110

I'm getting this error when building my iPhone application:

ld: warning: in /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/System/Library /Frameworks/UIKit.framework/UIKit, missing required architecture i386 in file

It goes the same for all the frameworks in my app. It's very weird since this was not happening earlier.

RedBlueThing
  • 42,006
  • 17
  • 96
  • 122
Gabe Shahbazian
  • 1,101
  • 2
  • 8
  • 3
  • Did this happen after you installed Snow Leopard and the new iPhone SDK (Xcode 3.2)? – avocade Sep 28 '09 at 13:45
  • 8
    My answer fixes the problem. Please check. – Jordan Oct 16 '10 at 14:44
  • 9
    One other possibility that's not discussed in the answers is that you will get this error if you have added a reference to a non-universal framework (i.e. you added an armv6/armv7 framework and then tried to do a simulator build). This is mainly a concern if you have been building your own custom frameworks. – aroth May 26 '11 at 23:11
  • @aroth is also correct, please check this [question](http://stackoverflow.com/questions/15659631/ignoring-file-path-missing-required-architecture-i386-in-file) – ArkReversed Sep 19 '13 at 08:44

16 Answers16

132

This happens when you add a framework to your project and unintentionally copy the framework into your project directory.

The fix is to check your project directory (where you store your project on disk) for any iphone SDK *.Framework files and delete them.

Project will build fine afterwards.

Jordan
  • 21,746
  • 10
  • 51
  • 63
  • 4
    in additionally, test it on iOS Device instead of Simulator. – Raptor Nov 01 '11 at 09:51
  • If you have another framework then modifying the project file seems to delete references to that too, this worked tho, and was easier, thanks Jordan – landon beach Feb 12 '13 at 03:25
  • Does not work for me. No .framework files in my project directory. Fwiw, I did a clean and then a build and this problem began. The clean somehow must have broken things. – Alyoshak Jul 12 '18 at 21:19
85

I had this same problem, and the solution turned out to be an easy fix. Backup then open project.pbxproj (located inside your project file bundle) in TextMate or TextEdit and search for the section titled "/* Begin XCBuildConfiguration section */". Look for a key named FRAMEWORK_SEARCH_PATHS and delete it and it's contents (once per build configuration, so I removed it in two places). Here is an example of what I deleted:

FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/System/Library/Frameworks\"",);

My project now build for both the iPhone device and the iPhoneSimulator.

Bill
  • 44,502
  • 24
  • 122
  • 213
Sean Roehnelt
  • 867
  • 5
  • 2
  • 2
    I can verify that this works as described. It seems Xcode can easily get out of touch with its metadata when moving Xcode projs between different computers; in this case with one having 3.0 and Leopard, and the other 3.1 and Snow Leopard installed. FRAMEWORK_SEARCH_PATHS metadata shows as blank in Build Settings while the actual project.pbxproj has stuff in it. – avocade Sep 28 '09 at 13:44
  • 1
    Agreed FRAMEWORK_SEARCH_PATHS also showed as blank in the build settings for me as well. However, hand-editing the project.pbxproj file as described fixed the problem. – Alasdair Allan Oct 05 '09 at 13:59
  • 11
    This did not work for me. HOWEVER, you lead me to the right place to look. My .pbxproj didn't have the FRAMEWORK_SEARCH_PATHS key, but a key named LIBRARY_SEARCH_PATHS. – rebellion Mar 02 '10 at 12:52
  • I second @rebellion. Perhaps the newer XCode versions have changed the key name. – Moshe Aug 19 '10 at 18:41
  • Thanks, I also had a stray LIBRARY_SEARCH_PATHS key in my pbxproj file. The key appeared in boldface in the Project Settings in Xcode 3, but with no value. This led me to believe there was something amiss. I did open the project in Xcode 4 Preview 5 once, after which this happened. – mvexel Jan 11 '11 at 11:13
  • +1 - deleting FRAMEWORK_SEARCH_PATHS resolved my problem of simulator builds not working, while device builds worked fine. Lifesaver. – Nostradamus Jun 30 '15 at 23:20
