error: Unable to resolve build file: XCBCore.BuildFile - ios

error: Unable to resolve build file: XCBCore.BuildFile (missingTargetProductReference("3bf83096e50de72a94699e9afc1133ebe3512682230d04680075c283a974e273")) (in target 'MyTarget')
Xcode 10 is giving this error immediately when trying to build our project. It's not immediately clear what is causing it.
How can I resolve it?

For XCode 10 Beta: Problem occurs when I have two workspaces open that share the same project directories. Solution was
Short version
Shut down all but one workspaces
exit XCode and reopen XCode
XCode > Product > Clean Build Folder
Longer version
Shut down all but one workspace
XCode > Preferences > Locations > Derived Data > goto directory ~/Library/Developer/Xcode/DerivedData
Clear out subdirectories from DerivedData
exit XCode and reopen XCode
XCode > Product > Clean Build Folder
Thanks to #aferriss answer for the clue.

I came across this same error while using openframeworks 0.10 with xcode 10 recently. It seems like it was caused by having multiple openframeworks projects opened at a time. If you close them all one by one, and then reopen the one you'd like to work on, it should resolve the error. Hoping this is just an xcode-beta thing.
Xcode used to tell you that there as a workspace integrity problem, and you could just ignore it. But it seems like it's returned. There's some discussion about this issue here.

For me, XCode > Product > Clean Build Folder and restart Xcode then worked.

This was the culprit for my experience of the same error:
After setting the correct version of Command Line Tools (i.e., Xcode 10.2.1; see below) on my system, the error went away!

Just Restarted my Xcode and the problem went away

The key here is missingTargetProductReference, or you might get namedReferencesCannotBeResolved. Xcode can't find something.
This happened after upgrading to Swift5/Xcode10.
I found that removing linked frameworks and then re-adding them fixed the issue.

I had an embedded Xcode project that was not found (light blue). Deleting it and dropping it in again solved the issue.

In case this helps, I had a new repo and the Libraries weren't correctly linked.
I opened Xcode, cleaned, and went through, one by one, through Libraries on the menu. I clicked on it, which opened the info panel on the right, and pressed the small folder button, and found the path designated and clicked and opened, to make Xcode recognize those Libraries. Path names were often
/node_modules/react-native/Libraries/(something)/(something).xcodeproj

In my case, after trying all solutions in this question and some more (including updating Xcode 10.2 beta and even macOS), the only thing that worked was accessing the project bundle (right click > Show Package Contents) and remove everything except project.pbxproj:
project.xcworkspace
xcshareddata
xcuserdata

If you have a File Group which is backed by a physical folder and that physical folder has been deleted then you will get the same error "Unable to resolve build file: XCBCore.BuildFile".
In my case the physical folder has been removed (because I removed all "real" files from it) and in XCode group there was still one external project linked.
Solution:
- created a new group (without a folder) in XCode
- Moved external project reference there.
- rebuilt the project
Error gone.

For me there was a different solution after none of the above worked.
The problem started after using unlink for one of my packages.
Then for some reason, the Package was still there under Libraries, but it was greyed. After deleting the greyed Library, everything started working again.

My solution was that I was using the wrong Xcode version for the project I was working with. It still required 10.1 and I was attempting to run in 10.2. I instead opened it in 10.1 and the error went away while successfully compiling.

The problem is that on new xcode 10.2 there is a new BUILD Configuration, you need to change to LEGACY.
You can check how to change it here: https://medium.com/xcblog/five-things-you-must-know-about-xcode-10-new-build-system-41676cd5fd6c . CHECK THE GIF
So if you have a newer version of xcode different than the one used when the project was working probably this is what is causing the issue.

I have the same problem. Because a folder not upload to Git server, git not allow upload empty folder, then I create a folder in project folder, and it work well.
missing folder

In my case, it was a simple issue of a missing file.
Checked all secondary error messages. Error report said that my bridging-header.h file was not being found. Checked the path of the missing file from the target settings (just search for .h to get the right setting key). Fixed the new path and error went away.
The cause:
I had reorganized my folders after a system crash and added a second level to my project location.

