372

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

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

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?

6
  • 2
    Any suggestions about what to do when this happens while testing on the device? I've tried restarting the device, Xcode. Commented Mar 6, 2011 at 23:36
  • 1
    I also tried deleting the app on the device, quitting all active apps (double click home, hold finger down on app icon, touch '-' sign) restarting Xcode, logging out and in again. Nothing works so far. Commented Mar 6, 2011 at 23:50
  • Try "Empty cache" in the XCode menu. That helps as well. Commented Mar 7, 2011 at 8:14
  • 3
    For everyone facing this issue, later figured out, this happens most of the times due to a bug in the code. Look for some piece of code that either takes a lot of execution time or takes the app into a loop. Commented Aug 22, 2011 at 6:45
  • 4
    When that happens I just kill the SimulatorBridge and quit the simulator. ps ax | grep SimulatorBridge
    – Elland
    Commented Feb 15, 2012 at 5:39

31 Answers 31

243

status: this has been seen as recently as Mac OS 10.8 and 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.

Mike Ash suggested

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.

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}'`

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.

details:

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

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.

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.

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.

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.

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.

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

28
  • 2
    Thanks for the thorough explanation of the new Lion/XCode4.2 behavior. It seems to happen more often when debugging two separate apps.
    – samkass
    Commented Oct 23, 2011 at 4:17
  • 2
    It's not just Lion. Still using Snow Leopard here and see this error lots of times since going XCode 4.2. (Used to use XCode 3.x until iOS SDK 5.0 was released.)
    – Jonny
    Commented Oct 24, 2011 at 16:40
  • 3
    Thanks for the info... This is happening insanely frequently for me recently... Twice in the last 10 minutes. Kinda hard to get a solid workflow going when I have to constantly restart. Well, off to restart my computer again.
    – Brad G
    Commented Dec 6, 2011 at 13:59
  • 1
    @smparkes: It actually seems to happen more frequently than before. I just change the bundleID and everything works again, but it's annoying when working with CoreData logic you're trying to debug. Less annoying than rebooting though, I'll admit.
    – Mike A
    Commented Feb 18, 2012 at 21:43
  • 2
    4.3.1 and it happened just now ... soooo annoying. For me, restarting the iPhone itself normally solves it, I do not need to restart my Mac. Its tarted happening with XCode 4.2 under Snow Leopard, sometime around September 2011 for me.
    – TheEye
    Commented Mar 13, 2012 at 14:54
162

Try quitting and restarting the simulator? If "worse comes to worst" you can always try restarting: in my experience this should fix it.

13
  • 45
    Ended up restarting the system! Still don't know what caused the issue though! Commented Apr 25, 2009 at 6:18
  • 6
    As comment below says, you can usually see the hung process in Activity Monitor and kill it there.
    – mxcl
    Commented Sep 5, 2010 at 18:29
  • 14
    I hate restarting :) Quitting the hung process worked for me: ps ax | grep Simulator will show your running apps, in my case it was MyApp.app that was hung.
    – BadPirate
    Commented Jan 28, 2011 at 0:08
  • 10
    I often get this in XCode 4.3. Restarting the application or quiting the simulator does not help. I have to restart the computer in order to make it work.
    – Øystein
    Commented Nov 14, 2011 at 14:20
  • 4
    If you get this while running in debug on device, you'll need to restart the device
    – wkhatch
    Commented Feb 6, 2012 at 22:34
70

I find I have started having this issue with Lion + Xcode 4.2. I have also experienced the issue in 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. :(

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.

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. :)

9
  • Thanks, I had 7 instances of 3 programs I was working on running as zombies. Commented Nov 15, 2011 at 7:16
  • 1
    Rebooting is sufficient but not necessary, as mentioned above. Also, there are sometimes zombies around that don't cause the problem, so looking for zombies this way isn't really a reliable measure. The only sure sign is the message in Xcode.
    – smparkes
    Commented Dec 22, 2011 at 21:18
  • Have you tried killing these zombie processes as root? I rebooted before I thought of doing it.
    – Ryan H.
    Commented Jan 13, 2012 at 16:34
  • 1
    @smparkes, yes, that is obvious based on this question which discusses this error message.
    – jyap
    Commented Jan 15, 2012 at 9:10
  • 1
    @HZC, yeah, you can't kill zombie processes even as root.
    – jyap
    Commented Jan 15, 2012 at 9:10
