launchctl remove on the stuck UIKitApplication entry, or killing the user launchd via a secondary admin account.Why this happens
When you stop debugging an app in Xcode without properly terminating it, the process can enter a zombie state (status Z in ps). The debugger hands the process off to launchd, but a long-standing bug in the bootstrap name server (inside launchd) fails to clean up the Mach port registration for the app’s bundle identifier. The next time you try to launch the same app, the bootstrap server sees the stale entry and refuses the new registration, producing:
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”.
The issue appears more frequently when the debugger detaches after a crash or breakpoint stop. It affects both simulator and device runs, though the simulator is more common in daily workflows.
How to fix it
1. Restart the simulator (quickest)
Quit the Simulator app completely (⌘Q), then launch it again from Xcode. This clears the per-user bootstrap namespace for the simulator runtime and resolves the majority of occurrences.
2. Remove the stale bootstrap entry with launchctl
Open Terminal and run:
launchctl list | grep UIKitApplication | awk '{print $3}' | xargs launchctl remove
This lists all UIKitApplication entries registered with the user launchd, extracts their labels, and asks launchd to remove them. It works for many developers but not all; if the entry is already gone or stuck deeper in the bootstrap server, the command returns without effect.
3. Kill the user launchd via a secondary admin account (most reliable)
When the above steps fail, the only guaranteed fix is to restart the user launchd instance without a full reboot. You need a second administrator account on the Mac (create one in System Settings → Users & Groups if you don’t have one).
- Log out of your main account.
- Log in as the secondary admin user.
- Open Terminal and find the main user’s
launchdPID:
bash
ps aux | egrep 'your_main_username .*[0-9] /sbin/launchd' | awk '{print $2}'
- Kill that process:
bash
sudo kill -9 <PID_FROM_STEP_3>
- Log out of the secondary account and log back into your main account. The user
launchdrestarts with a clean bootstrap server.
Note: This procedure is faster than a reboot and has been the standard workaround since Xcode 4.2 / OS X Lion.
4. For device runs: disconnect and reconnect
If the error appears when running on a physical device, simply unplug the Lightning/USB-C cable and plug it back in. This forces lockdownd and the device-side bootstrap to reset the app’s registration.
How to prevent it
- Stop the app via Xcode’s Stop button (⌘.) instead of letting it crash or sit at a breakpoint for long periods.
- Avoid force-quitting the simulator while an app is being debugged; use the simulator’s Hardware → Shut Down if you must close it.
- Keep Xcode and macOS updated; Apple has mitigated the underlying
launchdbug in newer releases, though it can still surface. - Use a dedicated development user account if you frequently hit this issue; isolating the bootstrap namespace reduces collisions.
FAQ
Does this error mean my code is broken?
No. It is an environment issue in launchd‘s bootstrap server, not a compile-time or runtime error in your Swift/Objective-C code.
Will erasing the simulator device help?
Erasing the simulator (Device → Erase All Content and Settings) clears the app sandbox but does not reset the user launchd bootstrap namespace, so the stale registration often persists.
Is there a permanent fix from Apple?
Apple has improved the situation in recent macOS/Xcode versions, but the root cause lives in the user-space launchd bootstrap server. A full fix would require a launchd update; until then, the workarounds above remain the standard solutions.
Parts of this guide are adapted from content licensed under CC BY-SA 4.0; this article is shared under the same license.