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

14,560

Solution 1

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.

Solution 2

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.

Share:
14,560

Related videos on Youtube

KaiserJohaan
Author by

KaiserJohaan

Updated on June 04, 2022

Comments

  • KaiserJohaan
    KaiserJohaan almost 2 years

    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.

    • James Webster
      James Webster over 12 years
      It seems the libraries aren't compatible with the simulator, they haven't been built for i386. Test on a device or if the code from the libraries is available to you, rebuild it, including the i386 architecture
    • Pooja M. Bohora
      Pooja M. Bohora over 12 years
      Anyone got solution for this? I am also facing the same problem.