在 iOS 模拟器上测试时出错:无法向引导服务器注册
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/788277/
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
Error when testing on iOS simulator: Couldn't register with the bootstrap server
提问by lostInTransit
I was testing my app on the simulator when it crashed on clicking a button of a UIAlertView. I stopped debugging there, made some changes to the code and built the app again. Now when I run the application, I get this error in the console
我在模拟器上测试我的应用程序时,它在单击 UIAlertView 的按钮时崩溃。我在那里停止调试,对代码进行了一些更改并再次构建了应用程序。现在,当我运行应用程序时,我在控制台中收到此错误
Couldn't register com.myApp.debug with the bootstrap server. Error: unknown error code. This generally means that another instance of this process was already running or is hung in the debugger.Program received signal: “SIGABRT”.
无法向引导服务器注册 com.myApp.debug。错误:未知错误代码。这通常意味着该进程的另一个实例已经在运行或在调试器中挂起。程序收到信号:“SIGABRT”。
I tried removing the app from the simulator, doing a clean build but I still get this error when I try to run the app.
我尝试从模拟器中删除该应用程序,进行干净的构建,但是当我尝试运行该应用程序时仍然出现此错误。
What should I do to be able to run the app on my simulator again?
我应该怎么做才能再次在我的模拟器上运行应用程序?
采纳答案by Elliot Kroo
Try quitting and restarting the simulator? If "worse comes to worst" you can always try restarting: in my experience this should fix it.
尝试退出并重新启动模拟器?如果“更糟”,您可以随时尝试重新启动:根据我的经验,这应该可以解决问题。
回答by smparkes
status:this has been seen as recently as Mac OS 10.8 and Xcode 4.4.
状态:最近出现在 Mac OS 10.8 和 Xcode 4.4 中。
tl;dr:This can occur in two contexts: when running on the device and when running on the simulator. When running on the device, disconnecting and reconnecting the device seems to fix things.
tl;dr:这可能发生在两种情况下:在设备上运行时和在模拟器上运行时。在设备上运行时,断开并重新连接设备似乎可以解决问题。
launchctl list|grep UIKitApplication|awk '{print }'|xargs launchctl remove
This doesn't work all the time. In fact, it's never worked for me but it clearly works in some cases. Just don't know which cases. So it's worth trying.
这并不总是有效。事实上,它从来没有对我有用,但它在某些情况下显然有效。就是不知道是什么情况。所以值得一试。
Otherwise, the only known way to fix this is to restart the user launchd. Rebooting will do that but there is a less drastic/faster way. You'll need to create another admin user, but you only have to do that once. When things wedge, log out as yourself, log in as that user, and kill the launchd that belongs to your main user, e.g.,
否则,解决此问题的唯一已知方法是重新启动用户 launchd。重新启动会做到这一点,但有一种不那么激烈/更快的方式。您需要创建另一个管理员用户,但您只需要做一次。当事情发生时,以您自己的身份注销,以该用户身份登录,并杀死属于您的主要用户的 launchd,例如,
sudo kill -9 `ps aux | egrep 'user_id .*[0-9] /sbin/launchd' | awk '{print }'`
substituting your main user name for user_id
. Logging in again as your normal user gets you back to a sane state. Kinda painful, but less so than a full reboot.
用您的主要用户名替换user_id
. 以普通用户身份再次登录可让您恢复正常状态。有点痛苦,但不如完全重启。
details:
细节:
This has started happening more often with Lion/Xcode 4.2. (Personally, I never saw it before that combination.)
在 Lion/Xcode 4.2 中,这种情况开始更频繁地发生。(就我个人而言,在这种组合之前我从未见过它。)
The bug seems to be in launchd, which inherits the app process as a child when the debugger stops debugging it without killing it. This is usually signaled by the app becoming a zombie, having a process status of Z in ps.
该错误似乎在launchd中,当调试器停止调试而不将其杀死时,它会将应用程序进程作为子进程继承。这通常由应用程序变成僵尸来表示,在 ps 中的进程状态为 Z。
The core issue appears to be in the bootstrap name server which is implemented in launchd. This (to the extent I understand it) maps app ids to mach ports. When the bug is triggered, the app dies but doesn't get cleaned out of the bootstrap server's name server map and as result, the bootstrap server refuses to allow another instance of the app to be registered under the same name.
核心问题似乎出现在launchd 中实现的引导名称服务器中。这(就我的理解而言)将应用程序 ID 映射到 mach 端口。当错误被触发时,应用程序会终止,但不会从引导服务器的名称服务器映射中清除,因此引导服务器拒绝允许以相同名称注册应用程序的另一个实例。
It was hoped (see the comments) that forcing launchd to wait()
for the zombie would fix things but it doesn't. It's not the zombie status that's the core problem (which is why some zombies are benign) but the bootstrap name server and there's no known way to clear this short of killing launchd.
希望(见评论)强制wait()
为僵尸启动会解决问题,但事实并非如此。核心问题不是僵尸状态(这就是为什么有些僵尸是良性的),而是引导名称服务器,并且没有已知的方法可以清除这种缺少杀死 launchd 的情况。
It looks like the bug is triggered by something bad between Xcode, gdb, and the user launchd. I just repeated the wedge by running an app in the iphone simulator, having it stopped within gdb, and then doing a build and run to the ipad simulator. It seems to be sensitive to switching simulators (iOS 4.3/iOS 5, iPad/iPhone). It doesn't happen all the time but fairly frequently when I'm switching simulators a lot.
看起来这个错误是由 Xcode、gdb 和用户 launchd 之间的错误触发的。我只是通过在 iphone 模拟器中运行一个应用程序来重复这个楔子,让它在 gdb 中停止,然后进行构建并运行到 ipad 模拟器。它似乎对切换模拟器(iOS 4.3/iOS 5、iPad/iPhone)很敏感。它不会一直发生,但当我经常切换模拟器时会相当频繁。
Killing launchd while you're logged in will screw up your session. Logging out and logging back in doesn't kill the user launchd; OS X keeps the existing process around. A reboot will fix things, but that's painful. The instructions above are faster.
在您登录时杀死 launchd 会搞砸您的会话。注销并重新登录不会杀死用户 launchd;OS X 保留现有进程。重启会解决问题,但这很痛苦。上面的说明更快。
I've submitted a bug to Apple, FWIW. rdar://10330930
我已向 Apple FWIW 提交了一个错误。雷达://10330930
回答by jyap
I find I have started having this issue with Lion + Xcode 4.2. I have also experienced the issue in Xcode 4.3.
我发现我已经开始在使用 Lion + Xcode 4.2 时遇到这个问题。我在 Xcode 4.3 中也遇到过这个问题。
I have tried all the suggestions but none of them have worked other than a full reboot.
我已经尝试了所有建议,但除了完全重新启动之外,没有一个建议有效。
Here is how you determine if you require a reboot quickly.
以下是您确定是否需要快速重启的方法。
List out all your Zombie processes:
列出你所有的僵尸进程:
ps -el | grep 'Z'
If you see your app listed as a Zombie process you will need to reboot your machine. The error message states "This generally means that another instance of this process was already running or is hung in the debugger". Well, Xcode is detecting this Zombie process which you can't kill. The only way you can then fix it is with a system reboot. :(
如果您看到您的应用程序被列为僵尸进程,您将需要重新启动您的机器。错误消息指出“这通常意味着此进程的另一个实例已在运行或在调试器中挂起”。好吧,Xcode 正在检测这个您无法杀死的 Zombie 进程。然后您可以修复它的唯一方法是重新启动系统。:(
EDIT, 20120823:I have some better knowledge of Zombie processes so I wanted to update this answer. A Zombie process is created when a parent process does not call wait() (wait for process to change state) on a terminating child process. You can't run 'kill' directly on a Zombie process but if you kill the parent process, the zombie child process will be 'reaped' and removed from the process table.
编辑,20120823:我对僵尸进程有一些更好的了解,所以我想更新这个答案。当父进程未在终止子进程上调用 wait()(等待进程更改状态)时,将创建僵尸进程。您不能直接在僵尸进程上运行“kill”,但是如果您杀死父进程,僵尸子进程将被“收割”并从进程表中删除。
I haven't seen this issue in a long while so haven't inspected to see what the parent process is in this scenario. The alternative to killing the parent process is to reboot your system. :)
我有很长一段时间没有看到这个问题,所以没有检查在这种情况下父进程是什么。杀死父进程的替代方法是重新启动系统。:)
回答by n3wscott
I just had this happen to me: I was getting the error only on my device and the simulator was working fine. I ended up having to reset my device and the error went away.
我刚刚发生了这种情况:我只在我的设备上收到错误并且模拟器工作正常。我最终不得不重置我的设备,错误消失了。
回答by sang
I'm having this problem very often recently. What would prevent this from occurring? Logging out and in fixes the problem but.. it's annoying to do so every so often.
我最近经常遇到这个问题。什么会阻止这种情况发生?注销并登录可以解决问题,但是.. 经常这样做很烦人。
EDIT:
编辑:
I just found the cause. I had a bug in ApplicationWillTerminate method. So when i click stop button on Xcode window, app couldn't properly terminate and started to hang.
我刚刚找到原因。我在 ApplicationWillTerminate 方法中有一个错误。因此,当我单击 Xcode 窗口上的停止按钮时,应用程序无法正确终止并开始挂起。
check Activity Monitor to see if your app is on the list. force quit if possible.
检查活动监视器以查看您的应用程序是否在列表中。如果可能,强制退出。
回答by JRG
If you find your problem is due to zombie processes:
如果您发现问题是由于僵尸进程引起的:
ps -el | grep 'Z'(如之前的评论 https://stackoverflow.com/a/8104400/464289https://stackoverflow.com/a/8104400/464289)并且只想立即解决问题,您无需重新启动或杀死任何东西即可。只需重命名您的项目目标可执行文件:
- Click on the project on the left-hand pane
- Select Build Settingsin the middle pane
- Under 'Packaging' change 'Product Name' from $(TARGET_NAME) to $(TARGET_NAME).1
- 单击左侧窗格中的项目
- 在中间窗格中选择构建设置
- 在“包装”下,将“产品名称”从$(TARGET_NAME) 更改为 $(TARGET_NAME).1
Easy!
简单!
回答by David H
Well, no answers but at least one more test to make. Open Terminal and run this command: "ps-Ael | grep Z". If you get two entries, one "(clang)" and the other your app or company name, you're hosed - reboot.
好吧,没有答案,但至少要再做一项测试。打开终端并运行以下命令:“ps-Ael | grep Z”。如果您收到两个条目,一个是“(clang)”,另一个是您的应用程序或公司名称,那么您就被灌输了 - 重新启动。
If you are a developer, enter a short bug and tell Apple how absolutely annoying having to reboot is, and mention they can dup this bug to "rdar://10401934" which I just entered.
如果您是开发人员,请输入一个简短的错误并告诉 Apple 必须重新启动非常烦人,并提及他们可以将此错误复制到我刚刚输入的“rdar://10401934”。
David
大卫
回答by negrelja
- Close simulator
- Stop the app from running in xCode.
- Open Activity Monitorand search for a process runningwith your App NAME.
- Kill this process in Activity Monitor
- Rebuild your project and you should be all set
- 关闭模拟器
- 停止应用程序在 xCode 中运行。
- 打开Activity Monitor并搜索与您的App NAME一起运行的进程。
- 在活动监视器中终止此进程
- 重建你的项目,你应该一切都准备好了
回答by domthinks
Resetting the iOS Simulator fixed the error for me. Although this will remove all of the Apps you have in Simulator, it fixes the problem without having to restart the machine.
重置 iOS 模拟器修复了我的错误。虽然这将删除您在模拟器中拥有的所有应用程序,但它无需重新启动机器即可解决问题。
You can reset your iOS Simulator by doing the following:
您可以通过执行以下操作来重置您的 iOS 模拟器:
1) Go to the "iOS Simulator" menu, next to the Apple (?) logo on the far left of your main screen.
2) Select "Reset Content and Settings...".
3) Read the pop message and if you agree click "Reset" otherwise, click "Don't Reset".
1) 转到主屏幕最左侧 Apple (?) 标志旁边的“iOS Simulator”菜单。
2) 选择“重置内容和设置...”。
3) 阅读弹出消息,如果您同意点击“重置”,否则点击“不要重置”。
回答by Chris Burt-Brown
This error happens a lot to me, almost every time I test the app in the Simulator, forcing me to restart.
这个错误经常发生在我身上,几乎每次我在模拟器中测试应用程序时,都会迫使我重新启动。
Here's a workaround if you want to get some work done:
如果您想完成一些工作,这里有一个解决方法:
- Click your project in the Project navigator
- Go Target-> Info
- Add a key for Application does not run in backgroundand set to
YES
.
- 在项目导航器中单击您的项目
- 去目标->信息
- 为Application 不在后台运行添加一个键并设置为
YES
.
This will mean that when you press the home button in the simulator or quit the simulator, the app doesn't hang.
这意味着当您按下模拟器中的主页按钮或退出模拟器时,应用程序不会挂起。
Don't forget to change this setting back before distribution! Put it on your release checklist :)
不要忘记在分发之前更改此设置!把它放在你的发布清单上:)