iOS - 在模拟器上测试时出现奇怪错误 [英] iOS - strange error when testing on simulator

查看:168
本文介绍了iOS - 在模拟器上测试时出现奇怪错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在模拟器上测试我的应用程序,当它点击UIAlertView的按钮时崩溃了。我在那里停止调试,对代码进行了一些更改并再次构建了应用程序。现在,当我运行应用程序时,我在控制台中收到此错误

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


无法注册com.myApp.debug引导服务器。错误:未知错误代码。
这通常意味着此进程的另一个实例已在运行或挂在debugger.Program接收信号: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?

推荐答案

状态:这最近被视为Mac OS 10.8和Xcode 4.4。

status: this has been seen as recently as Mac OS 10.8 and Xcode 4.4.

tl; dr:这可能发生在两个上下文中:运行时设备和在模拟器上运行时。在设备上运行时,断开连接并重新连接设备似乎可以解决问题。

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.

Mike Ash建议

launchctl list|grep UIKitApplication|awk '{print $3}'|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.

否则,解决此问题的唯一已知方法是重新启动用户launchd。重新启动会做到这一点,但有一个不那么激烈/更快的方式。您需要创建另一个管理员用户,但您只需要执行一次。当事情楔入时,以自己的身份注销,以该用户身份登录,并终止属于您的主要用户的launchd,例如

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.,

sudo kill -9 `ps aux | egrep 'user_id .*[0-9] /sbin/launchd' | awk '{print $2}'`

用你的主用户名代替 user_id 。当普通用户返回到理智的状态时再次登录。有点痛苦,但不如完全重启。

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.

详细信息:

Lion / Xcode 4.2已经开始更频繁地发生这种情况。 (就个人而言,我之前从未在组合之前看到过它。)

This has started happening more often with Lion/Xcode 4.2. (Personally, I never saw it before that combination.)

该错误似乎是在launchd中,当调试器停止调试时,它继承了作为子进程的app进程杀了它。这通常由应用程序变为僵尸发出信号,其过程状态为Z in ps。

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的。这(在我理解的范围内)将app id映射到mach端口。当触发错误时,应用程序会死,但不会从引导服务器的名称服务器映射中清除,因此,引导服务器拒绝允许以相同名称注册该应用程序的另一个实例。

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的短缺。

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.

看起来这个错误是由Xcode,gdb和用户启动之间的错误引发的。我只是通过在iphone模拟器中运行一个应用程序重复楔子,让它在gdb中停止,然后进行构建并运行到ipad模拟器。它似乎对切换模拟器(iOS 4.3 / iOS 5,iPad / iPhone)很敏感。它不会一直发生,但是当我经常切换模拟器时这种情况经常发生。

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.

在你登录时杀死启动会搞砸你的会话。注销并重新登录并不会导致用户启动; OS X保持现有流程。重启将解决问题,但这很痛苦。上面的说明更快。

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.

我向Apple,FWIW提交了一个错误。 rdar:// 10330930

I've submitted a bug to Apple, FWIW. rdar://10330930

这篇关于iOS - 在模拟器上测试时出现奇怪错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