无效的设备状态 - Xcode/iOS 模拟器错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29480245/
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
Invalid Device State - Xcode/iOS Simulator error
提问by KeeperOfKale
Problem: I cannot simulate an Apple watch interface. Whenever I try and test my Apple watch app on the iPhone 6 simulator, Xcode successfully finishes and builds the app, attempts at opening simulator and fails with an error message which reads 'Invalid Device State'.
问题:我无法模拟 Apple Watch 界面。每当我尝试在 iPhone 6 模拟器上测试我的 Apple Watch 应用程序时,Xcode 都会成功完成并构建应用程序,尝试打开模拟器并失败,并显示错误消息“设备状态无效”。
I believe simulator has a watch simulator that opens along with the compatible iPhone simulator models that can communicate with Apple watch (example: iPhone 6) Although I have yet to see it work. I have built a universal interface for iPad and iPhone and another for the watch, so it's not a matter of the app being for the wrong device. Whenever I test on my actual iPhone I can test the universal interface successfully.
我相信模拟器有一个手表模拟器,可以与兼容的 iPhone 模拟器模型一起打开,可以与 Apple Watch 通信(例如:iPhone 6),尽管我还没有看到它工作。我已经为 iPad 和 iPhone 构建了一个通用界面,并为手表构建了另一个界面,所以这不是应用程序用于错误设备的问题。每当我在我的实际 iPhone 上进行测试时,我都可以成功地测试通用接口。
I'm using Xcode 6.2 on iMac OS X 10.10.3
我在 iMac OS X 10.10.3 上使用 Xcode 6.2
I have tried restarting Xcode/Computer. I can't seem to find any other mention of 'Invalid Device State' anywhere, hopefully due to it being an obvious thing to avoid/fix that I've overlooked. Any help would be appreciated.
我试过重新启动 Xcode/计算机。我似乎在任何地方都找不到关于“无效设备状态”的任何其他提及,希望因为这是我忽略的避免/修复的明显事情。任何帮助,将不胜感激。
回答by Chirag Vindhani
Force Quit xCode and restart will resolve problem.
强制退出 xCode 并重新启动将解决问题。
回答by Jayprakash Dubey
I had come across this issue after updating Xcode 6.4 to 7.1. Below are fixes for this :
将 Xcode 6.4 更新到 7.1 后,我遇到了这个问题。以下是对此的修复:
- Clean project(cmd+shift+k) as well as clean build folder(cmd+shift+k+option)
- 清理项目(cmd+shift+k)以及清理构建文件夹(cmd+shift+k+option)
- Quit simulatorand run again
- Quit Xcode and Simulatorand run again
- Restart your Mac.
- 退出模拟器并再次运行
- 退出 Xcode 和 Simulator并再次运行
- 重新启动您的 Mac。
Solution 3 worked for me!
解决方案 3 对我有用!
回答by RoaflinSabos
I had the same issue. Generally it is because you just update Xcode or change its name in the Applications folder.
我遇到过同样的问题。通常是因为您只是在 Applications 文件夹中更新 Xcode 或更改其名称。
If you just restart your computer it will work correctly.
如果您只是重新启动计算机,它将正常工作。
Hope it helps !
希望能帮助到你 !
回答by bademi
I observed this happening when more than one Xcode app installed.
当安装了多个 Xcode 应用程序时,我观察到了这种情况。
To fix this,
为了解决这个问题,
- Launch Xcode and click preference..,
- Go to "Location" Tab, Select correct options from "Command Line Tools" dropdown
- Quit Xcode and relaunch it.
- Run your app.
- 启动 Xcode 并单击首选项...,
- 转到“位置”选项卡,从“命令行工具”下拉列表中选择正确的选项
- 退出 Xcode 并重新启动它。
- 运行您的应用程序。
回答by Mandeep Singh
First of all, just clean the project.
首先,只需清理项目。
- Quit your
project
. - Quit your
Xcode
. - Restart
Xcode
.
- 退出你的
project
. - 退出你的
Xcode
. - 重新启动
Xcode
。
This happens to me when I have two different Xcode
versions running at the same time. Hopefully this helps you.
当我Xcode
同时运行两个不同的版本时,就会发生这种情况。希望这对你有帮助。
回答by Laurent
No need to quit, restart or even re-install. Switch to another iOS Simulator device (6s if you were using 6s plus) and voila!
无需退出、重新启动甚至重新安装。切换到另一个 iOS 模拟器设备(如果您使用的是 6s plus 则为 6s),瞧!
回答by Dheeraj D
I have Xcode 7.3
and Xcode 8.0
Installed.
我有Xcode 7.3
并Xcode 8.0
安装。
If a am working with Xcode7.3 and opens Xcode8.0 to get some code from Xcode8.0 project.
如果正在使用 Xcode7.3 并打开 Xcode8.0 以从 Xcode8.0 项目中获取一些代码。
When i run my application on Xcode7.3 So it will give me same error.
当我在 Xcode7.3 上运行我的应用程序时,它会给我同样的错误。
Solution is simple ForceQuit or Quit all Xcode's and open the required one.
解决方案很简单,强制退出或退出所有 Xcode 并打开所需的。
回答by Swapnil
Nothing worked for me on XCode 7.3.1.
Had to reinstall it to make the simulator work.
在 XCode 7.3.1 上没有什么对我有用。
必须重新安装它才能使模拟器工作。
- Go to applications folder. Drag drop XCode to Dustbin.
- Empty dustbin contents.
- Go to App Store and install XCode.
- Run XCode. The simulator should work now.
- 转到应用程序文件夹。将 XCode 拖放到垃圾箱。
- 空垃圾箱内容物。
- 转到 App Store 并安装 XCode。
- 运行 XCode。模拟器现在应该可以工作了。
回答by serdar aylanc
Jus clean the project and restart Xcode. This happens to me when I have two diffent xcode versions running at the same time.
只需清理项目并重新启动Xcode。当我同时运行两个不同的 xcode 版本时,就会发生这种情况。
回答by Kevin Laity
In my case, the simulator would show an indefinite black screen whether attempting to run a project, or running the simulator directly (which should bring you to the simulated home screen). This would happen even on a newly created simulated device.
就我而言,无论是尝试运行项目还是直接运行模拟器(这应该将您带到模拟的主屏幕),模拟器都会显示无限期的黑屏。即使在新创建的模拟设备上也会发生这种情况。
After the existing suggestions failed, the following worked for me:
在现有建议失败后,以下对我有用:
- Delete the Simulator
- Delete XCode
- Delete the Developer folder
- Reinstall XCode from the app store. This requires attempting to run XCode again so that Mac OS will realize it's no longer installed.
- 删除模拟器
- 删除 XCode
- 删除开发者文件夹
- 从应用商店重新安装 XCode。这需要尝试再次运行 XCode,以便 Mac OS 意识到它不再安装。