Build Error - missing required architecture i386 in file - iphone

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.

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.

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.

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.

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

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!

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.

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.

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.

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

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 ....

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.

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.

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.

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.

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.

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

Related

Finding the right way to include static libraries in Xcode

First of all I have to say that I'm new with Xcode and I found some things a bit comfusing for beginners.
For now I want to include SQLite support in my test app. I found the wrapper "FMDB" which seems very easy to use.
I was already able to include the .m and .h files into my project and setting the header line for bridging to Swift.
But if I build my app then I will get some link errors. I think the problem is that the sqlite library is missing. But I've no idea to include it. So I searched the web for some tutorials but all I found seems too old and didn't help me.
What I've already done are the following steps: I selected the top item of my project in the Project Explorer. Then I selected my build target and switched to the tab "Build Phases". But now I see no possibility to include the libsqlite.a file. I followed some suggestions and typed the keyword "sqlite" in the search field but I only get the message "No results found."
I'm using Xcode 8 + Swift 3 on Mac Sierra.
I think that U should find libsqlite.a file in the filesystem and only then add libsqlite.a to project by right click on project files in Xcode 8 and selecting "add files to " and select you .a library from system location like Homebrew's sqlite root folder, only then you can select this static library in "+" linking menu. Please read this answer:
https://stackoverflow.com/a/15974037/2835276
I solved my problem by including sqlite3.c and sqlite3.h from sqlite.org so every wrapper works fine.

Xcode won't build to device

