Debugging XPC helpers
Thecontainer system uses XPC helpers for various services. You can attach a debugger to these helpers to troubleshoot issues or understand their behavior.
Finding service labels
First, identify the launchd service labels for the XPC helpers you want to debug:Attaching the debugger
To debug a specific XPC helper, use theCONTAINER_DEBUG_LAUNCHD_LABEL environment variable:
Debug a specific service
To debug a single service by its exact label:com.apple.container.container-runtime-linux.test will wait for the debugger to attach.
Debug multiple services by prefix
To debug all services matching a label prefix:com.apple.container.container-runtime-linux will wait for the debugger.
Services configured to wait for a debugger will pause at startup until you attach a debugger to them.
Debugging workflow
Here’s the complete workflow for debugging an XPC helper:Trigger service launch
Run the command that will launch the service you want to debug. For a runtime helper:The command will appear to hang:This is expected - the service is waiting for the debugger.
Attach debugger
In Xcode or your debugger of choice, attach to the waiting process. The process will resume once the debugger is attached.
Common debugging scenarios
Debugging the runtime helper
To debug container startup and execution:Debugging the network helper
To debug network configuration:Debugging the image helper
To debug image operations:Debugging the API server
To debug the main API server:Development tips
Using the pre-commit hook
Install the pre-commit hook to ensure your changes have correct formatting and license headers:git commit.
The pre-commit hook helps maintain code quality and consistency across the project.
Project location considerations
Due to a vmnet framework bug, avoid placing your project under~/Documents or ~/Desktop:
If you use
make install, this limitation doesn’t apply since the binaries are installed to /usr/local.Cleaning build artifacts
When switching between debug and release builds, or after major changes:Using local dependencies
When working on features that span multiple repositories:- Clone related repositories (Containerization, container-builder-shim) alongside your container clone
- Use
swift package editto link to local copies - Make changes across repositories
- Test thoroughly with
make test integration - Revert to normal dependencies before committing
Debugging with logging
Container services use the macOS unified logging system. View logs using:Structured logging provides valuable context for debugging without requiring a debugger attachment.
Testing with different macOS versions
While macOS 26 is recommended, you may need to test on macOS 15:- Be aware of vmnet limitations (no container-to-container networking)
- Network configuration may require manual adjustment
- Some features may not be available