I've faced the problem in Xcode 10.1.2. Xcode restarting and the clean project solve it in my case.

Seems like there are a number of reasons for which one runs into the same error. For my case, it was not having the Submodule checked out locally. After I made sure all my Submodules were downloaded, the error went away.

I had correct Command Line Tools and cleaning did nothing for me.
While resolving a merge conflict, A Group named "Recovered References" had appeared in my project navigator. Probably due to a mistake I made during merging. The Group was empty and deleting it fixed my problem.

Related

Xcode 8.0 Command /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1

When I compile my code on Xcode Version 8.0 beta 4 (8S188o) I get this single error bringing the compilation to failure:
Command
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc
failed with exit code 1
I tried to clean the project and wipe the derived folder but that did not change things.
What is it and how may I know more about it?
When I try to compile on the terminal the error being reported is:
Invalid bitcast\n %.asUnsubstituted = bitcast %swift.error* %13 to
i2, !dbg !438\nLLVM ERROR: Broken function found, compilation
aborted!\n
Happened to me, when I had two classes with the same name in my project. After deleting the redundant one, error disappeared.
If you look above the error, Xcode will tell you which ViewController is added/declared twice, navigate to it and remove the reference. Build and you're good to go.
I am going to tell you my silly mistake, the error is showing the issue and It took 3 hours to me to understand. look into below error
look into above 2 lines of error, the problem is shown, Obviously, In my case Xcode is complaining that Location.swift and Customer.swift file is missing, look into my project hierarchy, the same issue can understand.
It's my advice to everyone that first understand the error and then look into issues. I removed my desktop files, which were referenced in the project, and therefore compile error occurred.
Clean your project that fixed my project
Product/clean
I got this error for core data models that i've created manually.And it got resolved by changing particular entity's 'Codegen' attribute to 'Manual/None' under Data Model Inspector.
If you change any file folder location or change any Objective-C Bridging file path. Then it's happened some time.
Update your Bridging path.
Clean your project alt + Shift + Command + K
Quit Xcode completely Command + Q
Open project again and wait for Xcode to index files.
I got this error when I was trying to run an xcode project. A swift file wasn't being found and complied correctly, even though clearly in the xcode project file you can see the swift file and when you click on it in finder the file comes up as a separate xcode swift file. I solved this by:
Deleting the problematic swift file
Creating a new swift file with the same name
Xcode prompts that the file is already created, press replace
copy/replace the code/etc. in the file
Clean the project (for good measure)
Run the project
The problem went away by itself for mysterious reasons. Instead of the whimsical linking error I got a new bunch of errors due to Swift 3 fling which the app compiles and run fine.
The solution that worked for me is I had to delete the .xcdatamodeld file in my project and create a new one. This solved it.
I got this error and resolved by changing Xcode command line tools,
Goto Xcode -> Preferences -> Choose Locations tab
Choose required Command Line Tools from drop down, run the project error has been fixed.
In my case the error triggered when Xcode could not find a file/folder from the external Framework and dependency. In such a case just pod update / pod install do the job.
Try removing inactive file(deleted file) from Build phases...
Based on #Mohammed Rizwan N answer
If error not gone, do the clean project and close Xcode. Then click right button on .xcodeproj/.xcworkspace file and choose appropriate Xcode version.
In my case, I tried to run a project in Xcode9/Swift4, while the project was written on Xcode8/Swift3
1.Go to build settings and check the path of the info.plist file and bridging header file.
2.If not sure they are correct , from the left side drag and drop the files into respective fields .This creates the path automatically .
Clean the project and build again .
I created 3 new groups and put my MainVC under one of those groups. After I deleted one of the new groups I created, the error went away after I cleaned my project.
Please update your entire log which suggests the error, mine is telling me I have duplicated classes in file
Try closing Xcode, cleaning the project and building again.
At first, cleaning wasn't enough. I had to actually close it and try again.
I faced this issue when I resolved git conflict for the project file, which was for adding and removing some files.
What I found out is Xcode creates the folder named folder named "Recovered References", just search this from bottom left search option from Xcode and delete it. After you delete it you will only get an error for missing files. Resolve that by adding files again by right-clicking and selecting add files option. Once you are done with it project compiles with no error.
Happened to me when I found two swift files with the same name within the project, even if the classes have different names.
In my case error came when I moved my bridging-Header.h file from one folder to another. and when I checked in Build Settings -> Objective-C Bridging Header it was showing old path. Then I moved that file back to previous folder.
My problem was that my machine was running out of available space. Restarting it cleaned up ~8GB of temporary files, but I guess you can also delete something instead.
This is mainly because xcode is not getting the exact path of any file or duplication of file name under linking area.
In my case I have added bridge header file under Resources file and added the path in
BuildSettings->Objective-C bridge header-> bridgehearfilename.h
You should specify the exact path of that file in this section.
eg: BuildSettings->Objective-C bridge header-> Projectfolder/Resources/bridgehearfilename.h
Correct your file paths in the build settings then Clean and build the project.
For me it was ,
Product > alt + Clean Build Folder
OR
alt + Shift + Command + K
Do these 3 steps:
Clean Project: Shift+Command+K
Make sure low disk space shouldn't be on your mac
Focus on the upper lines of this error...Try reading them again...Paste those files that are missing or having some light icon in xcode project navigator and delete those files with light icon.
Hope you will fix the error.
I tried to run a project in Xcode12/Swift4, while the project was written on Xcode8/Swift3
so I install Xcode version 11.7 and run this work for me.