43

What has happened here is that Xcode has mysteriously added a "Framework Search Paths" entry that points to a particular iPhone device SDK. For example, mine was recently set to:

$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk/System/Library/Frameworks

This leads the compiler to find frameworks of the incorrect architecture. Removing any values under the "Framework Search Paths" key in your target's build settings will resolve the issue.

John Cromartie
  • 4,184
  • 27
  • 32
  • this was the problem in my case. it had added a bunch of search directories every time i add a new library. even if i remove reference the search directory entry used to be there which had caused the issue. – darshansonde Jan 18 '12 at 13:43
  • "Framework Search Paths" are already empty in my case. The exact error I'm getting is **ld: building for iOS Simulator, but linking against dylib built for MacOSX file '/usr/lib/libSystem.B.dylib' for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)** I'm using SDK 7.0 on Mavericks . – Ans Oct 30 '13 at 05:02
  • I had the same error, I removed the values from the framework search path under Build settings and now it compiles succesfully. – Nirav Sep 12 '15 at 14:33
10

I just wanted to mention that in XCode if you go to "Edit Project Settings" and find "Search Paths" There is a field for "Framework Search Paths". Updating this should fix the problem, without having to hack the project file!

Cheers!

Jesse

  • I have the same issue that is driving me absolutely crazy. It looks like you guys know the solution but I can not locate "project.pbxproj" file and Can not find where "Edit Project Settings" is located. – saman01 Sep 07 '11 at 02:56
  • 2
    In XCode 4.2.1 I found this as follows: click on the project name in the Project Navigator. In the properties screen which appears, select the 'Build Settings' tab. The Search Paths are located in this screen. Deleting them worked for me. – dsteele Feb 12 '12 at 23:16
8

I fixed it in a different way.The reason why i was getting this error was that i added security.framework twice in my project.I was not able to see security framework in xcode ,i opened the project in finder and found this framework which i deleted and problem solved.

Suraj K Thomas
  • 5,773
  • 4
  • 52
  • 64
8

Check that you didn't copy the framework into your project when you added it. If you copied it, it can't find the original paths. To fix this problem. Delete the AVFoundation framework from your frameworks folder in your project, then add it again, but this time, make sure you don't have copy check marked.

This fixed it for me!

Jrman52
  • 91
  • 1
  • 3
7

If your app is meant to run on the device, make sure you are not trying to run in it on the simulator. May sound obvious, but check anyway.

Eric Brotto
  • 53,471
  • 32
  • 129
  • 174
5

Though it is possible that something got deleted, it has been my experience that something gets screwed up in the project file. I have yet to pin down what that "something" is. I've had similar issues when the SDK installation is just fine. There are a couple of options.

First, add all of your files to a new project. This seems to usually work. Kind of a pain, though.

Second, you can right-click project in XCode/Get Info/Build/Library Search Paths. Add new paths similar to /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.sdk/usr/lib. Add appropriate versions of that string for each version (2.2.1, etc) and platform (simulator or iPhoneOS). Perform a similar action for Framework Search Paths if frameworks are your problem.

Third, which is more work but more reliable, is to open project.pbxproj from within MyProject.xcodeproj (Textmate is good for this). Look for "/* Begin XCBuildConfiguration section */", then "LIBRARY_SEARCH_PATHS" and "FRAMEWORK_SEARCH_PATHS". Add or modify the paths as appropriate, and save the file.

In any case, a pain in the butt, and I'd sure like to pin-point the cause because I've had this happen a couple of times. Project builds fine, then just up and refuses to do so with what seems to be little reason.

