views:

7731

answers:

11

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.

A: 

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
Reinstalled the sdk and I still get the same exact build error.
gabeshahbazian
+1  A: 

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
I'm going to just start a fresh project. Oh wells.
gabeshahbazian
You can fix the "Frameworks Search Paths" build settings from a target's info panel.
John Cromartie
+6  A: 

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
+26  A: 

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.

  • Sean Roehnelt
Sean Roehnelt
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
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
Thank you very much!!!
goo
Thank you! Was banging my head against the wall trying to figure this out.
iworkinprogress
Thanks mate...spent almost two hours to find a cause.
Amit Vaghela
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
I second @rebellion. Perhaps the newer XCode versions have changed the key name.
Moshe
Thanks! This method is super helpful when opening projects in Xcode 3.x that were started in Xcode 4.x
joet3ch
+1  A: 

Hello, 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

A: 

As mentioned by somebody here, Reinstalling the SDK doesn't help, So I would suggest others not to waste time on that.

Vibhor Goyal
A: 

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
+2  A: 

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
A: 

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

Litebeam
A: 

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.

Buffernet
A: 

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