ERROR "swiftc failed with exit code 1" when converting to latest syntax

I was trying to convert syntax of old Swift project to new one as per few suggestion on Stack Overflow I tried converting it through Edit > Convert > To latest Syntax that did not work properly instead I started getting new errors shown as below
Command/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc
failed with exit code 1
And
Command /usr/bin/ditto failed with exit code 1
I tried Xcode 6.0.1 Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1, but it's a different situation.
Have you tried to do clean with Clean build folder?
The combination keys is:
ALT + SHIFT + COMMAND + K
Try delete Derived Data folder and Build it.
Go to Xcode -> Preferences -> Locations for get the derived data path
Clean Xcode. (cmd+shift+k)
Quit Xcode completely.
Open project again.
Wait for Xcode to indexing files.
Now run your project.
Just had the same issue. For me it was because I had renamed some of the project directories. I had a ton of red files in my project navigator. To solve, follow these steps:
click on the directory in project navigator where many files show as red
Under "Identity and Type" in the File Inspector (on the right side), click Containing directory
Select the new directories
Rebuild - command shift K, command B
As far as I know there can be multiple reasons why a compiler fails. Although cmd+alt+shift+k will help most of the time. If this fails, then click on the error message and try to debug it.
For example in the image below, if you read the message, we get to know that, there has been a name duplication. Fixing the name duplication will fix the issue.
Just remove inactive file(deleted file) from Build phases
then
Clean Xcode. (cmd+shift+k)
delete Derived Data folder and Build it.
Go to Xcode -> Preferences -> Locations for get the derived data path or cmd+Alt+shift+k
OR
Just remove inactive file(deleted file) from Build phases
Cleaning the project wasn't working for me, this is because I didn't pay attention to the message right above (Xcode highlights only the final command).
In my case it was
<unknown>:0: error: filename "FileDuplicated.swift" used twice: '/../filepath/FileDuplicated.swift' and '/../filepath/FileDuplicated.swift'
<unknown>:0: note: filenames are used to distinguish private declarations with the same name
Command /../bin/swiftc failed with exit code 1
I had to change the name of one of the two files and it was solved.
Hope this can help someone, cheers
In my case it was due to the few swift files which has been showed grayed out in the Build Phases section. After removing those files it was successful.
In my case I deleted few files from project and when try to commit the code, the files was showing there . To solve this issue.
1. Open terminal
2. Type git clean -n // it will show you list of files which are deleted from project but still are saved somewhere
3. Type git clean -f // All unwanted files will be removed
In my case, it was "Other swift flags". I had declared a flag there but not -D, so this was not getting recognized and resulted in the same error
In my case swift development snapshot was selected instead of xcode 9.2. here are the steps and image.
xcode on screen and click on xcode top menu bar.
Than go to toolchains option and check on xcode 9.2. thats it.
Note: If no toolchain found in your xcode than download from Here and install it. (after installation restart xcode).
Happy Coding!!!
Ok, my turn now. In my case I had an existing project. I copied in a few files from another project. One of the files I brought in was SettingsViewController.swift and there was already a file by the same name I was not aware of. The files were in different directories of the project so no duplicate message was shown. The compile/link messages offered no clue to this. I figured out the issue by adding one file at a time to the project (there were 12 total) and the building each time until I found the offending file. I renamed the new file and project builds now.
In my case it was a compiler flag change that didn't work well. It took a few compiles before it actually started failing though! Xcode caches what it compiles.
I just had this issue. It's due to path references. Have you been moving files around and/or copying folders? Check if .xcodeproj is inside or outside of the main project folder. Also, make sure that the project's file and directory structure are intact.
/yourFolderProjectName/ <-- contains your .xcodeproj file AND folder with Xcode project name
/yourProjectFolder <-- here are .swift, info.plist, assets folder, etc.
/yourProjectXcodeFile.xcodeproj
Another thing to check:
In my case I had deleted a row in the "Other Swift Flags" section in the Build Settings screen under the Release setting.
That row had been a value for a compiler flag key/value pair. So the key was there but not the value.
Once I deleted the key as well, then the build worked again.
This issue is happening because of pods
So Follow the below steps to resolve this issue
Remove all the pods and re-install again.
Remove all the pods using below this command (rm -rf "pwd/Pods/")
Quit the Xcode and open it again and build the app with device (generic iOS device).
Now check this issue will be resolved.
I had this error when Xcode found two .swift files with same name. Rename one of them and build again.
Wait for completing the indexing and run the project again. You must get an error then check it which may be Objective-c bridging file not found error. This error comes if you are using any Objective-C library or code directly in the project and your project unable to find the bridging file in the system. This issue basically caused by, if project is unable to find any file in the system which is using in the project (path issue).
I faced this issue while using the Swift auto-generated header file in my project (named as 'TargetName'-swift.h) to use Swift classes in Objective-C.
There was a typo in the file where I had imported this swift header. Correcting the typo helped me resolve the issue.
Clean the build in Xcode cmd+shift+k.
Update the pods.
look the where errors showing.
Add the missing files in Xcode.
After Run the Code. Working fine.
Try below if none of the above working for you.
My project location was desktop/my_project_folder
I tried all above then i made simple change.
I create one more folder on desktop past my project
.
then...
Cause of problem in my case:
This problem occurred when i change my project name in xcode & project folder name from desktop.
I was working on a private pod and was also pointing to it locally. I had made some file name changes.
Hence I was getting this error.
All I had to do was to run pod install so it would reflect the file name changes. After that it compiled.
In my case I copied a core data entity and only renamed the entity but not the class.
So go to your xcdatamodel and select the enitity > rename also the class name
Had the same issue but with duplicate file references.
Deleting Derived Data and cleaning had no success. But I got it fixed by doing this:
Navigate to your project.pbxproj -> open with your text editor of choice(I use atom).
Command+F and find the duplicate file sources and then delete them.
Build/Run and should be fixed.
For me, it was the keychainAccess problem as described in this answer (my error messages were completely opaque, all I had to go by was 'failed with exit code 1')

fatal error: malformed or corrupted AST file - Xcode

I get this error when building my app in the latest version of Xcode:
fatal error: malformed or corrupted AST file: 'Unable to load module
"/Users/me/Library/Developer/Xcode/DerivedData/ModuleCache/XYZYIE6ZV0OP/Darwin.pcm":
file not found' note: after modifying system headers, please delete
the module cache at
'/Users/me/Library/Developer/Xcode/DerivedData/ModuleCache/XYZYIE6ZV0OP'
1 error generated.
When I navigate to:
/Users/me/Library/Developer/Xcode/DerivedData/ModuleCache
I can see that the directory 'XYZYIE6ZV0OP' doesn't exist.
Does anybody know how I can resolve this? I cannot delete anything at the directory as suggested in the 2nd part of the error message as that directory doesn't exist!
Had same problem. Clearing derived data folder solved the issue for me. In Xcode, go to Window->Organizer->Projects, select your project, and press the "Delete..." button next to "Derived data".
If this doesn't work, you can try to do a Product->Clean (Cmd+Shift+k).
Press Command + shift + k or clean the project and then run project...
In Xcode select Product-->Clean problem will be solved
By default Library folder is hidden in Mac. Best way to navigate to that folder is :
Open Finder
Select Go from menu -> Select "Go to folder"
Type : /Users/"your user name"/Library/Developer/xcode
This will open direct xcode folder inside hidden library folder.
Select "DerivedData" folder
Command + A, select all and delete them.
Open Simulator and "Reset Content and Settings".
Now run XCode again, all will fix.
I had the same issue, solved it by cleaning the project.
Product-> Clean
or press
command+shift+K
In my case, I accidentally modified NSURLConnection.h. Xcode complained about cache at path
/var/folders/p6/fk2rmf017sn2d_gds6dtqr6hrst8b2/C/com.apple.DeveloperTools/5.0.2-5A3005/Xcode/5.0.2-5A3005/Xcode/ModuleCache/XWWWZ5ED888F
I finally found the steps to fix it:
Quit Xcode
Delete the upper "5.0.2-5A3005" at
/var/folders/p6/fk2rmf017sn2d_gds6dtqr6hrst8b2/C/com.apple.DeveloperTools/5.0.2-5A3005
When Xcode restarted, it regenerated that folder and everything in it.
I had the same issue ever since installing the latest SDK.
My solution was to delete the derived data and clean the project.
I got same error on executing xcodebuild command of Xcode6-beta5.app coexisting with Xcode.app (Xcode 5).
In this case I added -derivedDataPath to separate ModuleCache from the one for default Xcode.app.
xcodebuild -derivedDataPath ./build/Xcode6-beta5/DerivedData ....
This works for me.
I tried deleting derived data and Clean project several times and it doesn't work. The file in my warning is an old file I already deleted from Project Navigator and all the Build Settings. But it keeps showing up and gives me this error. The error only occurs on Simulator, but not on device. Which is really really weird. :/
For some reason, I switched branch to some other branch and switch back and it works again. If anyone even know how that could work please tell me :D
Simply clean remove the Derived Data and build folders. The problem shall be resolved.
In my case the SSD was broken.
You can verify the disk with apples Disk Utility
In my case I had a spaces in my plist file name.
I removed it, and changed Info.plist File key in target Build Settings
Refreash Safari browser, scroll down the page and you will see you "Click + button for add build ..." then add actual build, click Save and "Waiting for Review"
Cleaning the project and deleting the drive data didn't fix it for me. But what finally fixed it was changing the model of simulator that I used.
So first do a clean, then if you were running it on iPhone 5 simulator, run it on iPhone 5s simulator to fix the issue. basically, run it on any other simulator other than the one you were running.
(Credit to Hlung for his answer, I hope this one is a bit more clear)
If you have your project scheme set to "Wait for executable to be launched" this error might happen.
In that case, just changed your scheme from Product > Scheme > Edit Scheme...
In my case, I tried to archive a app in one project within a xcodeworkspace
close Xcode, the open the single target project, and clean an
Then, I do archive, it makes an iOS App archive.
I hope I can help someone.
Got this error while trying to build a third-party app for the first time. Adding foundation as a library fixed the issue for me.
I did Clean cached, Delete derived data, Manually delete the Module cache folders which found from the error logs, Restart xcode, Restart machine.
But non of them helped me.
But this steps help me to resolve the issues
Comment out all the #import line in [Name]-Prefix.pch files.
Build, as expected its pointing me to different errors.
Revert back the changes I have done in [Name]-Prefix.pch and Build, compilation succeeded.
This solution help me to resolve the issue.
if you can't find your "Derived data"
File -> Workspace settings
Click on the arrow icon next to your path
Remove "Derived data" folder
tried to re-install XCode which didnt resolve the issue, also created a new local user account & get the same error so in the end I gave up & restored to a time machine backup from a few days before... seems to be ok again... for now!

