Weird xCode linker error I've never seen befor

2019-05-11 14:45发布

问题:

Built this game through Unity, and managed to compile through xCode once before. Without any apparent changes, however, this error message turns up. I don't understand where to start looking for a fix, but maybe someone else have a clue? I've seen similar looking errors through searches, though the fixes seem arbitrary compared to mine.

Anyone able to shed some light? Thank you!!

0 0x1034de0e7 __assert_rtn + 144 1 0x10351350c archive::File<arm>::makeObjectFileForMember(archive::File<arm>::Entry const*) const + 1142 2 0x103512c9a archive::File<arm>::forEachAtom(ld::File::AtomHandler&) const + 416 3 0x10352a6a1 ld::tool::InputFiles::forEachInitialAtom(ld::File::AtomHandler&, ld::Internal&) + 465 4 0x10353490e ld::tool::Resolver::resolve() + 48 5 0x1034dec47 main + 679 A linker snapshot was created at: /tmp/wingOstar-2014-09-26-171939.ld-snapshot ld: Assertion failed: (memberIndex != 0), function makeObjectFileForMember, file /SourceCache/ld64/ld64-236.4/src/ld/parsers/archive_file.cpp, line 355. clang: error: linker command failed with exit code 1 (use -v to see invocation)

回答1:

This seems like the kid of error the Xcode developers hope you never actually see...

The part of that message that is likely most useful for searching against will be the ld: Assertion failed: (memberIndex != 0), since that is the root of the error rather than supporting information.

I probably found the same few sources you did, but they indicated that this is caused by corruption in one of the resources Xcode is trying to link your program against, rather than something immediately caused by your own code. A file becoming corrupted by some external action would explain how this can happen despite no obvious changes in your program source.

So the obvious suggestion for fixing this would be to repair the corruption by making sure whatever is causing it gets recompiled. The first thing to do is to completely clean your project so that no older precompiled files are used and all of your own code is rebuilt. Since your error mentions a source cache, follow the recommendation here to wipe all caches, not just those cleared by the Product->Clean option.

The error message also gives a suggestion to use the -v flag to see what ld is actually doing, which may help you narrow down which object files could be corrupt (by showing you which ones are actually used). To add the flag, go to Build Settings in your project's settings, go down to Linking->Other linker flags, and add -v to those. Once you've rebuilt the project, look at the Build messages in the Report Navigator panel, and expand the linker messages for a full list of linked objects. If any of these options refer to libraries you provided, consider deleting and rebuilding them, before cleaning and rebuilding your project again.



标签: c# ios c xcode linker