20

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.

1
  • 1
    same here, restarted the device and it went away. The simulator worked fine Commented May 15, 2011 at 12:25
15

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.

check Activity Monitor to see if your app is on the list. force quit if possible.

2
  • 2
    This fixed it for me! ps aux | grep Simulator Commented May 11, 2010 at 5:52
  • If it helps I create this bug while launching Leak Performance Tools
    – IssamTP
    Commented Dec 17, 2010 at 18:01
14

If you find your problem is due to zombie processes:

ps -el | grep 'Z'
(as in the earlier comment https://stackoverflow.com/a/8104400/464289) and just want to fix the problem immediately, you can do so without rebooting or killing anything. Just rename your project target executable:

  1. Click on the project on the left-hand pane
  2. Select Build Settings in the middle pane
  3. Under 'Packaging' change 'Product Name' from $(TARGET_NAME) to $(TARGET_NAME).1

Easy!

3
  • this didn't work for me, got the same error I get: Provisioning profile 'mataleao2' specifies the Application Identifier 'au.com.mataleao' which doesn't match the current setting 'au.com.mataleao-1'
    – sapatos
    Commented Aug 8, 2012 at 11:00
  • Are you testing on the simulator or on the iPhone?
    – JRG
    Commented Aug 8, 2012 at 11:53
  • i'm testing on iphone only, teh functionality i'm testing will only work on the phone
    – sapatos
    Commented Aug 10, 2012 at 8:32
7

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.

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.

David

5

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.

You can reset your iOS Simulator by doing the following:

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

2
  • 3
    Does not help one bit, instead you lose all your content / apps / photos / contacts
    – strange
    Commented Oct 15, 2011 at 8:16
  • 1
    @strange it's simulator. anyway it doesn't contain any important information. :) Commented Jan 19, 2012 at 11:16
5
  1. Close simulator
  2. Stop the app from running in xCode.
  3. Open Activity Monitor and search for a process running with your App NAME.
  4. Kill this process in Activity Monitor
  5. Rebuild your project and you should be all set
1
  • The process seems to be immune from being Killed in Activity Monitor, even with "Force Quit"
    – Ferruccio
    Commented Jan 15, 2012 at 12:44
4

I had a recursive setter that blew through the stack and killed my app in such a way that I had to power boot my iPad. It was provable with a fix in the code.

4

I had the problem @jyap mentions with zombie processes. The only way to clear them was to reboot. However, I noticed that my friends working on the same project would get the same issue but could kill the simulator without creating a zombie process. I completely uninstalled Xcode and re-installed it, and while I still get the error, it doesn't create zombie processes, so I don't have to reboot.

Before I did that, I was using this really ugly workaround: change your app ID and run again. You end up with junk copies of the app in the simulator, but you can put off rebooting for a while.

4

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 background and set to 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 :)

2
  • 1
    This is dangerous, since it prevents you from testing backgrounded behaviour until you remember to change it back.
    – tc.
    Commented Feb 16, 2012 at 19:33
  • @tc: Yes, I agree. However, if you are forced to restart every single time you run your iOS app (which was what I was having) then this may still be better than the alternative. Commented Feb 16, 2012 at 20:58
4

If this happens when testing on the iPhone. Just restart the phone. From what I have been told the phone or simulator still believes there is an instance of the app running, so when it was last run it had not terminated correctly do to either an error in your code or the phone/simulator just wanted to have a moan.

4

I got this error while debugging my app on an iPhone 4. Hard rebooting the iPhone solved my problem. (Powering off the iPhone hung...)

I did not have any zombie process on my mac and rebooting the mac did not solve the problem.

Maybe this bug can manifest itself on both the simulator and actual devices???

4

Restarted the Device, Worked! :D

Thanks Everyone for the great suggestions.

3

I just had this error. I tried restarting the simulator and Xcode but my project would only work again after a clean and build. No idea what caused it.

3