How to solve the apple LLVM 5.0 error in xcode 5?

I was running my application without any problems on both the simulator and device. All of a sudden i get this error:
fatal error: file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UICollectionView.h' has been modified since the precompiled header '/Users/rashidasgari/Library/Developer/Xcode/DerivedData/ModuleCache/SWBH8ZAWBXAH/UIKit.pcm' was built
note: after modifying system headers, please delete the module cache at '/Users/rashidasgari/Library/Developer/Xcode/DerivedData/ModuleCache/SWBH8ZAWBXAH'
I tried any solution i could find and still no luck. Note that i tried running the application on another MacBook and everything works fine without any errors.
Cleaning the project is the first port of call (menu under Product).
If that doesn't help, delete the derived data. That can be done via the Locations section of the preferences or by navigating to the directory in Finder and deleting it (there is a little -> button in preferences to get there, or use Go To Folder... option in the Finder.
Ok after trying almost every solution on web, i decided to reinstall xcode and it finally worked.
I solved this problem by changing DerivedData folder name..see how i did
Xcode->preferences->Then you will be redirected to preferences screen
Then click on locations tab under menu selection->then you will have options like Derived data,snap shots ,archives
under Derived data you can see some thing like /Users/SENABI/Library/Developer/Xcode/DerivedData-> then click on that arrow button that's it there you can see DerivedData folder click on that and rename it. your error will be removed.
This is my experience and it worked for me hope it will be helpful to someone.
Error occurs when system header files are modified.
Solution :
If you have the backup of XCode then reinstall the XCode (Better solution).
Delete the DerivedData folder and then build the project
Use CMD+Shift+K to clean the build and then relaunch. This should solve the issue.
you don't have to delete anything.
you messed up a git pull somewhere probably. just quit Xcode and the simulator, reset any changes (or stash them) try another git pull, start Xcode again, clean your project and run it again.

Xcode Cannot Run on the Selected Destination

I was running my app this morning and now all of a sudden I am getting the following error when I try to run on the iPhone 5.1 simulator.
Cannot run on the selected destination
The destination does not support the architecture for which the selected software is built. Switch to a destination that supports that architecture in order to run the selected software.
I deleted the schemes but still no solution.
I am using Mountain Lion. I am using xCode 4.4 (Recently upgraded to Mountain Lion and xCode 4.4)
UPDATE 1: Here is the view of my build settings:
UPDATE: Here is the actual error which prevents from it running.
You might follow the steps:
Quit Xcode and iPhone simulator
Unplug your devices
Goto /Users/your_usr_name/Library/Developer/Xcode/DerivedData/
Delete all data under this folder
Start Xcode again and run your project
Hope this will solve your problem.
I had this issue after updating from Facebook SDK 3.1 to Facebook SDK 3.1.1. My fault, I guess.
Inside "resources" folder, now there is a totally useless but dangerous info.plist that, if imported, may break your project file. Don't know why they included it but I believe few of us made the same mistake recently.
I found this problem with the version of Xcode 4.4. And finally I solved it this way:
Find the "Info.plist" in your project, then unselect the target membership plus on the right side view of window, it works for me.
You might also want to check if the project uses a supported compiler in the project settings
Its just duplicated Info.plist file
just use 1 Info.plist file in files then restart xcode
its fixed for me
I have just encountered this error in Xcode 4.5.1, and the error went away after I take all non-alpha characters out of the Product Name build setting.
I believe this may be a current unlisted bug with Xcode 4.4+. I have/had the very same issue with my project. I deleted all versions of Xcode and restarted with 4.4, opened my project and had the error again.
I then started a new project with a template with a different name. Did not have the issue.
I then renamed my old project, started a new empty project with the same name and built/ran and got the error again. This new project was nothing more than a view controller that didn't do anything. I should have gotten a blank screen but got the same error you did.
Frustrated I shut down for the day and re-ran the old project and it worked. I had not changed anything. Currently I have the error again and neither rebooting or restarting Xcode fixes it.
So in summary, a project can have absolutely no changes made, sometimes it builds and runs fine, sometimes you get this error. For the record I did not get this error running Xcode 4.3.
My issue did not show up until I upgraded to Mountain Lion and Xcode 4.4 which happened to be on the same day. Now I can not get back to a 100 percent workable configuration.
Committing my files to SVN and checking out the project in a new directory fixed this for me.
Look at both the project and target build settings, at that Architectures, and see if anything has changed. When first going from Xcode 3 to 4, it use to wreck havoc in a hidden way, giving the same error, and in the end you had to add i386 to the "Valid Architectures" line. I just looked at my big project started in Xcode 4.1, and it shows nothing about i386 etc, but I have other newer projects where I get this grayed out thing in that line $(ARCHS_STANDARD_32_BIT).
EDIT: I took a relook at this with a guru friend. Neither of us can find a linkage to i386 in our projects - Xcode is using some magic. That said, I did get a hit to i386 in a binary plist within the project, which leads me to another suggestion.
In your build settings, insure that ALL "Architectures" are $(ARCHS_STANDARD_32_BIT).
If that does not work, we suggest that you look at the compile and ld lines of your build when you select iPhone 5.1 Simulator in the scheme menu - to see if in fact its i386,
Another idea - move all your schemes and user settings to a save folder somewhere (with the project closed), then reopen and recreate a scheme. Now try again. There is no reference to i386 in any of my project.pbxproj files, so our suspicion is that this is somehow related to the scheme setting for the target device.
Good luck!
I've solved changing in both the project and target build settings the key "Build variants" from "armv7" to "normal"
in addition to deleting all the files in this directory
Users/your_usr_name/Library/Developer/Xcode/DerivedData/
i restarted my mac and it worked fine (restarting xcode and the simulator didn't cut it for me)
I was running into this same problem. In my case, it appeared to be that I had changed the Bundle Name for my multi-target project instead of the Product Name. Once I corrected that by editing the Project Name correctly and then setting the Bundle Name back to ${PRODUCT_NAME} it would run in the simulator again.
This may not be the answer for everyone, but it does appear that product naming errors (special characters, spaces, etc.) are a contributor for many, and that's what drove me to review the renaming that I had one.
I was facing the same issue with my project. Here's a brief explanation of the situation and my resolution. This may or may not work in your case.
I work at a place which has multiple iOS projects going. I recently had my system upgrade to Mac OSX 10.8 and Xcode 4.4.1. I was working on a project that was originally built on Xcode 4.1 for iOS 4. Since Xcode had iOS 4 simulators until 4.3, the project built and ran fine on all simulators. In Xcode 4.4.1 however, I did not find iOS 4 simulators and there is no easy way to install them either, which is why I was getting the "Cannot run on selected destination" error. Here's how I got my project to run.
Check under Build Settings > Architectures and set Architectures to Standard (armv7) or ${ARCHS_STANDARD_32_BIT} for all your profiles.
Set Base SDK to Latest iOS(<ios version #>) 5.1 in my case.
Set Build Active Architecture Only to NO for all profiles.
Set Valid Architectures to armv6 armv7 for all profiles. You may have to add either depending on what is already available.
Set iOS Deployment Target to iOS 5.1 (in my case) .
Make sure you have the same target under Deployment Target under the Summary tab of your project.
Clean and Run and cross fingers !!
In my case, the problem occurs after removing whole Resources folder, copying Resources folder from other or old project over current one then adding back that folder.
I solve the problem with the help from Analyse tool: after analysing, it warms me about Info.plist inside "Copy Bundle Resources".
Simply go to Copy Bundle Resource (at Build Phrase tab) delete Info.plist, then restart Xcode, clean and build. My project is back to normal.
Hope that help someones :)
I think a lot of these solutions force a full rebuild, which is what solved this for me.
I did Product => Clean, and the problem went away.
For me this worked:- Check all you product references are consistent in the settings and plists. Also check the product name does not contain any SPACE or other "illegal" characters.
try to rename your project. I solved by this way.
Judging from the responses this type of error has many potential sources, so here is my own (admittedly careless) version of the mistake (and simple solution):
XCode project Build Settings can be set at two levels: Project level, and Target level. For those less familiar, target level is where you have your executable app, and often other items like a dynamic library build.
In Linking section of Build Settings there is a option for Mach-O Type, where you can set Executable, Dynamic Library, Static Library, etc..
I was having trouble preparing a dynamic library, was scanning over the build settings for the project and saw Mach-O was blank. So I set to dynamic library. I then went on and reviewed a few more things and forgot I'd made this change. But I didn't realize I was at the overall Project Level, not the Target level for the actual dynamic library. This changed all target Mach-O settings to dynamic library.
And of course the executable target didn't like being treated as a dynamic library, and I got the OP's error message.
Setting the executable back to executable Mach-O at its target-level build settings fixed everything. Annoyingly the project-level setting still said dynamic library, but with correct target-level settings all worked fine.
Silly I know, but since a couple of the more drastic solutions listed above would have indirectly solved for this error I thought I'd share in case someone else had made the same mistake!
The way I solved this error was by a adding dummy function to my project. My issue was my app had no code of its own, only linked-in code.
I have an unusual situation with two projects: one "App" parent and one "Engine" child. All the compilable code is in the child and the parent simply links with the child, copying a ton of App-specific resources into the project.
Apparently this saddens Xcode, resulting in the above error.
My solution is adding this C function / file to the App project:
int workaround_for_xcode_reporting_cannot_run_on_selected_destination(){return 0;}
I restore the data from the time machine. Notice this is the exact same data that has been stored just 1 hour ago. The problem started yesterday. So it should be the EXACT same data.\
Yet it works.
I tried everything metioned here. Nothing worked. It seems that I somehow imported the Info.plist twice. To fix it I selected the project and pressed the "Validate Settings" button. Afterwards it works for me.
After a half day of experimenting, I think this means that the debugger can't find your executable to launch. I think this is an important distinction from the prior answers because its an underlying cause, that can have a lot of symptoms. In my case it couldn't reconcile the apps Info.plist for a custom build where we were copying the plist for the build. I changed the build setting to the Alt-Info.plist for AltDebug and that fixed it. Also meant no more copying.
Your underlying cause might be different, so the key takeaway is think about why Xcode might not be able to find your built app.
You'll be happy to know this problem has a very simple solution. Select Info.plist in your project navigator tree and make sure it is not assigned to a target. I have confirmed this is the correct solution. If building for iOS 6 or earlier you may also need to add armv6 to supported architectures
I had this issue after upgrading to Mountain Lion and XCode 4.4.1 for an OSX project.
To resolve it, I had to upgrade my deployment target to 10.5 or higher; it was set to 10.4 and up.
You have to find in the "Activity Monitor" the Xcode process and kill it! I just did it to solve a similar problem!
I've got this problem after accidentally removing the Resources folder, when I added it again to the project, Bam !
I'm also running Mountain Lion and XCode 4.4 !
trying to find out what's causing this, but it seems to be reproduced when you delete then add the info.plist file ! can someone confirm that ?
I had the same problem after two things happened:
I upgraded to Facebook SDK 3.1
I updated my OSX (with a minor version update)
The only fix worked from me was adding armv7s (mind the "s" in the end!!!)
Like was suggested here:
https://stackoverflow.com/a/12540654/531527
Yet another variant solution: after trying just about everything in the list above, I fixed this by addressing a warning that the TestFlightSDK1 path could not be found. To do so, I deleted the relevant path from Header Search Paths (Build Settings>Search Paths) and removed the TestFlightSDK, and now things run just fine.
I had this from beginning and it looks like it is a problem that the emulator can not handle virtual smartcards. Unfortunately I ended up just using my Android phone connected via USB.
Remove Info.plist from the Copy Bundle Resource build phase.That worked for me!

Resources