The static library gives an error on the iOS simulator and works on the iOS device

I am currently working on an iOS application (iOS 6) in which I need to implement a static library.

I have successfully implemented the Static library using this tutorial . And I successfully added the static library to another project and installed the application on the iPhone !. It works successfully.

But my problem is that when I tried to run it on my simulator, some errors will appear:

"_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 error console

I added the target architecture as follows:

Target settings

I searched a lot, but could not find a solution why my library works on the device and gives an error on the simulator.

Please help me, thanks in advance

+6
source share
1 answer

You have the opportunity to create your library for device architecture only. IOS Simulator is not an emulator, that is, the code must be able to work on your Mac architecture, which is clearly different from the architecture of your device.

Since the library is precompiled (for a specific architecture), the code that it consists of is not compiled again for your current purpose as soon as you use it in your project. That's why you need to create your own library for both architectures first.

This SO answer explains how to combine two libraries into one convenient โ€œthick fileโ€.

+5
source

All Articles