xcode 无法在模拟器上运行应用程序“操作无法完成。(LaunchServicesError 错误 0。)”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34683193/
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
Cant run app on simulator "The operation couldn’t be completed. (LaunchServicesError error 0.)"
提问by Cheng Lin
I have an app on Xcode that was running just fine earlier. but all of the sudden it has stopped working when I try to run it. There was no code changed, and I don't know what happened. The error message is:
我在 Xcode 上有一个之前运行良好的应用程序。但是当我尝试运行它时,它突然停止了工作。没有更改代码,我不知道发生了什么。错误信息是:
"The operation couldn't be completed. (LaunchServicesError error 0.)"
“操作无法完成。(LaunchServicesError 错误 0。)”
When I look into the CoreSimulator log file I get this:
当我查看 CoreSimulator 日志文件时,我得到了这个:
Jan 8 11:43:55 C02PG69EG3QD com.apple.dt.Xcode[7083] : Error Domain=LaunchServicesError Code=0 "The operation couldn't be completed. (LaunchServicesError error 0.)" UserInfo=0x7fc597a59240{Error=PackageExtractionFailed, ErrorDescription=Failed to copy file:///Users/myUsername/Library/Developer/Xcode/DerivedData/myApp-eyozcttdojgdpgdstfspqjxsztrb/Build/Products/Debug-iphonesimulator/myApp.app/ to file:///Users/myUsername/Library/Developer/CoreSimulator/Devices/DAC0E72A-6F6A-42EA-A8CA-5F41E22F2CCC/data/Library/Caches/com.apple.mobile.installd.staging/temp.qtgx1Q/extracted/myApp.app/}
Jan 8 11:43:55 C02PG69EG3QD com.apple.dt.Xcode[7083]:Error Domain=LaunchServicesError Code=0“操作无法完成。(LaunchServicesError 错误 0。)” UserInfo=0x7fc597a59240{Error= PackiledExtraction ErrorDescription=复制文件失败://Users/myUsername/Library/Developer/Xcode/DerivedData/myApp-eyozcttdojgdpgdstfspqjxsztrb/Build/Products/Debug-iphonesimulator/myApp.app/到文件://Users/myUsername/Library/开发人员/CoreSimulator/Devices/DAC0E72A-6F6A-42EA-A8CA-5F41E22F2CCC/data/Library/Caches/com.apple.mobile.installd.staging/temp.qtgx1Q/extracted/myApp.app/}
Basically it says that Xcode can't copy the file from one place to other.So I thought it might be a permissions issue. I did chmod with 777 to both folders, but that didn't work.
基本上它说Xcode无法将文件从一个地方复制到另一个地方。所以我认为这可能是一个权限问题。我对两个文件夹都用 777 进行了 chmod,但这没有用。
I also tried 'Reset content and setting'for simulator, it gave me permission error to remove certain files, so i did it manually. and this method didnt work either.
我还尝试了模拟器的“重置内容和设置”,它给了我删除某些文件的权限错误,所以我手动完成了。而且这个方法也没有用。
I have tried:
我试过了:
- restart the simulator and xcode
- clean and rebuild
- clean build folder and rebuild
- delete Xcode and reinstall it
- using a different iPhone simulator, like changing from iPhone 6 to iPhone 6s
- 重启模拟器和xcode
- 清理和重建
- 清理构建文件夹并重建
- 删除Xcode并重新安装
- 使用不同的 iPhone 模拟器,比如从 iPhone 6 换到 iPhone 6s
None of the above worked for me.
以上都不适合我。
Note: one thing that was working, was if I run it through my iPhone via USB connection.
注意:一件事是有效的,如果我通过 USB 连接通过我的 iPhone 运行它。
I guess to solve this problem, I will need to figure out the way for Xcode to be able to copy file to its destination. Does anyone have any clue for this?
我想要解决这个问题,我需要找出 Xcode 能够将文件复制到目的地的方法。有没有人对此有任何线索?
回答by amisha.beladiya
Just force quit the Simulator and restart again.Then run the source code.
只需强制退出模拟器并重新启动。然后运行源代码。
回答by Nik Bhatt
I ran into this today. I had just changed the bundle identifier on my app, which invalidated the app id and the provisioning profiles. As a result, the app couldn't installed (with that alert). Once I made new app id's and profiles, things worked fine.
我今天遇到了这个。我刚刚更改了应用程序上的包标识符,这使应用程序 ID 和配置文件无效。结果,无法安装该应用程序(带有该警报)。一旦我创建了新的应用程序 ID 和配置文件,一切就正常了。
回答by WasimSafdar
I just deleted my "DerivedData" in Xcode for my application and everything starts working file. In finder Go-->GotoFolder-->"/Users/myUsername/Library/Developer/Xcode/DerivedData". Delete your app folder and run again.
我刚刚在 Xcode 中为我的应用程序删除了我的“DerivedData”,一切都开始工作文件。在 finder 中 Go-->GotoFolder-->"/Users/myUsername/Library/Developer/Xcode/DerivedData"。删除您的应用程序文件夹并再次运行。
回答by Delimiter
Usually stuff like that just requires you to delete DerivedData which is what I just had to do to fix it. I just use the following script in Automator:
通常这样的事情只需要您删除 DerivedData,这就是我必须做的来修复它。我只是在 Automator 中使用以下脚本:
do shell script "rm -frd '$(getconf DARWIN_USER_CACHE_DIR).org.llvm.clang/ModuleCache'"
执行 shell 脚本“rm -frd '$(getconf DARWIN_USER_CACHE_DIR).org.llvm.clang/ModuleCache'”
do shell script "rm -frd ~/Library/Developer/Xcode/DerivedData/*"
做shell脚本“rm -frd ~/Library/Developer/Xcode/DerivedData/*”
do shell script "rm -frd ~/Library/Caches/com.apple.dt.Xcode/*"
做shell脚本“rm -frd ~/Library/Caches/com.apple.dt.Xcode/*”
回答by AnneTheAgile
I got this today. I have not changed anything, but I was opening a branch that was used by a user who had upgraded Xcode to 7.3, Monday's new version. Closing the simulator app fixed it for me.
我今天得到了这个。我没有更改任何内容,但是我打开了一个分支,该分支由已将 Xcode 升级到 7.3(星期一的新版本)的用户使用。关闭模拟器应用程序为我修复了它。
回答by BatyrCan
just rename bundleIdentifier-->com.sample.myTest to anything like -->com.sample.myTests. It works on Xcode 8.2
只需将 bundleIdentifier-->com.sample.myTest 重命名为 -->com.sample.myTests 之类的名称。它适用于 Xcode 8.2