问题描述
我需要发布一个启用了bitcode的框架,结果很麻烦。我将项目设置中的启用Bitcode设置为YES,它可以为真实设备和模拟器进行干净的构建。
I need to release a framework with bitcode enabled which turns out as a hassle. I set 'Enable Bitcode' in the project's settings to 'YES' and it builds cleanly for both a real device and a simulator.
我想测试库,所以我将它集成到我为此目的创建的新应用程序,但现在它只为模拟器构建。当我尝试为真实设备构建时,我得到:
I wanted to test the library so I integrated it to a new app I created for this purpose but now it only build for simulators. When I try to build for a real device I get:
ld: '/path/to/Framework.framework/Company(File.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
就像我说的那样,我已经用Bitcode启用了它,所以我不确定为什么会这样。
Like I said, I had built it with Bitcode enabled so I'm not sure why this happens.
有什么想法吗?谢谢
推荐答案
AFAIK,当您使用Xcode构建应用程序时,它仅在您进行存档时包含Bitcode,原因是 - 减少编译时间只是想调试或测试应用程序/库。
AFAIK, when you build app with Xcode it includes Bitcode only when you make archive, the reason - decrease compile time when just want to debug or test the app/library.
为了确保Xcode在每次构建时发出bitcode,你可以添加 -fembed-bitcode
标志为其他C标志
和其他链接器标志
:
To ensure that Xcode emits bitcode at each build you can add -fembed-bitcode
flag to Other C flags
and Other linker flags
:
此外,检查二进制文件是否包含bitcode的最简单方法是使用 otool
和 grep
:
Also, the easiest way to check if the binary contains bitcode is to use otool
and grep
:
otool -l binary_name | grep __LLVM
你会看到一个或多个 segname __LLVM
条目,如果有的话如果没有,则为bitcode或空输出。
you will see one or more segname __LLVM
entries if it does have bitcode or empty output if does not.
这篇关于编译启用了bitcode的iOS库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!