I had same problem and solved it by doing the following

  • Deleting the app from the device,
  • Disconnecting the device from Mac,
  • Turning the device off and back on,
  • Quitting and relaunching Xcode,
  • Quitting Instruments,
  • Finally, Clean and Build again.

I also did one more thing, because Xcode is configured to use iOS 5.0 and my project uses iOS 4.3

  • Remove all frameworks and add them again.
1
  • Question is for Simulator. not for device.
    – viral
    Commented Apr 16, 2012 at 11:21
3

Alternate workaround:

  • Give your app a new identifier. If it's called com.foobar.myapp, call it com.foobar.myapp01

You lose all data in the app as it's actually a new app running as far as the iPhone simulator is concerned. This may or may not be more annoying than rebooting - just wanted to add it to the list.

3

The Cause

Running your app in the Simulator before the previously running app has completely stopped.

The Fix

Wait until you see the Stop button become active again before running again.

(I'm using Xcode 4.2.1. This problem happened very frequently when I upgraded to OS X Lion).

1
  • Just been having this error again. I tried everything and finally an iPad restart fixed it. Commented Jul 17, 2012 at 16:37
2

Fixed by rebooting my phone after deleting the app, then rebuilding it clean and running again. Works fine now.

Weird.

2

No rebuild or reinstall needed for my issue, and in my case the error appeared when trying to run the app on the iPhone. Simulator worked fine.

Solution: Delete app off phone, do a cold restart of phone and now all is well.

2

Happened a lot for me with Xcode 4.2.1 on Lion. Updated to 4.3.2 and it doesnt happen anymore. Glad they fixed it.

2

Mike Ash posted a solution (god bless him!) that doesn't require a reboot. Just run:

launchctl list|grep UIKitApplication|awk '{print $3}'|xargs launchctl remove

The above command lists out all launchd jobs, searches for one with UIKitApplication in the name (which will be the job corresponding to your app that's improperly sticking around), extracts the name, and tells launchd to get rid of that job.

1
  • I had many chances to test this (sigh). Sometimes it works, sometimes I have to reboot my iPhone, or even my Mac (the command above says "process not found").
    – Jano
    Commented May 21, 2012 at 20:04
2

I think this is caused by force-quitting your app on the iPhone prior to pressing the stop button in Xcode. Sometimes when you press the stop button in Xcode, then it takes extra time to quit the app if it hung. But just be patient, it will eventually quit most of the time.

1

You may alloc variable in function or tab. It will dealloc if your function or tab is quit. So you must declarate it member variable or global variable.

1

I was getting this error all the time until I stopped trusting the "Stop" button in the Run dialog box. Now that I always hit stop in the toolbar before trying to run, I have yet to encounter any zombie processes.

0

Oh my - I tried EVERYTHING listed above and in other posts. Re-installed Xcode, rebooted my machine, copied all the missing files into the right folders... Eventually I backed-up my iphone, wiped it and restored it, and it worked!

I think what may have been the cause from reading in and around this was disconnecting my iphone white it was running with performance tools catching leaks. Or some such thing.

Aaaah, big sigh of relief.

0

In most worst condition Reset content and setting of iOS Simulater, and most of the time in my case, quitting XCode along with simulator, always work works for me with XCode4.6 (that frequently get hanged)

0

I faced this kind of issue once in my case here's what i did

  1. Delete the app from simulator.
  2. Delete the derived data folder.
  3. Perform a clean action in the project by selecting the product menu - clean
  4. Reset the simulator.
  5. Quit Xcode.
  6. Try running the project now if its working fine else go to step 7
  7. Repeat all steps from 1 to 5 and then restart your machine.

In most of the cases i got it running at step 6 extreme cases i had to restart my machine.

0

This error used to occur in older versions of the iOS Simulator because older instances of a job in another device that was shutting down could collide with the new instance.

iOS 6.0 and later should not experience issues like this because iOS 6.0 introduced the usage of bootstrap subsets, and iOS 7.0 introduced the usage of a dedicated bootstrap server (launchd_sim) which is completely isolated from the host's bootstrap server.

Not the answer you're looking for? Browse other questions tagged or ask your own question.