Skip to main content
command CX Codex GP ChatGPT official · OpenAI

build-and-run-macos-app — Codex command: what it does, how to install

Generates or updates the build_and_run.sh script and connects the Run button in the Codex app. Built for macOS targets using Xcode or SwiftPM.

Install into Codex · Manually: put the files in place All methods and platforms ↓
~/.codex/prompts/build-and-run-macos-app.md
Open on GitHub

What build-and-run-macos-app does

The command inspects the project structure to detect an Xcode workspace, an Xcode project, or a SwiftPM package. If the repository lacks git tracking, it runs git init at the project root. Nested git initialization is blocked.

Its main job is maintaining script/build_and_run.sh. The generated script stops any running instance, builds the target, and runs the fresh binary. For AppKit or SwiftUI GUI applications built with SwiftPM, the script packages a local .app bundle and starts it via /usr/bin/open -n. Command-line tools run directly.

The script follows the contract required for .codex/environments/environment.toml. Optional flags include --debug, --logs, --telemetry, and --verify. These modes run only when requested. Any build or launch errors produce a concise summary.

What it helps with

  • Wire the Codex app Run button to build macOS targets
  • Create a build-and-relaunch script for Xcode and SwiftPM projects
  • Bundle SwiftPM SwiftUI applications into local .app packages
  • Add debug and log-checking modes to script/build_and_run.sh

Example prompts for the agent

  • /build-and-run-macos-app mode:run
  • /build-and-run-macos-app project:MyApp.xcodeproj scheme:MyApp mode:debug
  • /build-and-run-macos-app product:MyCLI mode:logs

How to install build-and-run-macos-app

Manually: put the files in place

~/.codex/prompts/build-and-run-macos-app.md

Call it with /prompts:build-and-run-macos-app. Codex marks this format deprecated in favour of skills

Questions about build-and-run-macos-app

How to install build-and-run-macos-app in Codex?

Save the file to ~/.codex/prompts/build-and-run-macos-app.md. Once saved, the command is ready to use in Codex.

What does the build-and-run-macos-app command do?

It detects your project layout, writes script/build_and_run.sh, and updates .codex/environments/environment.toml. The script kills previous instances, triggers a fresh build, and runs the application.

How does it handle SwiftPM graphical applications?

Standalone CLI tools run directly from their executable path. For AppKit or SwiftUI GUI applications, the script creates a project-local .app bundle and starts it through /usr/bin/open -n.

Source text

build-and-run-macos-app.md · MIT
# /build-and-run-macos-app

Create or update the project-local macOS `build_and_run.sh` script, wire the
Codex app Run button, then use that script as the default build/run entrypoint.

## Arguments

- `scheme`: Xcode scheme name (optional)
- `workspace`: path to `.xcworkspace` (optional)
- `project`: path to `.xcodeproj` (optional)
- `product`: SwiftPM executable product name (optional)
- `mode`: `run`, `debug`, `logs`, `telemetry`, or `verify` (optional, default: `run`)
- `app_name`: process/app name to stop before relaunching (optional)

## Workflow

1. Detect whether the repo uses an Xcode workspace, Xcode project, or SwiftPM package.
2. If the workspace is not inside git yet, run `git init` at the project root so Codex app git-backed features unlock.
3. Create or update `script/build_and_run.sh` so it always stops the current app, builds the macOS target, and launches the fresh result.
4. For SwiftPM, keep raw executable launch only for true CLI tools; for AppKit/SwiftUI GUI apps, create a project-local `.app` bundle and launch it with `/usr/bin/open -n`.
5. Support optional script flags for `--debug`, `--logs`, `--telemetry`, and `--verify`.
6. Follow the canonical bootstrap contract in `../skills/build-run-debug/references/run-button-bootstrap.md` for the exact script shape and `.codex/environments/environment.toml` format.
7. Run the script in the requested mode and summarize any build, script, or launch failure.

## Guardrails

- Do not initialize a nested git repo inside an existing parent checkout.
- Do not leave stale `Run` actions pointing at old script paths.
- Keep the no-flag script path simple: kill, build, run.
- Use `--debug`, `--logs`, `--telemetry`, or `--verify` only when the user asks for those modes.

© OpenAI · MIT · openai/plugins

Similar slash commands

All slash commands for Agent setup: memory, context, orchestration →

From the same set420

The whole set →
canva-implement-feedback This skill reads every comment thread on a Canva design, makes the clear-cut edits through the API, and lists what still needs a human. CX Codex GP ChatGPT ★ 7,604repo stars canva-design-feedback This skill reviews Canva designs and returns ordered feedback on hierarchy, copy, spacing, readability, and accessibility. It helps when a slide, poster, or flyer needs a clear critique. CX Codex GP ChatGPT ★ 7,604repo stars canva-bulk-create Turns a table of data into one Canva design per row by autofilling a brand template. Useful when you need product cards or posts built from a CSV in one go. CX Codex GP ChatGPT ★ 7,604repo stars fix-codesign-error Inspects a macOS signing or entitlement failure and lays out the shortest fix path. Useful when a build refuses to launch or fails validation. CX Codex GP ChatGPT ★ 7,604repo stars boltz-small-molecule-screen Docks a supplied SMILES library against a target, ranks the hits, and returns ADME numbers for every molecule. CX Codex GP ChatGPT ★ 7,604repo stars boltz-protein-screen Ranks existing proteins, peptides, antibodies and nanobodies against a target through the Boltz API. Not for designing new proteins or screening small molecules. CX Codex GP ChatGPT ★ 7,604repo stars airtable-overview This skill gives the agent context on how Airtable is structured: bases, tables, fields, records, views, automations and interfaces. Useful before writing code against a base. CX Codex GP ChatGPT ★ 7,604repo stars airtable-cli This skill lets Codex inspect and change Airtable data through airtable-mcp. Use it for bases, tables, fields, records, searches, and filters. CX Codex GP ChatGPT ★ 7,604repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor