> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xenoci.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Exec

> box exec runs a shell command in your project folder on the Mac. Files the command writes to $BOX_OUT come back to .box/out/<job>/

> [!NOTE]
>
> **When to use it.**
>
> * Your project has its own build or release script (an archive, fastlane, a code generator)
> * You need a file only the Mac can make, such as an IPA or an `.xcarchive`
> * You want to see what is on the Mac: `xcodebuild -version`, `xcrun simctl list`

## Run a command and get a file back

BoxDemo keeps an archive script in `scripts/archive.sh` that makes an unsigned `build/BoxDemo.ipa`. Copying it into `$BOX_OUT` brings it back

```bash theme={"system"}
box exec 'xcodegen generate && bash scripts/archive.sh && cp build/BoxDemo.ipa "$BOX_OUT"/'
```

<video controls muted loop playsInline autoPlay preload="metadata" poster="/media/docs/ios-exec-poster.webp" src="https://mintcdn.com/xenoci/ZFKGlbE4Q2bw14Om/media/docs/ios-exec.mp4?fit=max&auto=format&n=ZFKGlbE4Q2bw14Om&q=85&s=7d5a857e09fe589ff64906fff808bf12" width="1280" height="778" />

box exec running xcodebuild -showsdks on the Mac

```text theme={"system"}
box: queue: job bj_STF4GX2ZsG8dmBWM (exec, ios, $0.05/min) submitted
box: status: running
box: machine: source unpacked
** ARCHIVE SUCCEEDED **
IPA: build/BoxDemo.ipa
box: status: succeeded
box: results: saved to ./.box/out/bj_STF4GX2ZsG8dmBWM/ (BoxDemo.ipa, exec.log)
box: bj_STF4GX2ZsG8dmBWM succeeded, 60s billed, $0.05
```

> [!NOTE]
>
> Job `bj_STF4GX2ZsG8dmBWM` on the production Mac: 60 s billed, \$0.05

```bash theme={"system"}
        0  Payload/
        0  Payload/BoxDemo.app/
    79800  Payload/BoxDemo.app/BoxDemo
      761  Payload/BoxDemo.app/Info.plist
        8  Payload/BoxDemo.app/PkgInfo
```

## Good to know

* The command runs in a copy of your project on the Mac. A file written anywhere else does not come back; write it to `$BOX_OUT`. A `box-out/` folder inside the project comes back too
* The command’s whole output is saved as `exec.log`
* The command’s own exit code decides the job: anything but 0 is a failed job and box exits with 1
* box keeps no signing files and has no secrets option; the command sees only your project folder. `.env` is never uploaded
* Add `--platform android` to run it on the Android machine instead


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.