美文网首页
构建一个支持bitcode的静态库

构建一个支持bitcode的静态库

作者: yxibng | 来源:发表于2019-08-28 16:57 被阅读0次

参考

如何检测一个库是否支持bitcode

otool -l (my .o or .a file) | grep __LLVM

添加设置,打包静态库的时候,支持bitcode

When you build normally, Xcode adds the build flag -fembed-bitcode-marker to any clang invocation. This seems to be some sort of 'this is where bitcode would go, if bitcode was enabled' thing, and doesn't actually enable bitcode.

When you "Build & Archive", this flag is replaced by -fembed-bitcode, which really does build a Bitcode-enabled binary.

There seems to be two ways to make xcodebuild use -fembed-bitcode:

  • Use the 'archive' action, as in xcodebuild -target LookbackSDK archive instead of xcodebuild -target LookbackSDK build. This has the side-effect of putting binaries in your Xcode Organizer instead of the build/ folder, though you can work around that by using -exportArchive -archivePath ./build (thanks @JensAyton)
  • Force usage of the flag by adding Other C Flags with OTHER_CFLAGS="-fembed-bitcode". >Your xcodebuild invocation would look something like xcodebuild OTHER_CFLAGS="-fembed-bitcode" ->target LookbackSDK build.

The latter is what I chose so that I don't have to change my build system, but it will generate warnings for every file, since now both -fembed-bitcode-marker and -fembed-bitcode are sent to clang. Luckilly the latter wins, generating a Bitcode-enabled library!

相关文章

网友评论

      本文标题:构建一个支持bitcode的静态库

      本文链接:https://www.haomeiwen.com/subject/mtsmectx.html