macOS Runtime Debugger
Before invoking Apple-only binaries, confirm the execution context is macOS. From Windows or Linux, run those steps in a Mac SSH project or through an already configured remote transport; do not retry missing Apple binaries locally.
Reuse the project's existing build/run entrypoint first. For one-shot build,
launch, log, or debug tasks, use the smallest existing command that proves the
requested outcome without adding durable project files. Bootstrap
script/build_and_run.sh through /macos-runtime-debug only when the user asks
for a reusable run loop or no adequate entrypoint exists and repeated use makes
one worthwhile.
Workflow
- Discover project shape and existing entrypoints:
git rev-parse --show-toplevel 2>/dev/null || pwd
find . -name '*.xcworkspace' -o -name '*.xcodeproj' -o -name 'Package.swift'
Read repository guidance and inspect existing scripts, schemes, package
products, and host actions before introducing another entrypoint.
- Resolve and prefer the established runnable target/process:
- Xcode: list schemes and prefer the app-producing scheme unless named.
- SwiftPM CLI: run the executable.
- SwiftPM AppKit/SwiftUI GUI: stage a project-local
.app bundle and launch with /usr/bin/open -n; do not run as a raw executable.
- For a one-shot task, run that entrypoint directly and avoid changing project
structure merely to make the command repeatable.
- If a durable loop is explicitly requested or clearly useful because no
adequate entrypoint exists, invoke
/macos-runtime-debug and follow
references/run-button-bootstrap.md. Do not duplicate its full snippets.
- Add or update
.codex/environments/environment.toml only when the user asks
for a Codex Run action. Preserve unrelated existing actions.
- When the bootstrap script is the selected entrypoint, run the requested mode:
./script/build_and_run.sh
./script/build_and_run.sh --debug
./script/build_and_run.sh --logs
./script/build_and_run.sh --telemetry
./script/build_and_run.sh --verify
- Classify failures as compiler, linker, signing, build settings, missing SDK/toolchain, entrypoint/script bug, or runtime launch. Quote the smallest useful error.
Bootstrap Script Requirements
- Apply these requirements only when
/macos-runtime-debug bootstraps or
refreshes script/build_and_run.sh.
- Keep the script outside app source in
script/build_and_run.sh.
- Xcode projects use
xcodebuild.
- SwiftPM command-line tools use
swift build then executable launch.
- SwiftPM GUI apps create
dist/<AppName>.app, copy the binary to Contents/MacOS/, generate minimal Info.plist (APPL, executable, identifier, name, minimum system version, NSApplication), then launch with /usr/bin/open -n.
- For GUI logs/telemetry, launch the bundle first, then stream unified logs.
--verify should confirm process existence with pgrep -x <AppName>.
Debugging
- Use
--logs/--telemetry for config, entitlements, sandbox, and action-event proof.
- If a SwiftPM GUI bundle launches but does not foreground, check
NSApp.setActivationPolicy(.regular) and NSApp.activate(ignoringOtherApps: true).
- Use
--debug or direct lldb for symbolized crash debugging.
- Switch to
macos-telemetry-probe when verifying specific window/sidebar/menu/menu-bar actions.
- Use Xcode-aware MCP only when explicitly requested and it fits macOS discovery/debugging; fall back to shell when it does not.
Guardrails
- Do not initialize source control merely to build, run, or debug an app.
- Do not replace an established project entrypoint with the bootstrap script
unless the user explicitly requests that change.
- A bounded one-shot command is appropriate for a one-shot task; create durable
automation only when it will be reused or the user requests it.
- Do not write Codex environment config unless the user requests a Run action
and the target entrypoint already exists.
- Do not describe mobile/simulator workflows as macOS workflows.
- Do not claim UI state you cannot inspect.
Output
Report detected project type, existing entrypoint selected, command run,
build/launch result, any durable artifacts explicitly created, top blocker if
failed, and the smallest next action.
1---2name: macos-runtime-debugger3description: macOS app runtimes: build, launch, and debug Xcode or SwiftPM GUI/CLI targets with shell-first workflows; diagnose compiler, linker, startup, log, and telemetry failures; exclude iOS Simulator work.4---56# macOS Runtime Debugger78Before invoking Apple-only binaries, confirm the execution context is macOS. From Windows or Linux, run those steps in a Mac SSH project or through an already configured remote transport; do not retry missing Apple binaries locally.910Reuse the project's existing build/run entrypoint first. For one-shot build,11launch, log, or debug tasks, use the smallest existing command that proves the12requested outcome without adding durable project files. Bootstrap13`script/build_and_run.sh` through `/macos-runtime-debug` only when the user asks14for a reusable run loop or no adequate entrypoint exists and repeated use makes15one worthwhile.1617## Workflow18191. Discover project shape and existing entrypoints:20 ```bash21 git rev-parse --show-toplevel 2>/dev/null || pwd22 find . -name '*.xcworkspace' -o -name '*.xcodeproj' -o -name 'Package.swift'23 ```24 Read repository guidance and inspect existing scripts, schemes, package25 products, and host actions before introducing another entrypoint.262. Resolve and prefer the established runnable target/process:27 - Xcode: list schemes and prefer the app-producing scheme unless named.28 - SwiftPM CLI: run the executable.29 - SwiftPM AppKit/SwiftUI GUI: stage a project-local `.app` bundle and launch with `/usr/bin/open -n`; do not run as a raw executable.303. For a one-shot task, run that entrypoint directly and avoid changing project31 structure merely to make the command repeatable.324. If a durable loop is explicitly requested or clearly useful because no33 adequate entrypoint exists, invoke `/macos-runtime-debug` and follow34 `references/run-button-bootstrap.md`. Do not duplicate its full snippets.355. Add or update `.codex/environments/environment.toml` only when the user asks36 for a Codex Run action. Preserve unrelated existing actions.376. When the bootstrap script is the selected entrypoint, run the requested mode:38 ```bash39 ./script/build_and_run.sh40 ./script/build_and_run.sh --debug41 ./script/build_and_run.sh --logs42 ./script/build_and_run.sh --telemetry43 ./script/build_and_run.sh --verify44 ```457. Classify failures as compiler, linker, signing, build settings, missing SDK/toolchain, entrypoint/script bug, or runtime launch. Quote the smallest useful error.4647## Bootstrap Script Requirements4849- Apply these requirements only when `/macos-runtime-debug` bootstraps or50 refreshes `script/build_and_run.sh`.51- Keep the script outside app source in `script/build_and_run.sh`.52- Xcode projects use `xcodebuild`.53- SwiftPM command-line tools use `swift build` then executable launch.54- SwiftPM GUI apps create `dist/<AppName>.app`, copy the binary to `Contents/MacOS/`, generate minimal `Info.plist` (`APPL`, executable, identifier, name, minimum system version, `NSApplication`), then launch with `/usr/bin/open -n`.55- For GUI logs/telemetry, launch the bundle first, then stream unified logs.56- `--verify` should confirm process existence with `pgrep -x <AppName>`.5758## Debugging5960- Use `--logs`/`--telemetry` for config, entitlements, sandbox, and action-event proof.61- If a SwiftPM GUI bundle launches but does not foreground, check `NSApp.setActivationPolicy(.regular)` and `NSApp.activate(ignoringOtherApps: true)`.62- Use `--debug` or direct `lldb` for symbolized crash debugging.63- Switch to `macos-telemetry-probe` when verifying specific window/sidebar/menu/menu-bar actions.64- Use Xcode-aware MCP only when explicitly requested and it fits macOS discovery/debugging; fall back to shell when it does not.6566## Guardrails6768- Do not initialize source control merely to build, run, or debug an app.69- Do not replace an established project entrypoint with the bootstrap script70 unless the user explicitly requests that change.71- A bounded one-shot command is appropriate for a one-shot task; create durable72 automation only when it will be reused or the user requests it.73- Do not write Codex environment config unless the user requests a Run action74 and the target entrypoint already exists.75- Do not describe mobile/simulator workflows as macOS workflows.76- Do not claim UI state you cannot inspect.7778## Output7980Report detected project type, existing entrypoint selected, command run,81build/launch result, any durable artifacts explicitly created, top blocker if82failed, and the smallest next action.