[英]Unable to run app in simulator
Today, when I try to run my app in simulator, it simply tells me 今天,当我尝试在模拟器中运行我的应用程序时,它只是告诉我
Unable to run app in Simulator
An error was encountered while running
(Domain = NSPOSIXErrorDomain, Code = 22)
And the error dialog looks like this: 错误对话框如下所示:
I've tried many things: 我尝试了很多东西:
None of above works. 以上都不适用。 And I looked into log, I found these are those records has something to do with this issue
我查看了日志,我发现这些记录与此问题有关
2014/10/15 9:09:40.964 com.apple.CoreSimulator.CoreSimulatorService[979]: Error Domain=com.apple.CoreSimulator.SimError Code=146 "Unable to lookup in current state: Shutdown" UserInfo=0x7f96c861d000 {NSLocalizedDescription=Unable to lookup in current state: Shutdown}
2014/10/15 9:09:40.964 com.apple.CoreSimulator.CoreSimulatorService [979]:错误Domain = com.apple.CoreSimulator.SimError Code = 146“无法在当前状态下查找:关闭”UserInfo = 0x7f96c861d000 {NSLocalizedDescription =无法在当前状态下查找:关机}
2014/10/15 9:09:40.964 Xcode[1983]: [MT] iPhoneSimulator: Unable to connect to "com.apple.instruments.deviceservice.lockdown" (Error Domain=com.apple.CoreSimulator.SimError Code=146 "Unable to lookup in current state: Shutdown" UserInfo=0x7fcf6fc24190 {NSLocalizedDescription=Unable to lookup in current state: Shutdown})
2014/10/15 9:09:40.964 Xcode [1983]:[MT] iPhoneSimulator:无法连接到“com.apple.instruments.deviceservice.lockdown”(错误域= com.apple.CoreSimulator.SimError Code = 146“无法在当前状态下查找:关闭“UserInfo = 0x7fcf6fc24190 {NSLocalizedDescription =无法在当前状态下查找:关机}”
2014/10/15 9:09:40.980 com.apple.CoreSimulator.CoreSimulatorService[979]: Error Domain=com.apple.CoreSimulator.SimError Code=146 "Unable to lookup in current state: Shutdown" UserInfo=0x7f96c861d000 {NSLocalizedDescription=Unable to lookup in current state: Shutdown}
2014/10/15 9:09:40.980 com.apple.CoreSimulator.CoreSimulatorService [979]:Error Domain = com.apple.CoreSimulator.SimError Code = 146“无法在当前状态下查找:Shutdown”UserInfo = 0x7f96c861d000 {NSLocalizedDescription =无法在当前状态下查找:关机}
2014/10/15 9:09:42.351 launchd_sim[2047]: assertion failed: 13F34: libxpc.dylib + 29453 [75E30F22-514B-3A20-B82C-EDA43AF5C35C]: 0x8d
2014/10/15 9:09:42.351 launchd_sim [2047]:断言失败:13F34:libxpc.dylib + 29453 [75E30F22-514B-3A20-B82C-EDA43AF5C35C]:0x8d
2014/10/15 9:09:42.362 com.apple.CoreSimulator.CoreSimulatorService[979]: Could not register service com.apple.coreservices.lsuseractivity.simulatorsupport: Failed to lookup com.apple.coreservices.lsuseractivity.simulatorsupport: 0x44e
2014/10/15 9:09:42.362 com.apple.CoreSimulator.CoreSimulatorService [979]:无法注册服务com.apple.coreservices.lsuseractivity.simulatorsupport:无法查找com.apple.coreservices.lsuseractivity.simulatorsupport:0x44e
I also found some other people had the same issue here : https://gist.github.com/bdeshong/2dd90add09b7287a9a85 我还发现其他一些人在这里有同样的问题: https : //gist.github.com/bdeshong/2dd90add09b7287a9a85
No luck to find solution after Googling around. 谷歌搜索后没有运气找到解决方案。
Here is my environment information 这是我的环境信息
Any ideas? 有任何想法吗?
I found the root causes, and I also found the solution. 我找到了根本原因,我也找到了解决方案。 First thing I've done is to ensure this has something to do with Xcode rather than a problem relative to the project itself.
我做的第一件事就是确保这与Xcode有关,而不是与项目本身有关的问题。 I tried to create a new project, and it works perfectly fine.
我试图创建一个新项目,它工作得非常好。 So I assume that is caused by something in my project.
所以我认为这是由我的项目中的某些东西引起的。
I actually added a resources
reference folder to my project. 我实际上在项目中添加了一个
resources
引用文件夹。 So I think the problem has something to do with it. 所以我认为这个问题与它有关。 However, even I removed the folder from project, the problem is still there.
但是,即使我从项目中删除了该文件夹,问题仍然存在。 In the end, it turns out, the
resources
folder could live in 事实证明,
resources
文件夹可以存在
Since Xcode may simply copy and overwrite target App bundle folder, so the resources
folder may still there in the App bundle folder. 由于Xcode可能只是复制和覆盖目标应用程序包文件夹,因此
resources
文件夹可能仍然存在于应用程序包文件夹中。 So after removing the resources
folder, you need to 因此,删除
resources
文件夹后,您需要
And for the reason the App cannot be launched correctly, that's because it appears resources
is actually a reserved folder name in the bundle structure . 由于App无法正确启动,因为它看起来
resources
实际上是捆绑结构中的保留文件夹名称。 By adding a folder named resources
into the bundle, somehow ruined the normal structure. 通过在包中添加名为
resources
的文件夹,以某种方式破坏了正常的结构。 To solve the problem, I changed the name from resources
to app_data
, or whatever it is, that all work. 为了解决这个问题,我将名称从
resources
更改为app_data
,或者不管是什么,都可以。
You are doing everything correct but Xcode and Swift are still in their early stages, means they are a little buggy right now. 你正在做的一切都是正确的,但Xcode和Swift仍然处于早期阶段,这意味着他们现在有点小马车。 Maybe try restarting your Xcode and iOS Simulator once more.
也许再试一次重启你的Xcode和iOS模拟器。
I got the exact same error. 我得到了完全相同的错误。 When browsing in my project info I inadvertently deleted the bundle identifier;
浏览我的项目信息时,我无意中删除了包标识符; hence the "ErrorDomain".
因此“ErrorDomain”。
to correct, goto project data; 纠正,转到项目数据; info;
信息; set bundle identifier to whatever it was.
将包标识符设置为它是什么。 it worked for me.
它对我有用。
This can happen for a couple of reasons: 出现这种情况有几个原因:
If neither of those is the case, take a look at ~/Library/Logs/CoreSimulator/*.log for more information that might help debugging and include it in your question. 如果不是这种情况,请查看〜/ Library / Logs / CoreSimulator / * .log以获取可能有助于调试的更多信息,并将其包含在您的问题中。
Root cause in my case was slightly different. 在我的情况下根本原因略有不同。 In the project file, the iOS deployment target was set to 8.0 for the test target and 8.1 for the main target.
在项目文件中,iOS部署目标对于测试目标设置为8.0,对于主目标设置为8.1。 We were running Xcode 6.0.1 (6A317) with 8.0 simulators on our build servers, which all started failing after the main build target was set to 8.1.
我们在构建服务器上运行了Xcode 6.0.1(6A317)和8.0模拟器,在主构建目标设置为8.1之后,所有模拟器都开始失败。
I'm not sure whether it was the fact that the target and tests were using different iOS deployment targets, or whether the 8.1 set in the project file conflicted with the 8.0 simulators, but it was this change which broke the simulators across several machines. 我不确定目标和测试是否使用不同的iOS部署目标,或者项目文件中的8.1设置是否与8.0模拟器冲突,但正是这种变化打破了几台机器上的模拟器。
Unfortunately after setting the iOS Deployment Target back to 8.0 in the project, it still required a reinstall of Xcode (I also removed the ~/Library/Developer/Xcode directory) to return simulators to a functional state. 不幸的是,在项目中将iOS部署目标设置回8.0之后,它仍然需要重新安装Xcode(我还删除了〜/ Library / Developer / Xcode目录)以将模拟器返回到功能状态。
I got the same. 我也一样。 I just did force quit xcode and simulator then worked for me.
我刚刚强制退出xcode和模拟器然后为我工作。
检查您的/private/tmp
文件夹是否具有适当的权限,对所有用户都应该是可写的和可执行的。
Clear all files in /Users/XXXXX/Library/Developer/CoreSimulator/Devices 清除/ Users / XXXXX / Library / Developer / CoreSimulator / Devices中的所有文件
Restart Xcode and Simulator. 重新启动Xcode和Simulator。
Now it will work. 现在它会起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.