mikestew
  • 849
  • 4
  • 9
  • I'm going to just start a fresh project. Oh wells. – Gabe Shahbazian Sep 23 '09 at 00:59
  • You can fix the "Frameworks Search Paths" build settings from a target's info panel. – John Cromartie Sep 23 '09 at 16:48
  • I got the error but did not have the frameworks issues described above. Curiously, on one computer, the project could be check out of SVN and built fine, while on two others, it suddenly resulted in this error on every build. The only (and rather simple) fix - after trying all sorts of other solutions - was to create a new blank project and move all the files into it. – mmattke Sep 08 '11 at 18:18
  • This method worked for me. I had an working project set that suddenly stopped building for exactly one configuration one day. No reason. Used the textmate technique above and noticed that "$(SDKROOT)/Developer/Library/Frameworks" was missing from that configuration. No idea why, and I was unable to see this using Xcode. – Rob May 12 '12 at 19:22
4

It just happened here to me as well. Thanks to a great partner we found the answer. Your Xcode may be pointing to the simulator ..change it to a IOS device instead ..built smooth after ....

j2emanue
  • 60,549
  • 65
  • 286
  • 456
4

"Edit Project Settings" and find "Search Paths" There is a field for "Framework Search Paths". delete all!!

Litebeam
  • 61
  • 1
1

Run the file command on the framework from Terminal:

file /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/System/Library /Frameworks/UIKit.framework/UIKit

You should get back a message telling you which architectures the UIKit binary is compatible with. If you don't see "i386" listed, then you've somehow managed to remove the i386 version of UIKit, which will mean that you can't build for the simulator.To fix that, you'll have to re-install the SDK.

If you get some other error, hopefully it'll help you figure out what the actual problem is.

Mark Bessey
  • 19,598
  • 4
  • 47
  • 69
  • Reinstalled the sdk and I still get the same exact build error. – Gabe Shahbazian Sep 22 '09 at 02:47
  • i'm having this problem. already checked framework and library path and they're clean. the command file /Developer/Platforms.../UIKit.framework/UIKit only says "Mach-O dynamically linked shared library arm". is it really necessary to install the whole SDK?, or can i copy the full version of the framework? – Alexander Fradiani Nov 03 '11 at 22:44
  • Good to learn! for my case, armv7 and i386 is there, but no armv6! – Nianliang Aug 29 '12 at 09:21
1

I just want to let you know that In my case, I was having the same problem, I realized that I had an older Xcode folder called Xcode3.1.3 I just rename it because it was an older version and that did the magic for me.

Raya2
  • 11
  • 1
1

Check your library search paths in your target settings. Sometimes goofy libraries get entered in there and this will give you a similar error.

You can remove all entries in this section.

Atma
  • 29,141
  • 56
  • 198
  • 299
0

I'd just experienced something slightly different, because I work on my own library (WM_GSRecognizerLib), but the error is the same.

What'd happen: due to some updates, the path targeting the lib to include (.a) was from the "Debug-iphoneos" folder (where it is generated). Compiling for Generic iOS Devices worked fine, but not for simulator, complaining for the missing i386 architecture.

What I did for this issue, is to also include the binaries from the "Debug-iphonesimulator" folder.

It can help for this topic, because the explanation is here: devices require binaries for arm64/armv7/armv7s, while simulator does need i386.

tontonCD
  • 320
  • 2
  • 6
0

My solution was to set on simulator target debug YES, just look on git status to see the new line added as architecture only on .project. if you don't set this the build will run to all architectures and will show some missing architecture like i386 or other. NOTE THAT obviously the main issue is to use some framework that implements some kind of specific architecture.

-1

I too got the same error am using xcode version 4.0.2 so what i did was selected the xcode project file and from their i selected the Target option their i could see the app of my project so i clicked on it and went to the build settings option.

Their in the search option i typed Framework search path, and deleted all the settings and then clicked the build button and that worked for me just fine,

Thanks and Regards

Radix
  • 3,639
  • 3
  • 31
  • 47