A build only device cannot be used to run this target

IosXcode

Ios Problem Overview


I get this error when I trying to test an app.

A build only device cannot be used to run this target.

No supported iOS devices are available. Connect a device to run your application or choose a simulated device as the destination.

Ios Solutions


Solution 1 - Ios

add -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.3' to your xcodebuild

Solution 2 - Ios

Maybe the Scheme has switched to a Generic device. Try to choose again the connected device from the Scheme menu:

Menu image

Solution 3 - Ios

Below is my way

Select project -> General -> Deployment Info -> Deployment Target -> choose a lower version enter image description here

Solution 4 - Ios

You need to get a list of valid destinations. To do this, specify an erroneous key-value pair and xcodebuild will spit out the combinations that work:

List Destinations Command

xcodebuild test -destination 'platform=iOS Simulator' -workspace Register.xcworkspace -scheme ThatTestTarget

Output Example

Available destinations for the "ThatTestTarget" scheme:
	{ platform:iOS Simulator, id:145A9B7E-B336-4819-8059-2FFEC408E05E, OS:11.1, name:iPad (5th generation) }
	{ platform:iOS Simulator, id:69ABAF6F-ADA3-4E38-AC97-D71001447663, OS:9.3, name:iPad 2 }
	{ platform:iOS Simulator, id:550E2F18-406D-4586-84BB-E48F1D704F27, OS:10.3.1, name:iPad Air }
	{ platform:iOS Simulator, id:94734F1C-775F-40FA-9015-8196C08805EF, OS:11.1, name:iPad Air }
	{ platform:iOS Simulator, id:1DB953DD-CD97-4EC7-8006-BCF01DF3E63F, OS:11.1, name:iPad Air 2 }
	{ platform:iOS Simulator, id:DE3072DA-2E31-423D-9D77-220626F8B90A, OS:11.1, name:iPad Pro (9.7-inch) }
	{ platform:iOS Simulator, id:3B5D18DB-13B5-4F28-B654-7D2ECDD1F6F0, OS:11.1, name:iPad Pro (10.5-inch) }
	{ platform:iOS Simulator, id:A4225E3A-512C-4F42-ADD9-1E7E448C4D27, OS:11.1, name:iPad Pro (12.9-inch) }
	{ platform:iOS Simulator, id:684FF1BA-8784-4B7C-B4E5-5231772F0FAC, OS:11.1, name:iPad Pro (12.9-inch) (2nd generation) }

Change Colons for Equals Signs, Remove Spaces, Ignore the ID

So if you want to use this destination:

platform:iOS Simulator, id:684FF1BA-8784-4B7C-B4E5-5231772F0FAC, OS:11.1, name:iPad Pro (12.9-inch) (2nd generation)

Change the colons for commas, remove the spaces, remove the ID, so you get this string:

platform=iOS Simulator,OS=11.1,name=iPad Pro (12.9-inch) (2nd generation)

Then the entire command would be:

xcodebuild test -destination 'platform=iOS Simulator,OS=11.1,name=iPad Pro (12.9-inch) (2nd generation)' -workspace Register.xcworkspace -scheme ThatTestTarget

Solution 5 - Ios

i meet a problem that only "Generic iOS Device" can be choosed. and when i run ,it says "A build only device cannot be used to run this target.No supported iOS devices are available. Connect a device to run your application or choose a simulated device as the destination "

and my solution for the problem is selecting Build Settings ---> Deployment ----->IOS Deployment Target---->choose a lower version like 8.0,

and i found the simulator come out and can be chosen.

Solution 6 - Ios

You are building for Xcode's "Build Only Device", which is compiling the app. for the ARM processor (whereas compiling for the simulator targets the Intel CPU on your Mac.)

Plug in a device and select it from the active scheme popup, or, select one of the simulators and you should be good to go.

Solution 7 - Ios

With XCode 8.3.2 I had this error message after I tried to run the app on a locked device. I unlocked and reattached as requested but the "A build only device cannot be used to run this target." message appeared.

I simply changed the target to a simulator and changed it back - it resolved my issue.

Solution 8 - Ios

For what it's worth, if you get the error A build only device cannot be used to run this target, and see in the Issue navigator this text:

> ProjectName
> Target Integrity:
> iOS Deployment Target 'XX.X' is
> newer than SDK 'iOS YY.Y' in
> target ProjectName

then the issue is that the project requires an iOS SDK that is newer than what your version of Xcode has available. You'll find this issue in, say, projects taking advantage of new/beta iOS SDK functionalities such as ARKit.

The solution is to download the newest beta version of Xcode, which should have support for the non-public released iOS SDK that the application requires. If you have the latest Xcode, try finding the target iOS in Preferences -> Components -> Simulators.

Solution 9 - Ios

If you are using cordova/Ionic Go to Products -> Destination-> Choose the target and re run

Solution 10 - Ios

I encountered the same error message. Here's what I have experienced and did so far;

> Step 1: Check your target. > > My current target is IOS 13.2. From here, you will not see what > versions you currently have on your machine.

enter image description here

> Step 2: Check available versions on your local > > - Click the Generic IOS Device

