Xcode Cannot Run on the Selected Destination - ios

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!

Related

Xcode - Archive product goes to Other Items instead of iOS Apps

I am using XCode 11.2.1 and out of nowhere the archives for deployment appear in the Other Items category, instead of iOS Apps (in Organizer). I am using my custom static framework and what I found that this may be the issue, but for a while, like a month or so after I created and used my framework, I had no problems with deploy (I am also using CocoaPods, but that was ok).
I have tried a lot of things like here:
Xcode 10 Archives to 'Other Items' instead of 'MacOS Apps'
and it worked for a few times, but now, with multiple cleanings, deleting derived data, etc, nothing works.
Here there is a reference to header files (but I have never changed anything about them when it worked): https://developer.apple.com/library/archive/technotes/tn2215/_index.html#//apple_ref/doc/uid/DTS40011221-CH1-PROJ
The problem is that the help link about Copy files is not working and also (I cannot find "Copy files" section in Build phases - maybe it was renamed), the Xcode version is different (I found other posts on StackOverflow) so I cannot manage to make them work (I am pretty new to Xcode and C++ / Obj C / Swift and it is difficult to manage those options if I cannot really understand the references (or with missing help/explanations, which I don't know where to look for)
I used this to create and use my framework: https://www.raywenderlich.com/5109-creating-a-framework-for-ios (and different other links but very similar to this one)
Can someone please provide some help regarding the steps needed to make your app deployable to AppStore while using my custom framework? I can provide other information and screenshots if needed. Thank you.
EDIT:
Is there a way to check what is different between the creation of the last archive that worked and the new one that I cannot deploy?
After archiving my app I also exported it and explored it in Finder (as instructed here: stackoverflow.com/a/15120289/1215791) So there is no libraries folder. It seems that the problem is not related to forgetting set Skip Install to YES for something.
Check the contents of the .xcarchive, this happens when there's more than one item in Products/Applications. It should contain only your application.
After finding the extra items there, you can then know for which target you should set "Skip Install" to Yes.
This just started happening with Xcode 13.3.
Turns out that I was adding the DocC to the Products/Applications directory. I turned off the flag for compiling documentation ("Build Documentation during 'Build'"), and it started working again.

Xcode 10.1 doesn't show 'distribute app' option when archiving, can't archive

I suddenly got this weird issue with Xcode 10.1.
When I archive app store target for my app I cant see "distribute app" option, instead it now says "Distribute Content" and neither I can export ipa nor upload to app store directly.
My archive comes under "Other items" in Organizer instead of iOS apps.
It seems to work fine with development target though.
Here is the screen shot.
Anyone with any knowledge about it please help.
Thanks
Please make changes as follows
Change Skip install to NO
Make sure only the Application has this set to NO. Embedded Targets like Frameworks need to have Skip Install = YES
Faced the same issue few days ago. This usually occurs when you have multiple schemes in a project.
Go to edit scheme (Next to stop button)
Select the target of which you want to archive.
In build option, remove other targets or you may unselect archive checkbox.
Re-archive
I ran into this annoying error today - I thought it was the new version of Xcode - but no. I had multiple targets for my project (staging/production), and also a nested framework project.
To solve this I opened the staging scheme and made sure only the checkboxes are checked for that target: (the top row was selected before)
I have run into this situation and solved it.
The solution set SkipInstall=No does not work for me.
I find the reason for my situation is that I imported a framework by adding it into Link Binary With Libraries section.
So I changed a way to import the framework.
Remove the framework at Link Binary With Libraries section.
Add the framework directory to the framework search paths.
For more information ,see my blog at JianShu:
https://www.jianshu.com/p/c65599da18c0
i got the same issue and nothing works from above answers. so i debugged my code and i found out that there was a folder that was missing and instead of showing any error i was getting "distribute content" instead of "distribute app". So if anyone have the same issue please check for the red folders or swift files in their xcode.
Unticking the 'Find Implicit Dependencies' tick box solved it for me. Hope this helps.
I had the same problem in different projects in the last few days.
In one of the projects, a solution had to delete the .xcproject subproject file.
In another project, the solution was to uninstall .xcworkspace (I use cocoapods) and run pod install.
Thanks for the old answers, I have solved the problem by keeping "Skip install" of frameworks to false.
My XCode is with version 13.2.1. One thing special is that runner and framework in my project are in different schemes. Hope the picture will help newcomers.
I got the same issue, I tried skip install setting it with "No" didn't work for me.
I removed the script added for swiftlint in build phases then it works fine.

error: Unable to resolve build file: XCBCore.BuildFile

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.

Xcode 6 ignoring breakpoints - Swift

Xcode 6 is completely ignoring my breakpoints. I saw a post here from 2008, but the answers are outdated, and don't seem to work.
EDIT:
This is happening only with projects that I start. All my downloaded open source projects work perfectly fine, as well as projects I started a few months ago.
UPDATE:
This is what I get when I create a brand new project and set a breakpoint in viewDidLoad
After trying many different things, I ran
defaults delete com.apple.dt.Xcode
This reset my Xcode settings. Now when I create a new project, breakpoints work fine.
I realized that the problem happened when I added Cocoapods to the project. B/c right after I ran pod install, breakpoints stopped working. I'm not sure why.
Hope this helps anyone with the same problem
I had a similar issue when I added a target to my project. Breakpoints placed in that target were ignored.
The solution was to set "Debug Information Format" in the new target's build settings to "DWARF with dysm"
In XCode 7.1 it defaulted to DWARF
There can be various culprits for this, a common one being setting the build scheme to Release instead of Debug.
For me it was the Debug Optimization Level set to -O0 in my target's build settings. Changing it to "Fast [-O, O1]" makes Xcode breakpoint-respectful again.
There is an interesting post about it here:
http://blog.credland.net/2014/03/xcode-debugger-why-do-you-stop-working.html
Close Xcode and remove the derived data and then reopen Xcode it will work

“The application does not have a valid signature” shows EVERY second time in XCode 5

I created new target for my app and every second time I compile it and try to run on the device, I get:
“The application does not have a valid signature”
...and app does not run.
I checked all similar posts in stackoverflow but none of the solutions helped me (cleaning project, etc...)
Under General -> Linked Frameworks and Libraries
Removing all the frameworks and relinking them was what worked for me.
I found people saying two different things that are supposed to solve this problem:
Delete all broken provisioning profiles.
Ensure there are no spaces in the name of the folder that you are building from (your Xcode project folder) -- this was what fixed it for me!
Just to add another possible cause:
In my case I had integrated SpeechKit (2.1.5) as a an embedded framework in an iOS Swift project and this somehow caused the error.
When I used Cocoa Pods the error didn't occur anymore.
Clean, deleted derived data, rebuild worked for me.

Resources