xcodebuild链接器断言失败

den*_*ycd 4 xcode ld ios bitcode

我在使用xcodebuild在命令行中构建iOS动态框架时遇到此ld断言错误.


0  0x10163b342  __assert_rtn + 144
1  0x101678a3a  archive::File<arm64>::makeObjectFileForMember(archive::File<arm64>::Entry const*) const + 1138
2  0x1016783e8  archive::File<arm64>::justInTimeforEachAtom(char const*, ld::File::AtomHandler&) const + 122
3  0x10168ea75  ld::tool::InputFiles::searchLibraries(char const*, bool, bool, bool, ld::File::AtomHandler&) const + 265
4  0x101697db8  ld::tool::Resolver::resolveUndefines() + 160
5  0x10169a117  ld::tool::Resolver::resolve() + 79
6  0x10163c060  main + 812
7  0x7fff9dd4c5ad  start + 1
A linker snapshot was created at:
/tmp/MyKit-2016-02-31-154836.ld-snapshot
ld: Assertion failed: (memberIndex != 0), function makeObjectFileForMember, file /Library/Caches/com.apple.xbs/Sources/ld64/ld64-253.9/src/ld/parsers/archive_file.cpp, line 355.
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

根据archive_file.cpp源代码(http://www.opensource.apple.com/source/ld64/ld64-253.3/src/ld/parsers/archive_file.cpp),似乎有某种符号损坏,而ld是加载图书馆.但除此之外,我不知道如何解决这个问题.

只有当我尝试通过添加"-fembed-bitcode"编译器标志来启用bitcode来构建我的框架时,才会出现此问题.

此外,在我的ld命令中,我试图链接一些静态库,其中一个是> 4.25 GB(内置bitcode),这个大小超过无符号32位整数的最大值(~3.99 GB) .我以前遇到过与libtool有关的一些问题,因为无法处理大型二进制库,所以这是我的怀疑之一.

我想知道是否有人遇到类似的问题或弄清楚如何解决它?谢谢

一些相关的问题

奇怪的xCode链接器错误我在说"断言失败"之前从未见过

https://github.com/SciRuby/nmatrix/issues/69

http://lists.llvm.org/pipermail/llvm-dev/2013-October/066722.html

https://github.com/TrinityCore/TrinityCore/issues/14689

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57438

don*_*key 5

Do you want to read the explanation for your error, which is ld: Assertion failed: (memberIndex != 0) ...? Follow this link

Also, don't worry about the size of your static library. The linker will remove all unnecessary information in the final executable. Please read here

TL; DR version:

  1. Clean your project using Command-Option-Shift-K. Also, choose Window > Organizer and switch to the Projects tab. Click the right-arrow to the right of the Derived Data folder name, delete Derived Data folder, and restart XCode.

  2. go to Build Settings in your project's settings => find Linking->Other linker flags => add -v. This will show you the exact corrupted file that is causing your error, if it still occurs. If you have the error again, please post the path of the corrupted file here, we can work from there.

  3. The reason of your error is because one of your static library is corrupt. You can remove your 4.25gb lib and rebuild again to see if this is the problem. It is under your project's target settings -> build phases -> link binary with libraries. If the error goes away, that might be it. In this case, care to give the name of the lib?