ios - How do I xcodebuild a static library with Bitcode enabled? -


xcode 7 introduces bitcode, sort of llvm intermediate binary means apple's servers can recompile app different architectures without involvement.

at lookback, distribute static archive framework our library. seems when build "build & archive", bitcode not emitted library, , links library in app , tries build & archive bitcode enabled 1 of 2 warnings:

  • ld: 'lookback(lookback.o)' not contain bitcode. must rebuild bitcode enabled (xcode setting enable_bitcode), obtain updated library vendor, or disable bitcode target. (if lib built xcode 6)
  • ld: warning: full bitcode bundle not generated because 'lookback(lookback.o)' built bitcode marker. library must generated xcode archive build bitcode enabled (xcode setting enable_bitcode) (if lib built xcode 7 normal xcodebuild)

i have build script builds device+simulator universal binary, can't use build & archive, rather, run xcodebuild commandline script. how can make xcodebuild generate proper bitcode-enabled library?

bitcode compile-time feature (not link-time feature) means every .o file should contain section called __bitcode when built bitcode. can confirm whether binary bitcode-compatible running otool -l (my .o or .a file) | grep __llvm.

when build normally, xcode adds build flag -fembed-bitcode-marker clang invocation. seems sort of 'this bitcode go, if bitcode enabled' thing, , doesn't enable bitcode.

when "build & archive", flag replaced -fembed-bitcode, build bitcode-enabled binary.

there seems 2 ways make xcodebuild use -fembed-bitcode:

  • use 'archive' action, in xcodebuild -target lookbacksdk archive instead of xcodebuild -target lookbacksdk build. has side-effect of putting binaries in xcode organizer instead of build/ folder, though can work around using -exportarchive -archivepath ./build (thanks @jensayton)
  • force usage of flag adding other c flags other_cflags="-fembed-bitcode". xcodebuild invocation xcodebuild other_cflags="-fembed-bitcode" -target lookbacksdk build.

the latter chose don't have change build system, generate warnings every file, since both -fembed-bitcode-marker , -fembed-bitcode sent clang. luckilly latter wins, generating bitcode-enabled library!

resources


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -