ld: bitcode bundle could not be generated because '/Users/YzsComPuter/Desktop/IOS_KTV/ktv_ios/BaiduMapAPI_Location.framework/BaiduMapAPI_Location(BMKLocationService.o)' was built without full bitcode. All object files and libraries for bitcode must be generated from Xcode Archive or Install build for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
如果打包出现上述类似的错误,只需在build setting 里搜索bitcode关闭即可。
官方的解释:
Bitcode is an intermediate representation of a compiled program. Apps you upload to iTunes Connect that contain bitcode will be compiled and linked on the App Store. Including bitcode will allow Apple to re-optimize your app binary in the future without the need to submit a new version of your app to the store.
说的是bitcode是被编译程序的一种中间形式的代码。包含bitcode配置的程序将会在App store上被编译和链接。bitcode允许苹果在后期重新优化程序的二进制文件,而不需要重新提交一个新的版本到App store上。
而在 What’s New in Xcode-New Features in Xcode 7 中,还有一段如下的描述:
Bitcode. When you archive for submission to the App Store, Xcode will compile your app into an intermediate representation. The App Store will then compile the bitcode down into the 64 or 32 bit executables as necessary.
Bitcode配置
在上面的错误提示中,提到了如何处理我们遇到的问题:
You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE www.maiziedu.com), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64
要么让第三方库支持,要么关闭target的bitcode选项。
实际上,在Xcode 7中,我们新建一个iOS程序时,bitcode选项默认是设置为YES的。我们可以在”Build Settings”->”Enable Bitcode”选项中看到这个设置。不过,我们现在需要考虑的是三个平台:iOS,Mac OS,watchOS。
对于iOS,bitcode是可选的;对于watchOS,bitcode是必须的;而Mac OS是不支持bitcode。
所以,如果我们的工程需要支持bitcode,则必要要求所有引入的第三方库都支持bitcode。