Carthage / Carthage

A simple, decentralized dependency manager for Cocoa
Other
14.95k stars 1.55k forks source link

Bitcode not enabled for arm64 simulator XCFramework component #3187

Open jahorton opened 3 years ago

jahorton commented 3 years ago

Cartfile

To be clear, this Cartfile is used both for a framework and one app that integrates said framework.

github "marmelroy/Zip"
github "DaveWoodCom/XCGLogger" ~> 6.1.0
github "devicekit/DeviceKit" ~> 2.3
github "ashleymills/Reachability.swift"
github "getsentry/sentry-cocoa" ~> 4.4.3

Carthage Output

All dependencies (so, Carthage-built XCFrameworks) appear to build 100% fine and as normal.

Actual outcome

When building our framework (depending on those XCFrameworks) using these dependencies with ENABLE_BITCODE=YES, the following warnings occur during generic Simulator framework builds:

Screen Shot 2021-05-20 at 8 32 20 AM

I find it quite interesting that this only occurs for the arm64 architecture Simulator target; note how no issues arose from i386 and x86_64. This is also not seen during the arm64-oriented build for actual devices - just for the Simulator-oriented version.

Compilation is occuring on an older, x86_64 device; this was discovered when converting our framework to produce its own XCFramework for potential distribution. The work is open source, so more details can be seen at https://github.com/keymanapp/keyman/pull/5107 if desired.

Expected outcome

Carthage should support ENABLE_BITCODE=YES for arm64 architecture Simulator targets if it is also supported for the other Simulator architecture targets.

elliottwilliams commented 3 years ago

Interesting…I think this is expected behavior from Xcode? From the help text for ENABLE_BITCODE:

Activating this setting indicates that the target or project should generate bitcode during compilation for platforms and architectures that support it. For Archive builds, bitcode will be generated in the linked binary for submission to the App Store. For other builds, the compiler and linker will check whether the code complies with the requirements for bitcode generation, but will not generate actual bitcode.

Carthage builds the device variant using an archive action, and the simulator variant using a build action.

It looks like the built xcframeworks don't contain bitcode for the intel variants, either. I only see bcsymbolmaps for the device variants:

> find Carthage/Build -name \*.bcsymbolmap
Carthage/Build/Reachability.xcframework/tvos-arm64/BCSymbolMaps/684FB78B-CF6D-3CEE-8ED2-4979A3112D01.bcsymbolmap
Carthage/Build/Reachability.xcframework/ios-arm64_armv7/BCSymbolMaps/BE7D8F81-8774-3AC3-8FE5-5AADF21B6C07.bcsymbolmap
Carthage/Build/Reachability.xcframework/ios-arm64_armv7/BCSymbolMaps/5DAC7589-9933-3E0E-8707-EAD6761AE9D2.bcsymbolmap
Carthage/Build/Sentry.xcframework/watchos-arm64_32_armv7k/BCSymbolMaps/C69EB99E-9802-3B10-8479-AF11D8CD4739.bcsymbolmap
Carthage/Build/Sentry.xcframework/watchos-arm64_32_armv7k/BCSymbolMaps/3945145B-4453-37CD-95DB-A3C1A80CA9F7.bcsymbolmap
Carthage/Build/Sentry.xcframework/tvos-arm64/BCSymbolMaps/939F4220-73BD-34D4-A5E4-2AA5EA0CFB90.bcsymbolmap
Carthage/Build/Sentry.xcframework/ios-arm64_armv7/BCSymbolMaps/DEADBC65-817A-3D12-BA8D-4B9E404FD0C3.bcsymbolmap
Carthage/Build/Sentry.xcframework/ios-arm64_armv7/BCSymbolMaps/0A71B8AB-D8D2-36E5-AC32-947BC1A0C0B1.bcsymbolmap
Carthage/Build/DeviceKit.xcframework/watchos-arm64_32_armv7k/BCSymbolMaps/4DF24021-733C-313F-A033-87B45962A49E.bcsymbolmap
Carthage/Build/DeviceKit.xcframework/watchos-arm64_32_armv7k/BCSymbolMaps/CB2076DD-25C5-347C-8989-46034D3166A8.bcsymbolmap
Carthage/Build/DeviceKit.xcframework/tvos-arm64/BCSymbolMaps/624116B3-780E-3BC8-8269-3239BA3B58F4.bcsymbolmap
Carthage/Build/DeviceKit.xcframework/ios-arm64_armv7/BCSymbolMaps/8E59ABE7-AF8F-33AA-8D05-01A52E05D27E.bcsymbolmap
Carthage/Build/DeviceKit.xcframework/ios-arm64_armv7/BCSymbolMaps/94F4A1FF-8B20-3808-AB28-0D6EF733D20E.bcsymbolmap
Carthage/Build/Zip.xcframework/ios-arm64_armv7/BCSymbolMaps/078E045E-94F4-302F-972A-0361AD503BDB.bcsymbolmap
Carthage/Build/Zip.xcframework/ios-arm64_armv7/BCSymbolMaps/A8F0C087-1E2F-3B73-80A5-C105941D7896.bcsymbolmap
Carthage/Build/ObjcExceptionBridging.xcframework/ios-arm64_armv7/BCSymbolMaps/FB4FDD51-B2E7-3DC8-BD41-6279AC879C9C.bcsymbolmap
Carthage/Build/ObjcExceptionBridging.xcframework/ios-arm64_armv7/BCSymbolMaps/A65E8875-3A2D-38B2-AEAB-51995B769E47.bcsymbolmap
Carthage/Build/XCGLogger.xcframework/ios-arm64_armv7/BCSymbolMaps/F6047BA1-5B32-3C37-8550-58C4EB3BCAD7.bcsymbolmap
Carthage/Build/XCGLogger.xcframework/ios-arm64_armv7/BCSymbolMaps/C00B1FBE-4DD0-32D8-A49B-1E3287AB72A6.bcsymbolmap

