只生成设备不能用于运行此目标

当我试图测试一个应用程序时,我得到了这个错误。

只生成设备不能用于运行此目标。

没有支持的 iOS 设备可用。连接设备以运行应用程序或选择模拟设备作为目标。

82821 次浏览

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.

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.

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

  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.

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.

Below is my way

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

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

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

Menu image

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

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.

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.

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.

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

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.

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.

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

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.

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!)

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

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

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.