28

I'm quite new to Xcode and Iphone development and ran into the following problem:

I opened a new project and added *.h and a *.a files (which I recived from a certain device vendor). I get the following warning:

ld: warning: ignoring file /Users/udi/Desktop/Xcode/Xcode Projects/Scosche/libmyTrekSDK_armv7.a, missing required architecture i386 in file /Users/udi/Desktop/Xcode/Xcode Projects/Scosche/libmyTrekSDK_armv7.a (2 slices)

If I ignore the warning, and try to instanciate the class that is given to me in the header file, I get these errors:

ld: warning: ignoring file [Path/FileName.a], missing required architecture i386 in file [Path/FileName.a] (2 slices)

Undefined symbols for architecture i386:

"_OBJC_CLASS_$_HRMonitor", 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've checked the Framework Search Pathes (as mantioned in many other posts) and it clear.

More info:

  1. I'm Using Xcode 4.6.1
  2. The files are currently located at project's root folder.
  3. I'm using a Single View Application tamplate.

Appreciate any help

U_D
  • 711
  • 1
  • 10
  • 18

3 Answers3

52

This warning means that you're trying to use library made for Device (ARM) with your Simulator (i386).

You can use this terminal command to create a universal library:

lipo -create lib_arm.a lib_i386.a -output lib_universal.a

More info about lipo command here.

Dmitry Zhukov
  • 1,809
  • 2
  • 27
  • 35
  • 1
    I guess the libraries need to exist for both armv7 and i386, right ? – Dani Pralea Oct 07 '13 at 07:46
  • 2
    Got "can't open input file: lib_arm.a (No such file or directory)" Is there a specific spot where you're supposed to run this command? – shim Oct 18 '13 at 01:56
  • @shim, you should change directory to the one, where your static libs (arm and i386) are, like this: $ cd /libs/ $ lipo -create *name_of_your_arm_lib*.a *name_of_your_386_lib*.a -output lib_universal.a – Dmitry Zhukov Oct 18 '13 at 09:58
  • @ Dmitry Zhukov can you show me how can I know the directory of my static libs , because i met the same error like Shim – tommy Dec 04 '13 at 08:37
  • @tommy **lipo** makes universal lib from libs with specific arch_types (or vice versa) and *lib_arm.a* here is just a placeholder. You can use *your_lib_name.a* if specific libs are located in same folder, or you can just use *path_to_your_lib/your_lib.a*. Hope this helps. – Dmitry Zhukov Dec 05 '13 at 09:17
  • My bad .. I was trying to run on simulator instead of device. Didn't change anything and just run my application over my iPad and everything is good. – Ans Apr 09 '14 at 11:11
  • 1
    I have a BluetoothManager.framework in my app, with the two .h files included. App runs well on iPad but I get the i386 error when I try it on the simulator. Can't finsd a way around. – Jorgen Apr 30 '14 at 08:09
  • @Jorgen did you find any solution for same.? I have case where I have .framework and facing same issue. – Abhishek Sharma Jul 11 '18 at 07:28
7

Change your target's "Build Settings > Build Active Architectures Only" to "No"

This is doing the same thing as Dmitry Zhukov's answer but doing it thru Xcode instead of going around its back.

Lucas Goossen
  • 527
  • 7
  • 15
4

If you are working with a 3rd party code, keep in mind that some SDKs may not work on the simulator. The same build error I have encountered vanished, when I ran the project on the device.

Yunus Nedim Mehel
  • 12,089
  • 4
  • 50
  • 56