Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - file was built for archive which is not the architecture being linked (i386)

I got a few static libraries I want to use in my iphone app. When I try to run the simulator I get linking errrors. I am new to iOS development, and I ran into this problem when linking against libraries I built previously;

file was built for archive which is not the architecture being linked (i386)

Which means all the functions I reference from those libraries gives me this:

undefined symbols for architectyre i386

I am not sure what to configure to make this right. The static libraries are build for armv7, supporteed platforms armv6 armv7.

like image 313
KaiserJohaan Avatar asked Oct 24 '11 08:10

KaiserJohaan


2 Answers

I sorted a very similar error with a static library I was building for iPad. I believe my solution was to add "i386" to the Architectures setting for the project (Click on the Project -> Build Settings -> Architectures --or was it Valid Architectures?-- and click the '+' icon, type "i386" in the highlighted line). Anywho that should get you close.

Oh, one more caveat, I've read that we should set "Build Active Architecture Only" to "No" as well. It was already set for me, but that's something you might want to check.

like image 56
Ed Gonzalez Avatar answered Oct 23 '22 14:10

Ed Gonzalez


After struggling with this same problem and following all the accepted answers of updating build settings, clearing the linker search path, etc.. I finally discovered an answer that worked for me.

Before building, make sure you select right type (iPhone Simulator) instead of iOS Device. Then rebuild. Otherwise, you're trying to use a library built for an iOS device (arm processor) on a simulator (i386). Should've been obvious, but wasn't.

Before:

iOS Device Settings

After:

iPhone 5.1 Simulator Settings

Now, look in the Products group in the Navigator > right click your static library (.a file) > Show in Finder, you'll notice that its in a Debug-iphonesimulator folder instead of Debug-iphoneos. I didn't pay any attention to the folder name originally, or I might have thought of this sooner.

Hope this helps.

like image 42
Cody A. Ray Avatar answered Oct 23 '22 13:10

Cody A. Ray