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

I got to build static library. I want to use in my iPhone and ipad app. When I try to run the simulator I get linking errrors. I am new to iOS development. kindly help;

ld: warning: ignoring file /Users/valuelabs/Desktop/DruvaProject/libraries/libnetUtils.a, file was built for archive which is not the architecture being linked (i386) Undefined symbols for architecture i386:
"_OBJC_CLASS_$_netUtils", 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 tried adding i386 in the Architectures. but no luck


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 on your mac (i386). Should've been obvious, but wasn't.

Before:

iOS设备设置

After:

iPhone 5.1模拟器设置

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.


Sometimes these types of errors irritates you!

Removing Derived Data Works for me:

Steps to fix

1) In XCODE > Windows > Project > Select your project > Delete derived Data > Quit XCODE and Reopen it > If you get MAC-O-Linker builed failed error > Refere this link > Clean and Build again.


Your libnetUtils.a is being built for a different architecture than your target.

Check the libnetUtils build settings. The architectures that it is being built for and its list of supported architectures must be a (weak) superset of your target's architecture. The complexity here is that the resulting architecture is spread over various settings: "Architectures", "Build active architecture only" and "Valid Architectures".

"Build active architecture only" settings make this particularly confusing. For example, suppose you are building for the simulator. If the "Build active architecture only" setting for Debug is set to NO, it will be building all the architectures listed in "Architectures" and "Valid architectures" (probably armv7, etc). But if libnetUtils has that setting set to Yes (Debug: Yes) it is only building for i386. So when your linker tries to link armv7 with i386, it fails.

链接地址: http://www.djcxy.com/p/64606.html

上一篇: O X链接器错误4.6

下一篇: 文件是为归档而构建的,而不是被链接的体系结构(i386)