ios static library Undefined symbols for architecture x86_64

匿名 (未验证) 提交于 2019-12-03 00:44:02

问题:

lipo -info libXxxx.a Architectures in the fat file: libXxxx.a are: armv7 i386 arm64

But compiler in the dependant project is giving linking error,

Undefined symbols for architecture x86_64:   "_OBJC_CLASS_$_ClassXXXX", referenced from:       objc-class-ref in AppDelegate.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) 

Am I missing something? All the lib project's target have Architectures: Standard Architectures (armv7, arm64) and Valid Architectures arm64, armv7, armv7s

in my lipo command while making universal binary I am lipo-ing both from iphonesimulator and iphoneos folder.

回答1:

Your main clue is that it says "symbol(s) not found for architecture x86_64" instead of "symbol(s) not found for architecture i386".

The fix is to tweak your build settings to allow a 32-bit build.

1) Select your project file in the Project Navigator (the left sidebar)

2) Select your project's target (first entry under TARGETS in the panel that just came up)

3) Find the "Architectures" setting (make sure "All" is selected if you can't find "Architectures")

4) Change it from "Standard Architectures" to "Universal" (or explicitly "32-bit" if you prefer)

You should be able to build after doing this.



回答2:

You need to create a universal binary including following architectures in your static library project. The architectures should be including 64-bit, armv7, armv7s, arm64.

Now when you do a lipo -info anyStaticLibrary.a on terminal - you should see armv7 armv7s i386 x86_64 arm64 architectures for your fat binary.

Also note that the project which uses the above static library can work fine with the default settings of the architectures.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!