CocoaPods / Rome

Makes it easy to build a list of frameworks.
MIT License
694 stars 64 forks source link

XCode 12 Support #89

Closed Unknoob closed 3 years ago

Unknoob commented 3 years ago

When using Rome on XCode 12, we get an error when merging the Simulator and Device frameworks.

fatal error: /Applications/Xcode12.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: 
/Users/{REDACTED}/Rome/build/Release-iphoneos/FBSDKCoreKit/FBSDKCoreKit.framework/FBSDKCoreKit 
and 
/Users/{REDACTED}/Rome/build/Release-iphonesimulator/FBSDKCoreKit/FBSDKCoreKit.framework/FBSDKCoreKit 
have the same architectures (arm64) and can't be in the same fat output file

That happens because when compiling for a Simulator on XCode 12, we end up with both x86_64 and arm64 binaries(thanks to the new arm Macs). To fix the problem I added a build setting to build only x86_64 architecture when building for the Simulator, that way we can merge it normally after both are compiled.

I still need help with 2 things.

The fix worked for me and may help some other people having this same error, but I'm not sure if I'm breaking the Simulator support on arm Macs, so any help would be appreciated.

kj800x commented 3 years ago

I also ran into this same issue today where my built frameworks weren't working on the simulator. Discovered the same thing that you did, the lipo command to merge the simulator and on-device frameworks failed and I ended up with a framework that only supported on-device. This fix looks good to me (although I'm just a stranger on the internet who has no actual ruby experience, not a maintainer of this project).

Here's the current output of file on the framework if I only generate the simulator build:

kjohnson@sudowoodo ~/src/framework-generator/ios/build/Release-iphonesimulator/React-RCTBlob/RCTBlob.framework $ file RCTBlob
RCTBlob: Mach-O universal binary with 3 architectures: [i386:Mach-O dynamically linked shared library i386] [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [arm64:Mach-O 64-bit dynamically linked shared library arm64]
RCTBlob (for architecture i386):    Mach-O dynamically linked shared library i386
RCTBlob (for architecture x86_64):  Mach-O 64-bit dynamically linked shared library x86_64
RCTBlob (for architecture arm64):   Mach-O 64-bit dynamically linked shared library arm64

It might be better to use EXCLUDED_ARCHS=arm64 to be more futureproof. Right now the simulator builds include i386, x86_64, and arm64 and I think we only need to remove arm64. On the other hand, we probably aren't losing much by dropping i386 support.

This relates to https://github.com/CocoaPods/Rome/issues/65