enter image description here

> - This will display a dropdown menu that contains a Download Simulators... selection > - In case the Download Simulators... selection is not visible, you need to lower down your target. In my case, from 13.2 I made it 13.0 (This depends on your current XCode) then repeat the Step 2 again > - From here, I can now see the Download Simulators... selection > - Select it

enter image description here

> - You will now see what are the available versions you have > - From here, you may choose to download or just use the version you have (The one that is selected)

enter image description here

> Step 3: Change your IOS target accordingly > > - Now that you already know what are the available versions of the simulator you have locally, you can now change the IOS target. > - In my case I choose to use IOS 11 (Just for this sample) > - Then I change the target

enter image description here

> - Again click the Generic IOS Device

enter image description here

> - From here, you can now select any simulator under that IOS

enter image description here

I am not an expert, I just wanted to share my experience and I hope this can help someone.

Solution 11 - Ios

Modification to @Quver's answer. With latest Xcode version(8.3), the parameters to destination command should be given in double quotes. Single quotes didn't work for me

add -destination "platform=iOS Simulator,name=iPhone 7" to your xcodebuild

I haven't mentioned OS version in above command because when a newer version of iOS is released, this command will through error telling that this device is not found. So it is better not to give OS version

Solution 12 - Ios

In my case this happened, when I selected a Generic iOS device and tried to "build" in order to publish it to the AppStore.
But I should have selected Product -> Archive instead

Solution 13 - Ios

I fixed this issue for emulator,

Firstly check your emulator list

> Window > Devices and Simulators

after choose any device and click check OS Version

If you have only Apple Watch OS, You should download new IOS Simulator

and click download more simulator runtimes..

choose your correct IOS Simulator and download it.

Solution 14 - Ios

  1. I applied for a new AppleID and added it to the "Xcode->Preferences->Account" to solve this problem. (Xcode 7.3)
  2. At the same time I deleted original AppleID in the "Xcode->Preferences->Account",because it was no longer a paid account and couldn't add new devices.

Solution 15 - Ios

xcodebuild things were not working in my case.

Here's what I've solved.

I've removed my apple account and re-set(login) on the xcode preference, and this was solved.

ps. on iphone 10.1, I needed to push Trust button on General > Device Management > account info > Trust App

Solution 16 - Ios

I fixed this issue by going to the project settings, and under my 'Targets' section I had to set the Tests target to the correct team.

Solution 17 - Ios

Well if you want to get the list of available destinations then call xcodebuild and pass in the command line option -showdestinations, and it will print valid options for you to pick from:

xcodebuild -showdestinations -workspace Register.xcworkspace -scheme ThatTestTarget

Solution 18 - Ios

I tried almost anything above, including restarting XCode, none of them worked for me. I solved this problem by simply restarting my Mac. Yes, the classic solution.

A side note: This problem occurred to my XCode after it requested my Mac password from me, probably after an automatic upgrade.

Solution 19 - Ios

For xcode v11:

I ran into this issue when trying to create an Archive of my project. I was trying to click "Build" when the device was set to "Generic iOS Device", but the proper steps were:

  1. Set device to "Generic iOS Device"
  2. Go to Product -> Archive (skip pressing Build!)

Solution 20 - Ios

I had an entirely different problem. For some reason my app "Devices" was set to Universal build as opposed to iPhone. When I switched it to iPhone everything worked. Didn't need any extra settings.

Solution 21 - Ios

This worked for me.

You are trying to run on a device when you already built it for a different scheme. Go to

> Product > Clean.

Then build with your device chosen from the active schemes.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionyrpalnoobView Question on Stackoverflow
Solution 1 - IosQuverView Answer on Stackoverflow
Solution 2 - IosCueView Answer on Stackoverflow
Solution 3 - Ios米米米View Answer on Stackoverflow
Solution 4 - IosDan RosenstarkView Answer on Stackoverflow
Solution 5 - IosMr.ylView Answer on Stackoverflow
Solution 6 - IosWaltView Answer on Stackoverflow
Solution 7 - IosDisplay NameView Answer on Stackoverflow
Solution 8 - IosDaniel R. LivingstonView Answer on Stackoverflow
Solution 9 - IosBenjaBoyView Answer on Stackoverflow
Solution 10 - IosnewProgramm3rView Answer on Stackoverflow
Solution 11 - IosArunView Answer on Stackoverflow
Solution 12 - IosLeonid UstenkoView Answer on Stackoverflow
Solution 13 - IosBerat EyüboğluView Answer on Stackoverflow
Solution 14 - IosZack ZhangView Answer on Stackoverflow
Solution 15 - IoskakadaisView Answer on Stackoverflow
Solution 16 - IosLord FreshView Answer on Stackoverflow
Solution 17 - IosC JohnsonView Answer on Stackoverflow
Solution 18 - IosHarmanView Answer on Stackoverflow
Solution 19 - IosBlundering PhilosopherView Answer on Stackoverflow
Solution 20 - IosAmir JView Answer on Stackoverflow
Solution 21 - IosC. WaltherView Answer on Stackoverflow