ios 仅构建设备不能用于运行此目标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33747828/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
A build only device cannot be used to run this target
提问by yrpalnoob
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 设备可用。连接设备以运行您的应用程序或选择模拟设备作为目标。
回答by Quver
add -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.3'
to your xcodebuild
添加-destination 'platform=iOS Simulator,name=iPhone 6,OS=9.3'
到您的xcodebuild
回答by Cue
回答by u5150587
回答by Dan Rosenstark
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:
您需要获取有效目的地的列表。为此,请指定一个错误的键值对,xcodebuild 将输出有效的组合:
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
更改等号的冒号、删除空格、忽略 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:
更改逗号的冒号,删除空格,删除 ID,因此您会得到以下字符串:
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
回答by Mr.yl
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 "
我遇到了只能选择“通用 iOS 设备”的问题。当我运行时,它说“不能使用仅构建设备来运行此目标。没有可用的受支持的 iOS 设备。连接设备以运行您的应用程序或选择一个模拟设备作为目标”
and my solution for the problem is selecting Build Settings ---> Deployment ----->IOS Deployment Target---->choose a lower version like 8.0,
而我的解决方案是选择Build Settings ---> Deployment ----->IOS Deployment Target---->选择一个较低的版本,比如8.0,
and i found the simulator come out and can be chosen.
我发现模拟器出来了,可以选择。
回答by Walt
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.)
您正在为 Xcode 的“Build Only Device”构建应用程序,它正在编译应用程序。对于 ARM 处理器(而为模拟器编译的目标是 Mac 上的 Intel CPU。)
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.
插入一个设备并从活动方案弹出窗口中选择它,或者,选择一个模拟器,你应该很高兴。
回答by catanore
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.
使用 XCode 8.3.2 后,我尝试在锁定的设备上运行该应用程序后收到此错误消息。我按要求解锁并重新连接,但“只能使用构建设备来运行此目标。” 消息出现。
I simply changed the target to a simulator and changed it back - it resolved my issue.
我只是将目标更改为模拟器并将其更改回来 - 它解决了我的问题。
回答by Arun
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
修改@Quver 的回答。使用最新的 Xcode 版本(8.3),目标命令的参数应该用双引号给出。单引号对我不起作用
add -destination "platform=iOS Simulator,name=iPhone 7"
to your xcodebuild
添加-destination "platform=iOS Simulator,name=iPhone 7"
到您的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
我在上面的命令中没有提到操作系统版本,因为当发布新版本的 iOS 时,这个命令会通过错误提示找不到此设备。所以最好不要给OS版本
回答by jungwon jin
xcodebuild things were not working in my case.
xcodebuild 的东西在我的情况下不起作用。
Here's what I've solved.
这是我解决的问题。
I've removed my apple account and re-set(login) on the xcode preference, and this was solved.
我已经删除了我的苹果帐户并在 xcode 首选项上重新设置(登录),这已经解决了。
ps. on iphone 10.1, I needed to push Trust button on General > Device Management > account info > Trust App
附:在 iphone 10.1 上,我需要在 General > Device Management > account info > Trust App 上按下 Trust 按钮
回答by Zack Zhang
- I applied for a new AppleID and added it to the "Xcode->Preferences->Account" to solve this problem. (Xcode 7.3)
- 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.
- 我申请了一个新的AppleID并将其添加到“Xcode->Preferences->Account”中以解决此问题。(Xcode 7.3)
- 同时我在“Xcode->Preferences->Account”中删除了原来的AppleID,因为它不再是付费账户,无法添加新设备。