[英]Static library gives error on iOS simulator and works on iOS device
Currently I'm working on a iOS application (iOS 6), In which I need to implement a static library. 目前我正在开发iOS应用程序(iOS 6),其中我需要实现一个静态库。
I successfully implemented the Static library using this tutorial . 我使用本教程成功实现了静态库。 And I successfully added the static library to other project and Installed the app to iPhone !. 我成功地将静态库添加到其他项目并将应用程序安装到iPhone! It's working successfully. 它运作成功。
But my issue is when I tried to run it on my simulator some errors are coming: 但我的问题是当我试图在我的模拟器上运行它时会出现一些错误:
"_OBJC_CLASS_$_MMPAlert", referenced from:
objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I added the target architecture like: 我添加了目标架构,如:
I searched a lot but couldn't find a solution, why my library is working on device and giving error on simulator. 我搜索了很多,但找不到解决方案,为什么我的库在设备上工作并在模拟器上给出错误。
Please help me, thanks in advance 请帮助我,提前谢谢
You have propably built your library for the device architecture only. 您已经专门为设备架构构建了库。 The iOS Simulator is not an emulator, meaning the code needs to be able to run on your Mac's architecture, which is obviously different from your device's architecture. iOS模拟器不是模拟器,这意味着代码需要能够在Mac的架构上运行,这显然不同于您的设备架构。
As a library is precompiled (for a specific architecture), the code it consists of doesn't get compiled again for your current target once you use it in your project. 由于库是预编译的(对于特定的体系结构),因此当您在项目中使用它时,它所包含的代码不会再为当前目标进行编译。 This is why you need to build your library for both architectures in the first place. 这就是为什么您需要首先为两种体系结构构建库。
This SO Answer explains how to bundle two library builds into one handy "fat file". 这个SO答案解释了如何将两个库构建捆绑成一个方便的“胖文件”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.