Unable to run app in Simulator An error was encountered while running (Domain = NSPOSIXErrorDomain,Code = 22)
错误对话框如下所示:
我尝试了许多事情:
>重新启动Xcode
>重新启动模拟器
>重新启动
>重置模拟器的内容和设置
以上都没有.而我查看日志,我发现这些记录与这个问题有关
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 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.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:42.351 launchd_sim[2047]: assertion Failed: 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
我也发现一些其他人在这里有同样的问题:https://gist.github.com/bdeshong/2dd90add09b7287a9a85
没有运气在Googling之后找到解决方案.
这是我的环境信息
> OSX 10.9.5
> Xcode 6.0.1
> iOS Simulator 8.0(550.1)
有任何想法吗?
解决方法
我实际上在我的项目中添加了一个资源引用文件夹.所以我认为问题与此有关.但是,即使我从项目中删除了文件夹,问题仍然存在.最终,事实证明,资源文件夹可以存在
由于Xcode可能只是复制并覆盖目标App捆绑文件夹,所以资源文件夹可能仍然存在于App捆绑文件夹中.所以在删除资源文件夹后,你需要
>确保构建被清理
>确保模拟器中的应用程序已被删除
由于原因是App无法正常启动,那是因为它显示资源实际上是bundle structure中的一个保留的文件夹名称.通过将名为resources的文件夹添加到bundle中,以某种方式破坏了正常的结构.为了解决这个问题,我将名称从资源更改为app_data,或者是将其改为所有工作.