9
votes

First off, I want to state that without bitcode , everything is working perfectly. The problems start when I turn on the "bitcode" flag in the app.

Also, all of the builds are through a CI flow (not manually inside xcode->archive et.al).

The framework is built in a separate flow from the app itself (The app embeds the compiled framework)

I'm getting this error when I try to package the ipa:

❌ ld: bitcode bundle could not be generated because '..../Framework.framework/Framework' was built without full bitcode. All frameworks and dylibs for bitcode must be generated from Xcode Archive or Install build for architecture armv7

❌ clang: error: linker command failed with exit code 1 (use -v to see invocation)

Regarding the Framework:

I'm building the framework using the following command: (omitting technical details)

# iphone (arm)
xcodebuild -configuration Release -sdk iphoneos CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO

# iphone (simulator)
xcodebuild -configuration Release -sdk iphonesimulator CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO

and then lipo (FAT binary)

lipo -create /Release-iphonesimulator/Framework.framework/Framework -output /Universal/Framework.framework/Framework

I've added the compiler flag to the framework to "embed bitcode"

enter image description here

And I even "validated" it has bitcode per other S.O. questions: (Compiling iOS library with bitcode enabled)

Also, the easiest way to check if the binary contains bitcode is to use otool and grep:

otool -l binary_name | grep __LLVM

you will see one or more segname __LLVM entries if it does have bitcode or empty output if does not.

otool -arch arm64 -l Frameworks/Framework.framework/Framework  | grep __LL
segname __LLVM
segname __LLVM

I've also tried the other variation of added a compile flag

xcodebuild OTHER_CFLAGS="-fembed-bitcode"

and had identical error reported to me

1
I'm wondering if you were able to resolve this issue? I'm also having the same issue. I ran otool -arch armv7 -arch armv7s -arch arm64 -l Framework.framework/Framework | grep 'LLVM\|bitcode' and that return 6 LLVM. But when I tried to Archive, it failed with 'clang: error: linker command failed with exit code 1'. - sonoluminescence
In one of the comments to the answer in the link you provided, user Mecki indicates that __bitcode is a better indicator than __LLVM of correct bitcode compilation when checking the output of otool. Can you or OP check your compilation logs and see whether the -fembed-bitcode flag is actually being passed? - fullofsquirrels
One further note: in the same comments, user Jonny indicates that he only added the -fembed-bitcode compiler flag to the main target, not to any of the embedded frameworks themselves, and was successful. - fullofsquirrels
@fullofsquirrels thanks for replying to the question. here's my univeral build scripts where I'm passing fembed-bitcode: xcodebuild -project ${NAME}.xcodeproj -scheme ${NAME} -configuration 'Release' -sdk iphoneos enable_bitcode=yes -arch arm64 -arch armv7 -arch armv7s only_active_arch=yes OTHER_CFLAGS='-fembed-bitcode' clean build | tee iphoneos.log | xcpretty xcodebuild -project ${NAME}.xcodeproj -scheme ${NAME} -configuration 'Release' -sdk iphonesimulator10.3 -arch x86_64 -arch i386 only_active_arch=no OTHER_CFLAGS='-fembed-bitcode' clean build | tee iphonesimulator.log | xcpretty - sonoluminescence
xcrun lipo -create -output $DIR/${NAME}.framework/${NAME} Build/Products/Release-iphoneos/${NAME}.framework/${NAME} Build/Products/Release-iphonesimulator/${NAME}.framework/${NAME} - sonoluminescence

1 Answers

0
votes

Add BITCODE_GENERATION_MODE=bitcode in the target's build settings as a user defined setting.