iOS 静态库 Xcode(链接错误)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14713557/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iOS Static Library Xcode (linking errors)
提问by Safari
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,文件 /Users/Downloads/ICodeBlogStaticLibrarySample/MathCodeBlogStaticLibrarySample/MathCodeBlogsMathLibrary/libICodeMathUtils.a 中缺少所需的架构 i386 (UniCodeBlogStaticLibrarySample/MathCodeBlogStaticLibrarySample/MathCodeBlogStaticLibrarySample)体系结构 i386 的符号:“_OBJC_CLASS_$_MathFunctions”,引用自:MathTestAppDelegate.old 中的 objc-class-ref:未找到体系结构 i386 clang 的符号:错误:链接器命令失败,退出代码为 1(使用 -v 到见调用)
采纳答案by Safari
回答by Subbu
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...
我曾经做过一个静态的lirary,我也遇到了同样的问题。解决方案是“在设备上运行应用程序”而不是在模拟器上,它可以正常工作!!!希望这可以帮助...
回答by neeraj
You must have selected iOS simulator while building the project. Select iOS device and it should be fine.
您必须在构建项目时选择了 iOS 模拟器。选择iOS设备应该没问题。
回答by neeraj
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. 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.
所以库中没有 i386 架构的编译代码。这意味着它要么仅为 ARM 编译(适用于实际的 iOS 设备,如 iPhone 或 iPad),要么为 64 位模拟器 (x86_64) 编译。使用otool
找出存在于库中的架构。