简体   繁体   English

iOS静态库Xcode(链接错误)

[英]iOS Static Library Xcode (linking errors)

I created a static library with Xcode I have compiled selecting a device. 我用Xcode创建了一个静态库我编译了选择一个设备。

I added this to my library test project in Xcode 4.6 我将它添加到Xcode 4.6中的库测试项目中

but I always have 2 errors during the linking... 但在链接期间我总是有2个错误...

I followed this tutorial: Static Library iOS Tutorial 我遵循了本教程: 静态库iOS教程

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) ld:警告:忽略文件/Users/Downloads/ICodeBlogStaticLibrarySample/MathTest/Classes/iCodeBlogsMathLibrary/libICodeMathUtils.a,文件中缺少必需的体系结构i386 /Users/Downloads/ICodeBlogStaticLibrarySample/MathTest/Classes/iCodeBlogsMathLibrary/libICodeMathUtils.a(2个切片)未定义体系结构i386的符号:“_ OBJC_CLASS _ $ _ MathFunctions”,引自:MathTestAppDelegate.o中的objc-class-ref ld:未找到架构i386 clang的符号:错误:链接器命令失败,退出代码为1(使用-v to看调用)

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... 希望这可以帮助...

I followed this step by step tutorial: 我按照这个一步一步的教程:

Tutorial 教程

in particular I had to add these flags: -ObjC and -all_load 特别是我不得不添加这些标志: -ObjC-all_load

You must have selected iOS simulator while building the project. 您必须在构建项目时选择iOS模拟器。 Select iOS device and it should be fine. 选择iOS设备,应该没问题。

Do read and try to understand the error message, it's a meaningful English phrase. 阅读并尝试理解错误信息,这是一个有意义的英语短语。

symbol(s) not found for architecture i386 找不到架构i386的符号

So there's no compiled code for the i386 architecture in the library. 因此,库中没有i386架构的编译代码。 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). 这意味着要么只为ARM编译(对于实际的iOS设备,如iPhone或iPad),要么为64位模拟器(x86_64)编译。 Use otool to find out the architectures present in the library. 使用otool查找库中存在的体系结构。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM