Carthage: How do I get Carthage to build all platforms of a single cross-platform target?

Created on 5 Sep 2016  路  5Comments  路  Source: Carthage/Carthage

  • carthage version 0.17.2
  • xcodebuild version Xcode 7.3.1 Build version 7D1014

I maintain Bedrock, and I'm trying to get the single "Bedrock" framework target (which supports multiple platforms) to build for each platform, but Carthage will only build for iOS.

Cartfile

github "nsforge/Bedrock" "master"

Carthage Output

carthage update
*** Fetching Bedrock
*** Fetching expecta
*** Downloading expecta.framework binary at "v1.0.5"
*** Checking out Bedrock at "b961a5746aa74c34b043dbc85b9bf0d9dfa464dd"
*** xcodebuild output can be found in /var/folders/lk/zqsb2vks1dj8kxz57rt2yzg00000gq/T/carthage-xcodebuild.xZEttt.log
*** Building scheme "Bedrock" in Bedrock.xcodeproj

The output that I get in the Carthage folder includes:
Build/iOS/Expecta.framework
Build/iOS/Bedrock.framework
Build/Mac/Expecta.framework

But the following binary is missing:
Build/Mac/Bedrock.framework

I've configured Bedrock.xcodeproj to build for every platform (Mac, iOS, iOS Simulator etc.) by using the following in an .xcconfig:

SUPPORTED_PLATFORMS = macosx iphoneos appletvos watchos appletvsimulator iphonesimulator watchsimulator
TARGETED_DEVICE_FAMILY = 1,2,3,4

This allows me to build and test for any of the above platforms from within Xcode.

Does Carthage support building multiple platforms for a single scheme? If it does, what logic does it use to pick the platform(s) to build for each scheme?

Is there a recommended approach to building cross-platform frameworks that doesn't involve having a separate target per platform?

question

Most helpful comment

Looks like your Bedrock.xcconfig is only set for Debug configuration, not for Release configuration and Carthage builds dependencies with Release configuration by default. SDKROOT = iphoneos is set at the project level without the xcconfig file, so this is the reason why the iOS one is built.

All 5 comments

When I try to build specifically for iOS or Mac using --platform, I get the following results:

carthage build --platform iOS
*** xcodebuild output can be found in /var/folders/lk/zqsb2vks1dj8kxz57rt2yzg00000gq/T/carthage-xcodebuild.g8F9G1.log
*** Building scheme "Bedrock" in Bedrock.xcodeproj
carthage build --platform Mac
*** xcodebuild output can be found in /var/folders/lk/zqsb2vks1dj8kxz57rt2yzg00000gq/T/carthage-xcodebuild.VGUpmk.log
*** Skipped building Bedrock due to the error:
Dependency "Bedrock" has no shared framework schemes for any of the platforms: Mac

If you believe this to be an error, please file an issue with the maintainers at https://github.com/nsforge/Bedrock/issues/new

This should work: #622. Carthage looks at SUPPORTED_PLATFORMS. But I haven't implemented a universal framework, so I'm not sure of the specifics. Maybe you need to add a scheme for each platform?

If you get it working, a PR to document it would be super helpful!

Looks like your Bedrock.xcconfig is only set for Debug configuration, not for Release configuration and Carthage builds dependencies with Release configuration by default. SDKROOT = iphoneos is set at the project level without the xcconfig file, so this is the reason why the iOS one is built.

@ikesyo you are correct, Bedrock.xcconfig wasn't set on the Release configuration. I'd set it in my local copy but hadn't committed+pushed from my local machine. 馃槼 Once I cleaned up the configuration it started working perfectly. I also cleared SDKROOT so it uses whatever Xcode decides is the "default", but I'm not sure if that actually makes a difference or not. Many thanks!

Thanks for the link to Bedrock - helped me out a LOT today!

One thing worth noting for anyone else who ends up here is that I had to set the Base SDK to "Other" and then clear any text there so it's just empty and sets the Base SDK to "No SDK (Latest macOS)". Otherwise Carthage would try and look in .../Build/Products/Release-iphones/.... for all platforms (I had iphoneos set as the Base SDK to start with.

UPDATE

Just re-read the comment above and that's exactly the bit that fixed it for me - clearing SDKROOT.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

itinance picture itinance  路  3Comments

faustperic picture faustperic  路  3Comments

Ogerets picture Ogerets  路  3Comments

pmhood picture pmhood  路  3Comments

JustinJiaDev picture JustinJiaDev  路  3Comments