XcodeGen icon indicating copy to clipboard operation
XcodeGen copied to clipboard

How to declare a Carthage built XCFramework dependency?

Open pouty18 opened this issue 4 years ago • 5 comments

I'm preparing my project for the upcoming Carthage release, which will build dependencies as XCFrameworks. How do I properly indicate a dependency on an XCFramework in my project.yml project spec?

Second question: Is there a way to disable the carthage copy files script being automatically added: If any applications contain carthage dependencies within itself or any dependent targets, a carthage copy files script is automatically added to the application containing all the relevant frameworks. A FRAMEWORK_SEARCH_PATHS setting is also automatically added

For context, in the upcoming carthage release, they indicate that you'll no longer need to include a run script to call carthage copy-frameworks, and including this would actually introduce breaking changes to the currently carthage update --use-xcframeworks flow.

pouty18 avatar Jan 11 '21 22:01 pouty18

figured it out, since xcframeworks don't need Carthage's copy frameworks run script anymore, you can just reference them in the dependency target like so

targets:
  MyApp:
    dependencies:
      framework: "Carthage/Build/iOS/Alamofire.xcframework"

and then you're good to go.

DrewKiino avatar Jan 11 '21 22:01 DrewKiino

Is there any plan to update the XcodeGen to allow carthage: Alamofire to find the XCFramework? The shorthand is still nice to avoid entering in the full path to the dependency. Especially now that Carthage has been released to support building XCFrameworks.

CraigSiemens avatar Feb 01 '21 19:02 CraigSiemens

I've put up a draft PR for this here #1020, if you'd like to test it

yonaskolb avatar Feb 15 '21 02:02 yonaskolb

Would appreciate some testing of this to make sure it works on your projects. You can use Mint to test it easily

mint run yonaskolb/xcodegen@carthage-xcframeworks xcodegen

yonaskolb avatar May 01 '21 04:05 yonaskolb

I replied to the PR that was linked the my results from testing it (https://github.com/yonaskolb/XcodeGen/pull/1020#issuecomment-918304960) but I also wanted to reply here too.

One issue I've noticed with added an xcframework from carthage as a dependency when the project also has a framework target and an app target.

  • If added to the app using framework it works fine
  • If added to my framework target the app will fail to launch cause the xcframework wont be copied into the app. Previously the copy script from carthage was copying in the frameworks and stripping out symbols. Striping out the symbols is no longer needed, but copying the frameworks is.

CraigSiemens avatar Sep 29 '21 21:09 CraigSiemens