This problem has been KILLING me. I've been working on this app for 8 Months, and I am so close to finishing, I just can't seem to build for device. Building for the simulator works fine, but device always gives me the SAME 2 errors.
The 1st Error:
"Instruction requires a CPU feature not currently enabled"
From googling, I've found this probably means I'm not linking a binary I should be, but I'm not sure.
The 2nd Error:
If you can't read it, it says: Generating JWFNS.app.dSYM ... error: unable to open executable '/Users/ajr1188/Library/Developer/Xcode/DerivedData/JWFNS-azshgysfabycfagnebotitpcyaww/Build/Products/Debug-iphoneos/JWFNS.app/JWFNS'
This is the big one. I cannot seem to build the .app.dSYM file properly. I went in and deleted the build folder, I looked at EVERY stackoverflow question I could find and tried changing any random thing mentioned in another question, but all of it is to no avail. I'm so suck right now. AHH. PLEASE. Any help would be so appreciated!
Maybe your project has become hopelessly corrupted. One thing to try is to start a brand new project and copy/import all your sources/assets into the new project to see if that fixes the problem.
Another less nuclear (but perhaps more time consuming) approach is to binary search the build. Exclude absolutely everything except main.m and see if that fixes the problem. If it does, include half your sources, and buid again....repeat, trying to narrow in on the problem spot. Maybe a file or group of files has received special build settings that don't belong there.
I've had very similar problems, I cant remember the exact error message but it was very similar. Are you able to make a new project that will run on your device?
if so (and I know this sounds bad but it's worth a try) Create a new project and simply copy all the code and resources across and see if it still works. If it doesn't then there is something wrong with you code and you can continue trying to isolate the problem from there.
Hope this is helpful.
check the frameworks you link to. there's a chance that you linked a framework (say quartz) of osx, instead of ios.
Answering in detail is probably going to take looking at your target settings. But it looks like you may be building for the wrong architecture. (It doesn't link, so there is no .dSYM symbol file.) For example, if you have only recently built for device, you probably created your project under an older Xcode, and it may not have the arm6/arm7 settings right.
To check, show the Build Settings for your target (not the project), and filter on Architecture.
Make sure that in build settings the architectures are armv6 and armv7. Also make sure that in .plist file, the "Application requires iPhone environment" is TRUE. Delete "Required device capabilities" in the .plist if present.

Importing frameworks on xcode 4 issue

Lately any framework I attempt to add to my project fails with "No such file or directory".
Eg for GameKit:
<GameKit/GameKit.h>: No such file or directory
The strange thing is that the frameworks that I added some time ago are found, but if i try to add the same framework now, I get this error. Where should I look? Hope I don't have to re-install xcode for this:(
To add a framework I use the steps described here (to remove the suspicion that I don't add it in the right manner):
How to "add existing frameworks" in Xcode 4?
Also I've checked here:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System/Library/Frameworks/GameKit.framework/
and the framework does exist. The base SDK is set to 4.3(latest), so that's not the problem either.
I'm not sure if this is going to work, but I use another method to add frameworks, which is go to your project (The one with the xcodeproj icon), then click on your target. There, you can add the frameworks you want.
If that doesn't work, then try go to /Library/Frameworks to see if your framework you want is still there. If it's there and it's still getting that error, try manually adding the framework which is the add other button when you add a framework.
It must not exist. It either got deleted or never existed to begin with, which makes me think it must have got deleted. Sorry, buddy.

iPhone project "No launchable executable present at path"

I downloaded one of the sample apps for iOS and it gives me the above error.
No launchable executable present at path /Users/..../MyProject/build/Debug-iphonesimulator/MyProject.app
What i do have is the MyProject/build/MyProject.build/Debug-iphonesimulator/GeneratedResources.build/ some files.
No build errors.
When I see in the finder the directory is indeed not even present. What could be the problem ?
Update: Yes, i did try cleaning & deleting Build directory, doesn't help
I also had this same error code for my project. I was using a number in the Target -> Product Name. Once I changed the Product Name of the target to letters only everything worked fine.
Try opening the Info.plist and removing "executable name" value if it's filled with custom string instead of string variable (the one that should look like ${FOO_BAR}, but doesn't).
I had this problem. it turned out I had the active target set incorrectly, in my case to a cocos library instead of to my own app.
After trying the things mentioned here, also make sure you click on "Clean All Targets" then quit XCode and restart XCode. This fixed it for me and many others on the web!
I had the same problem. In my case, I had an additional target for the same project (which contained test libraries). At some point xCode always tried to launch the test binary, regardless of what binary it compiled.
Removing the pbxuser and perspective files (inside project.xcodeproj) solved it for me.

Xcode falsely claims CFBundleExecutable to be (null)

I'm trying to create an ad-hoc build of an iPhone app for beta testing.
On their end, they're seeing an error like the following:
"The info.plist for application at xxx specifies a CFBundleExecutable of (null), which does not exist"
Here is an excerpt from the actual info.plist:
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
And it clearly is not null.
What am I doing wrong here?
The WORKING SOLUTION is this (and only this):
In Xcode, choose “Executables” from the project hierarchy. Click your project executable then press Command-I. Choose the General tab and set the working directory to “Build Products directory”.
Found via BrainwashInc, who credits MacHackShack. I thought this valuable information was way too important to leave floating around on random blog.
It seems like sometimes XCode may flip this setting, as I suddenly started having this issue, and the fix above repaired it. Changing it back to "project directory" reproduces the issue for me, every time.
I also had to restart XCode to get the debugger to work once this fix installed the app, that may be unrelated.
I don't think there is ONE working solution to this. I found several solutions that doesn't work for me. At the end, I did find one solution.
By deleting whatever I had in the "Producs" folder in xCode I managed to get it working. I am using xCode 3.2.1.
Note: I did the change regarding "Build Products directory” above as well, perhaps both solutions needs to be implemented, up to you to try it out.
This is, to say the least, quite anoying. As a beginner, things are complicated enough without bugs in the SDK...
Hope this will help someone out there!
Cheers
It sounds like you're looking at the info.plist in the project not the built product.
The '${EXECUTABLE_NAME}' in the project info.plist is just a place holder for a variable in the build script. You need to look at the info.plist in your built product to see what is listed there. It sounds like for some reason, the build script is not populating the field as it should.
You might actually check that the contents of the application package actually has an executable. Sounds weird I know but a few years ago I mucked about with my build setting son a project and ended up with a product without an executable. Everything else, the package, resources, string files etc was there just no actual program.
This is a know issue of SDK:
Changing an iPhone Executable's working directory from “Build Products directory” may cause the application not to install properly with the error message “The Info.plist for application at (null) specifies a CFBundleExecutable of (null), which does not exist.”
as you can see here:
http://developer.apple.com/iphone/library/releasenotes/General/RN-iPhoneSDK-3/index.html
For me, it worked to change the working directory.
I created the problem deleting by hand the build directory.