And if I build XCGLogger.xcframework in Xcode directly, the binary doesn't contain bitcode either:

> otool -l  /Users/emw/Library/Developer/Xcode/DerivedData/XCGLogger-gqtydfwbsyuewvcfstsnblqfkzjq/Build/Products/Debug-iphonesimulator/XCGLogger.framework/XCGLogger | grep __LLVM
# nothing

But that warning makes it sound like your i386 and x86_64 simulator targets aren't building bitcode, but your arm64 simulator target is for some reason. I haven't looked too deep into your project, but is there something special it's doing to build its arm64-apple-ios-simulator slice with bitcode?

As I understand it, conceptually, Apple only intends for developers to enable bitcode when they're making a release build for the app store.

jahorton commented 3 years ago

Interesting…I think this is expected behavior from Xcode? From the help text for ENABLE_BITCODE:

Activating this setting indicates that the target or project should generate bitcode during compilation for platforms and architectures that support it. For Archive builds, bitcode will be generated in the linked binary for submission to the App Store. For other builds, the compiler and linker will check whether the code complies with the requirements for bitcode generation, but will not generate actual bitcode.

Carthage builds the device variant using an archive action, and the simulator variant using a build action.

...

But that warning makes it sound like your i386 and x86_64 simulator targets aren't building bitcode, but your arm64 simulator target is for some reason. I haven't looked too deep into your project, but is there something special it's doing to build its arm64-apple-ios-simulator slice with bitcode?

I can say that there's nothing intentional we did to cause that. When I look at the framework project's Build Settings in Xcode:

Screen Shot 2021-06-07 at 3 52 25 PM

I can't discern a way to put simulator-specific settings for the relevant build option, though that may just be a personal limitation. I'm fairly certain that was the only thing we altered when originally enabling bitcode back during the fat-framework era.

Not sure if it would matter, but the strategy we've landed on for now (which still experiences this issue) uses the build action for both variants. We want the .swiftmodule files in our final XCFramework, and archive wasn't playing nicely.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

danielsaidi commented 2 years ago

Did you find any more information regarding this? I recently switched to M1 and my XCFramework no longer has Bitcode enabled after archiving and creating the framework.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

jahorton commented 2 years ago

No new information regarding this, no. Looking back, I think we had to accept this as a limitation for now; I don't see a workaround in place. At least it only affects the simulator target; the distributed versions of apps using the framework still get bitcode.