ios 运行时遇到错误(域 = LaunchServicesError,代码 = 0)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25632886/
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
An error was encountered while running (Domain = LaunchServicesError, Code = 0)
提问by Liran Revivo
I received an error (Domain = LaunchServicesError, Code = 0) when trying to launch my app in the iOS Simulator with Xcode 6. I looked for solution in google, but I didn't find anything practical.
我在尝试使用 Xcode 6 在 iOS 模拟器中启动我的应用程序时收到错误(域 = LaunchServicesError,代码 = 0)。我在谷歌中寻找解决方案,但没有找到任何实用的方法。
What does this error mean?
这个错误是什么意思?
回答by Jeremy Huddleston Sequoia
This error indicates that there was a problem with installation. Unfortunately, Xcode does not actually print the contents of the error message that would give you more insight, but you can look at ~/Library/Logs/CoreSimulator/CoreSimulator.log to see the rest of the error details. There will also be more information about the problem in the simulated device's system log (~/Library/Logs/CoreSimulator/[Device UDID]/system.log); look for messages from installd around the time of the error).
此错误表明安装存在问题。不幸的是,Xcode 实际上并没有打印错误消息的内容来让您更深入地了解,但是您可以查看 ~/Library/Logs/CoreSimulator/CoreSimulator.log 以查看其余的错误详细信息。在模拟设备的系统日志(~/Library/Logs/CoreSimulator/[Device UDID]/system.log)中也会有更多关于问题的信息;在错误发生时查找来自安装的消息)。
Common causes for this include bundles missing an Info.plist, missing keys within your bundle's Info.plist, or values for some keys in the Info.plist not being allowed.
造成这种情况的常见原因包括包缺少 Info.plist、包的 Info.plist 中缺少键或 Info.plist 中某些键的值不被允许。
If your app's Info.plist does not contain a valid CFBundleVersion key/value pair, it is possible that your app may install correctly the first time but fail to update. Many users seem to work around this by doing a "Reset Contents & Settings" after each install, but it would be better to fix the root cause by setting an appropriate CFBundleVersion in the Info.plist. I believe iOS 8.2 now correctly returns an error on the first install in this case rather than just on updates, so hopefully this problem will be more obvious now.
如果您的应用程序的 Info.plist 不包含有效的 CFBundleVersion 键/值对,则您的应用程序可能在第一次正确安装但无法更新。许多用户似乎通过在每次安装后执行“重置内容和设置”来解决此问题,但最好通过在 Info.plist 中设置适当的 CFBundleVersion 来解决根本原因。我相信 iOS 8.2 现在在这种情况下在第一次安装时正确返回错误,而不仅仅是在更新时,所以希望这个问题现在会更加明显。
Users with home directories on file systems that do not support hard links (eg: network home directories via AFP, SMB, or some NFS servers) may also run into problems related to hard linking. If this is the case, I suggest you create a path on your local HFS+ filesystem for simulator development (eg: /var/simulator/[user]) and create a symlink to that path from ~/Library/Developer/CoreSimulator. This particular issue was fixed in one of the iOS 8.2 betas.
在不支持硬链接的文件系统上拥有主目录的用户(例如:通过 AFP、SMB 或某些 NFS 服务器的网络主目录)也可能遇到与硬链接相关的问题。如果是这种情况,我建议您在本地 HFS+ 文件系统上为模拟器开发创建一个路径(例如:/var/simulator/[user])并从 ~/Library/Developer/CoreSimulator 创建一个指向该路径的符号链接。此特定问题已在 iOS 8.2 测试版之一中得到修复。
In another case, the Build&Run would always succeed on the first try, but subsequent attempts would sometimes fail due to a changed Info.plist (eg: because someone's build system settings result in CFBundleVersion being different on each iteration). You can usually recover by either deleting the installed app (using a long-press from the home screen or xcrun simctl uninstall [Device UDID] [app identifier]
) or erasing the device back to a default state. To erase the device, execute xcrun simctl erase [Device UDID]
from terminal or choose Erase Contents & Settings
from the iOS Simulator menu. This particular issue was fixed in one of the iOS 8.2 betas.
在另一种情况下,Build&Run 在第一次尝试时总是会成功,但随后的尝试有时会由于 Info.plist 的更改而失败(例如:因为某人的构建系统设置导致 CFBundleVersion 在每次迭代中都不同)。您通常可以通过删除已安装的应用程序(使用主屏幕上的长按或xcrun simctl uninstall [Device UDID] [app identifier]
)或将设备擦除回默认状态来恢复。要擦除设备,请xcrun simctl erase [Device UDID]
从终端执行或Erase Contents & Settings
从 iOS 模拟器菜单中选择。此特定问题已在 iOS 8.2 测试版之一中得到修复。
A newer instance of this issue is occurring for Xcode 6.2 users. If you have a WatchKit App Extension bundled in your app, it will fail to install to versions of the iOS Simulator runtime older than iOS 8.2. As a workaround, you will need to manually disable the app extension from installing when you want to test with iOS 8.1 and earlier runtimes.
对于 Xcode 6.2 用户,此问题的较新实例正在发生。如果您的应用中捆绑了 WatchKit 应用扩展,它将无法安装到低于 iOS 8.2 的 iOS 模拟器运行时版本。作为一种解决方法,当您想要使用 iOS 8.1 和更早的运行时进行测试时,您需要手动禁用应用程序扩展程序的安装。
If you need more specific help, please provide the entirety of the error message from CoreSimulator.log and any messages from installd and CoreSimulatorBridge that appear around the same time in ~/Library/Logs/CoreSimulator/[Device UDID]/system.log as that will reveal the underlying problem.
如果您需要更具体的帮助,请提供来自 CoreSimulator.log 的完整错误消息以及来自 installd 和 CoreSimulatorBridge 的任何消息,这些消息几乎同时出现在 ~/Library/Logs/CoreSimulator/[Device UDID]/system.log 中这将揭示潜在的问题。
回答by Rachid Finge Jr
Does your project include a widget or extension? If so, the problem could be the bundle identifier of your widget/extension. It should be the same as the main target, appended with a period and an extra string. So for example:
您的项目是否包含小部件或扩展?如果是这样,问题可能是您的小部件/扩展程序的包标识符。它应该与主要目标相同,并附加一个句点和一个额外的字符串。例如:
Main target: com.mycompany.myapp
主要目标: com.mycompany.myapp
Widget should be: com.mycompany.myapp.widget
小部件应该是: com.mycompany.myapp.widget
回答by Chris Long
I fixed it by resetting the simulator:
我通过重置模拟器修复了它:
iOS Simulator > Reset Contents and Settings...
iOS 模拟器 > 重置内容和设置...
回答by Zoltán
Since everyone writes what theywent through and how theyfixed theirexact problem, that might be unhelpful.
既然每个人都写了什么,他们经历了怎样他们固定的确切的问题,这可能是无益的。
The problem is that there are different causes for the same error message and the right way of solving it is to open up ~/Library/Logs/CoreSimulator/CoreSimulator.log
and look in there for the last message. This message gives you a good clue and sets you on the right path of solving your problem (sometimes it's bundle IDs, sometimes it's a missing or an extra attribute in the Info.plist, but you always get a good, descriptive clue).
问题是相同的错误消息有不同的原因,解决它的正确方法是打开~/Library/Logs/CoreSimulator/CoreSimulator.log
并查看最后一条消息。此消息为您提供了一个很好的线索,并为您提供了解决问题的正确途径(有时是包 ID,有时是 Info.plist 中缺少或额外的属性,但您总能得到一个很好的描述性线索)。
This is how you narrow down the problem and eventually get to fix it.
这就是您缩小问题范围并最终解决问题的方法。
Good luck and tough nerves with Xcode .)
Xcode 祝你好运和坚强。)
Z.
Z。
回答by CFSoftware Malta
For me I just cleaned the project and it worked -> Product -> Clean
对我来说,我只是清理了项目并且它起作用了 -> 产品 -> 清洁
回答by UKDataGeek
TLDR: Clear your Project Build Folder - and you will be free of this pain.
TLDR:清除您的项目构建文件夹 - 您将摆脱这种痛苦。
( plus I logged this as a bug with Apple as they need to find a way to fix this in Xcode )
(另外我将此记录为 Apple 的错误,因为他们需要找到一种方法在 Xcode 中解决此问题)
None of these solutions worked for me - I banged my head against several walls.
I looked at the CoreSimulator log and I realised that it was trying to build a library that I had deleted.
I couldn't find references to it anywhere.
这些解决方案都不适合我 - 我的头撞在了几堵墙上。
我查看了 CoreSimulator 日志,我意识到它正在尝试构建一个我已删除的库。我在任何地方都找不到对它的引用。
Then I saw via another SO Question which unfortunately I can't find to reference, if you:
然后我通过另一个 SO 问题看到,不幸的是我找不到参考,如果你:
- Hold down your option key then Product-> Clean option becomes
Clean Build Folder
- Press that and enjoy having your error vanish
- 按住您的选项键,然后 Product-> Clean 选项变为
Clean Build Folder
- 按那个,享受你的错误消失
回答by Sauvik Dolui
"Reset Content and Settings"from iOS Simutalormenu options and launching simulator after Quittingsolved my issue.
从iOS Simutalor菜单选项中“重置内容和设置”并在退出后启动模拟器解决了我的问题。
回答by Meg de Graaf
In XCode 6
在 XCode 6 中
An error was encountered while running (Domain = LaunchServicesError, Code = 0)
运行时遇到错误(域 = LaunchServicesError,代码 = 0)
I had this error after making some major code changes to accommodate the iPhone 6 Screens. in Xcode 6 (iOS8)
在进行了一些主要的代码更改以适应 iPhone 6 屏幕后,我遇到了这个错误。在 Xcode 6 (iOS8) 中
I followed the options above and found that the only way to really get this fixed was by doing the following:
我遵循了上面的选项,发现真正解决这个问题的唯一方法是执行以下操作:
- Deleted the derived data [go to Window >> Organizer >> (Find your App) Click on Delete next to the Derived Data]
- Product >> Clean
- Reset Contents and Settings in Simulator
Changed the Bundle Version to 1.4.1 from 1.4 in pList
Thank you for all the previous answers that got me to this stage. It worked a charm!
- 删除派生数据[转到窗口>>管理器>>(查找您的应用程序)单击派生数据旁边的删除]
- 产品 >> 清洁
- 在模拟器中重置内容和设置
将捆绑版本从 pList 中的 1.4 更改为 1.4.1
感谢您之前的所有回答让我走到了这个阶段。它很有魅力!
回答by jos
In my case, the error was caused because i didn't set the build id.
就我而言,错误是因为我没有设置构建 ID。
Setting this, launches the emulator without problem.
设置这个,启动模拟器没有问题。
回答by possen
One other thing to try, that worked for me, after resetting the simulator and doing a clean build did not help, is clearing out the derived data. To do this: go to Organizer click on project click on delete derived data button. I had this happen after working on an extension for a while and went back to the regular branch. Hope this helps.
另一件对我有用的尝试,在重置模拟器并进行干净的构建后没有帮助,是清除派生数据。为此:转到管理器单击项目单击删除派生数据按钮。我在扩展工作一段时间后发生了这种情况,然后回到常规分支。希望这可以帮助。