iOS Static Library Xcode (linking errors)

2019-08-09 22:56发布

I created a static library with Xcode I have compiled selecting a device.

I added this to my library test project in Xcode 4.6

but I always have 2 errors during the linking...

I followed this tutorial: Static Library iOS Tutorial

if I download the sample code I have the same errors:

ld: warning: ignoring file /Users/Downloads/ICodeBlogStaticLibrarySample/MathTest/Classes/iCodeBlogsMathLibrary/libICodeMathUtils.a, missing required architecture i386 in file /Users/Downloads/ICodeBlogStaticLibrarySample/MathTest/Classes/iCodeBlogsMathLibrary/libICodeMathUtils.a (2 slices) Undefined symbols for architecture i386: "_OBJC_CLASS_$_MathFunctions", referenced from: objc-class-ref in MathTestAppDelegate.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)

4条回答
聊天终结者
2楼-- · 2019-08-09 23:19

I had once made a static lirary , I had the same problem . Solution was to "Run the app on device " not on simulator , it works fine then !!! Hope this helps...

查看更多
Bombasti
3楼-- · 2019-08-09 23:29

You must have selected iOS simulator while building the project. Select iOS device and it should be fine.

查看更多
在下西门庆
4楼-- · 2019-08-09 23:39

Do read and try to understand the error message, it's a meaningful English phrase.

symbol(s) not found for architecture i386

So there's no compiled code for the i386 architecture in the library. This means that either it's compiled for ARM only (for actual iOS devices, like iPhone or iPad), or for the 64-bit simulator (x86_64). Use otool to find out the architectures present in the library.

查看更多
疯言疯语
5楼-- · 2019-08-09 23:40

I followed this step by step tutorial:

Tutorial

in particular I had to add these flags: -ObjC and -all_load

查看更多
登录 后发表回答