简体   繁体   English

静态库在iOS模拟器上出错,适用于iOS设备

[英]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)

Xcode错误控制台

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.

相关问题 静态iOS库针对设备而非模拟器进行构建 - Static iOS Library builds for device but not Simulator 在iOS模拟器上可以使用,但在iOS设备上不能使用吗? - Works on iOS Simulator but not on iOS device? Xcode 5和iOS 7模拟器/设备崩溃并出现僵尸错误-适用于iOS6 - Xcode 5 and iOS 7 Simulator/Device Crash with zombie error - Works on iOS6 为iOS(设备和模拟器)构建静态库并在XCode中使用 - Build static library for iOS (Device and Simulator) and use in XCode iOS应用程序可在模拟器上运行,但不能在设备上运行 - IOS application works on the simulator but not on the device 字体适用于模拟器但不适用于 iOS 设备 - Font works on Simulator but not iOS device iOS实际设备上的Appium出现SDK Iphone Simulator错误 - Appium on ios actual device gives sdk iphone simulator error 在模拟器上工作的iOS上打开的iOS设备因UIPopoverController错误而崩溃 - IOS open in works on simulator crashes on device with UIPopoverController error iOS Webkit不在设备上工作,但在swift的模拟器上运行 - iOS Webkit not working on device, but works on simulator at swift iOS应用程序在模拟器中以后台模式工作,但在设备中不工作吗? - iOS app works in background mode in simulator but not in device?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM