Skip to content

S06-14 - The Xcode Image

Purpose: How an image gets full Xcode and the simulator runtimes from the host, as a read-only disk the host builds, and who runs Xcode’s first launch.

Requirements: FR06-native-toolsFR06-native-tools: Native guest toolsAgent tool calls run tools native to the guest operating system (on macOS guests: Homebrew packages, Xcode command line tools, optionally full Xcode)., SEC02-no-host-fs-shareSEC02-no-host-fs-share: No host filesystem sharingNo host directory is mounted into the guest, read-only or otherwise., SEC04-no-guest-secretsSEC04-no-guest-secrets: No secrets in the guestThis includes the model credential., SEC05-default-denySEC05-default-deny: Default-deny egress, enforced on the hostOnly allowlisted hostnames are reachable., SEC09-host-policySEC09-host-policy: Policy is held on the hostThe guest cannot read or change policy., SEC12-least-privilegeSEC12-least-privilege: Least privilege on the hostNo root or administrator rights at run time and no extra host user accounts., SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped., SEC15-no-guest-disk-mountSEC15-no-guest-disk-mount: The host never mounts a guest-written diskA disk image is guest-written once a guest has run with it attached, and every copy or clone of a guest-written image is guest-written too.

Tests: C09-guest-and-sessionsC09-guest-and-sessions: Guest and SessionsThe test cases for what a project user can reach inside the guest, wb-guestd's update and the guest clock, the shared toolchain prefix, the guest admin password, and the session lifecycle., C11-host-daemonsC11-host-daemons: Host Daemons, Audit, and DisksThe test cases for the host daemons' own checks: wb-vmd's device set and slots, the image build bundle, supervision, the accounting and event channels, the daemon log pipes, the audit writer, free space, and the data…

Brief: B194-xcode-imageB194-xcode-image: How does an image get full Xcode and the simulator runtimes?From the host.

Full Xcode isn’t in the base image (S06-01-image-layersS06-01-image-layers: Image Layers and the Toolchain PrefixThe layers of a guest image, and the toolchain prefix that project layers install into., “Layers”). A named image whose recipe asks for Xcode (S06-17-named-imagesS06-17-named-images: Named Images and RecipesThe build of a named image from a recipe on a clone of the sealed base.) gets it in an Xcode step. The recipe holds only a flag that asks for Xcode, never a path. Recipes come from user settings only, never from a repository’s .wraithbox/ (S06-17-named-imagesS06-17-named-images: Named Images and RecipesThe build of a named image from a recipe on a clone of the sealed base., SEC09-host-policySEC09-host-policy: Policy is held on the hostThe guest cannot read or change policy.).

The Xcode step clones the sealed base image, installs Xcode and the runtimes, and is sealed. After wb-vmd-layer exits, wb-hostd takes that sealed result into a new, empty build bundle as in S06-02-image-buildS06-02-image-build: Image BuildHow wb image build makes a guest image: the build VM, its two provisioning stages, terminfo, sealing, and storage., “Taking the sealed image”. It is never listed as an image. The recipe’s own steps then run on it, in wb-vmd-recipe, which has no Xcode flag, so they can use Xcode. The image they seal is the parent that the Claude Code layer clones (S06-01-image-layersS06-01-image-layers: Image Layers and the Toolchain PrefixThe layers of a guest image, and the toolchain prefix that project layers install into., “The Claude Code layer”). When the recipe has no other step, the Xcode step’s sealed result is that parent.

The image build copies the Xcode installed on the host. It never downloads Xcode, because Apple serves Xcode only after an Apple ID sign-in, and the build has none. It never takes Xcode from the network in the guest either.

The source is /Applications/Xcode.app. Its real path has to be a directory directly in /Applications whose name ends in .app, so a link from Xcode.app to Xcode-27.0.app works. Any other source is refused with xcode-not-found.

The simulator runtimes come from the host too. The guest never downloads one:

The user exports each runtime on the host, with no Apple ID (X06-guest-xcodeX06-guest-xcode: Guest users and XcodeCan builds and simulators run for a guest user without a GUI login?):

Terminal window
xcodebuild -downloadPlatform iOS -exportPath "<data>/xcode-runtimes"

The command downloads every runtime Apple lists for the platform, and writes each as an exported runtime, which is a directory (X06-guest-xcodeX06-guest-xcode: Guest users and XcodeCan builds and simulators run for a guest user without a GUI login?, “Follow-up (I624I624 (closed): S06-14-xcode-image: measure the host export, signature checks and offline import of Xcode and runtimesFrom #194 (S06-14-xcode-image, the Xcode image variant).)”). For iOS 27.2 it wrote two of about 8.3 GB each, one general runtime and one for a newer device. After the export, the host listed both as installed and Ready, 15.5 GB in all. Wraith Box neither uses nor removes them. An exported runtime looks like this:

iphonesimulator_27.2_24B8117.exportedBundle/
ExportedMetadata.plist
Restore/141-80522-035.dmg
Restore/BuildManifest.plist
Restore/Restore.plist
Restore/Firmware/141-80522-035.dmg.cryptex_info
Restore/Firmware/141-80522-035.dmg.root_hash
Restore/Firmware/141-80522-035.dmg.trustcache

The build takes the exported runtimes in <data>/xcode-runtimes. With none there, the image has Xcode and no simulator runtime, and wb image build says so. wb-hostd never runs xcodebuild on the host.

Each entry in the folder, and each entry under it, is opened with O_NOFOLLOW, and the build refuses:

  • an entry that isn’t a directory named <platform>_<version>_<build>.exportedBundle, with a lowercase platform such as iphonesimulator (xcode-runtime-name);
  • an exported runtime with anything but the layout above: the named regular files and directories, and exactly one disk image in Restore, whose name the three Firmware files repeat (xcode-runtime-layout);
  • more exported runtimes than a count cap (xcode-runtime-too-many). One export can write more than one;
  • exported runtimes whose files’ sizes (st_size) add up to more than a size cap (xcode-runtime-too-large).

The caps are in code.

Before it copies anything, the shim of S06-15-xcode-diskS06-15-xcode-disk: The Xcode DiskHow the host builds the read-only disk that holds Xcode and the simulator runtimes for an image build, under the wb-diskfmt shim's profile, and what the build records. checks, and refuses with the rule:

  • that Apple signed the app and that its sealed parts are unchanged (xcode-signature-invalid), with codesign --verify --deep --strict against this code requirement:

    (anchor apple generic and identifier "com.apple.dt.Xcode" and
    (certificate leaf[field.1.2.840.113635.100.6.1.9] or
    (certificate 1[field.1.2.840.113635.100.6.2.6] and
    certificate leaf[field.1.2.840.113635.100.6.1.13] and
    certificate leaf[subject.OU] = "59GAB85EFG")))
    or (identifier "com.apple.dt.Xcode" and anchor apple)

    The first branch is Apple’s App Store signature, and the second its Developer ID with Apple’s own team. The third is the .xip from Apple’s developer site, signed with Apple’s own Software Signing certificate. anchor apple generic without the leaf or team clause is never accepted, because every certificate Apple issues, any developer’s Developer ID included, meets it;

  • that the host’s user accepted the license this Xcode names, from the host’s own record of it (xcode-license-not-accepted);

  • that Xcode’s minimum macOS version is at most the parent image’s macOS version (xcode-too-new-for-guest);

  • that Apple signed each exported runtime’s disk image and that it is unchanged (xcode-runtime-signature-invalid), with codesign --verify --strict against this code requirement:

    identifier image and anchor apple

    The disk image has its own code signature, made with Apple’s “macOS Software Signing” certificate, with one hash over the whole image. The other files of an exported runtime have no signature the host can check. The guest’s import is given only the disk image (“In the build VM”, and S06-15-xcode-diskS06-15-xcode-disk: The Xcode DiskHow the host builds the read-only disk that holds Xcode and the simulator runtimes for an image build, under the wb-diskfmt shim's profile, and what the build records. for the files beside it);

  • that <data> has room for the disk and the image (SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped., xcode-disk-no-space).

On the host’s App Store Xcode and on Xcode 27.2 expanded from the developer site’s .xip, the code requirement above holds. The .xip install’s designated requirement is identifier "com.apple.dt.Xcode" and anchor apple, and the first and second branches alone fail on it (codesign exits 3). Plain anchor apple fails on the App Store Xcode. A copy with one byte changed in a framework fails, as does a runtime disk image with one byte changed (X06-guest-xcodeX06-guest-xcode: Guest users and XcodeCan builds and simulators run for a guest user without a GUI login?, “Follow-up (I624I624 (closed): S06-14-xcode-image: measure the host export, signature checks and offline import of Xcode and runtimesFrom #194 (S06-14-xcode-image, the Xcode image variant).)”).

The license record is /Library/Preferences/com.apple.dt.Xcode.plist, which xcodebuild -license accept writes as root, and which is the Xcode entry’s read rule for it. It holds the accepted license’s ID per license type, IDELastGMLicenseAgreedTo for a release, and the Xcode version that accepted it, IDEXcodeVersionForAgreedToGMLicense. It doesn’t name a build. The app names the license it needs in Contents/Resources/LicenseInfo.plist (licenseID, licenseType).

The shim parses both plists itself. It refuses unless the ID recorded for the app’s license type equals the app’s licenseID. A fixed list in code maps the type to the record’s key, and holds only the measured one: GM to IDELastGMLicenseAgreedTo. Any other type, a beta’s included, refuses with xcode-license-not-accepted. It doesn’t compare the recorded version, because Xcode doesn’t either: on the reference machine the record says 27.0, Xcode 27.2 is installed, and xcodebuild -license check exits 0 (X06-guest-xcodeX06-guest-xcode: Guest users and XcodeCan builds and simulators run for a guest user without a GUI login?, “Follow-up (I624I624 (closed): S06-14-xcode-image: measure the host export, signature checks and offline import of Xcode and runtimesFrom #194 (S06-14-xcode-image, the Xcode image variant).)”). A new license ID still needs a new acceptance, which the refusal names: sudo xcodebuild -license accept.

The Xcode step boots its clone in wb-vmd-layer, with no network device, cloned as for the Claude Code layer (S06-01-image-layersS06-01-image-layers: Image Layers and the Toolchain PrefixThe layers of a guest image, and the toolchain prefix that project layers install into.). Its device set adds the Xcode disk, read-only, and only for this step (S06-06-devices-and-warm-startS06-06-devices-and-warm-start: Devices, Warm Start and TimeA VM's devices and resources, saving and restoring its state, and how the guest clock follows the host., “Devices”). wb-vmd-layer attaches xcode.img from the build bundle only when the start call sets its Xcode flag. The call never names a path. A start call with the Xcode flag in any other slot is refused before any device is created, and logs vmd-xcode-disk-refused. The flag is never dropped to let the start go on (S04-10-vmd-installS04-10-vmd-install: Installing macOS in `wb-vmd`The wb-vmd-install entry of an image build: its install rules, the restore image it reads, the build bundle it installs into, and its Install call., “The build bundle”, and S06-06-devices-and-warm-startS06-06-devices-and-warm-start: Devices, Warm Start and TimeA VM's devices and resources, saving and restoring its state, and how the guest clock follows the host., “The Xcode disk”).

A named wb-guestd operation, install-xcode, then runs as root (S06-02-image-buildS06-02-image-build: Image BuildHow wb image build makes a guest image: the build VM, its two provisioning stages, terminfo, sealing, and storage., “No guest disk mounts”):

  1. It checks the volume at /Volumes/wb-xcode as it checks the guest tools disk: APFS, read-only, and mounted by root (S06-12-guest-agentS06-12-guest-agent: Guest AgentWhat wb-guestd, the service in the guest, does for the host, and how it updates itself., “Update at start”).
  2. It copies Xcode.app to /Applications/Xcode.app with ditto --norsrc --noextattr --noacl --noqtn --hfsCompression, then sets owner root:wheel with chown -R and takes write permission from group and others with chmod -R go-w. The files on the volume don’t belong to root, and the sealing scan refuses files outside /Users that a non-system user owns (S06-02-image-buildS06-02-image-build: Image BuildHow wb image build makes a guest image: the build VM, its two provisioning stages, terminfo, sealing, and storage., “Sealing”). --hfsCompression keeps the copy at the 4.0 GB it takes on the host instead of 10 GB;
  3. It checks the copy’s signature with the same requirement. That check accepts changed mode bits and files its seal leaves out (X06-guest-xcodeX06-guest-xcode: Guest users and XcodeCan builds and simulators run for a guest user without a GUI login?, “Follow-up (I624I624 (closed): S06-14-xcode-image: measure the host export, signature checks and offline import of Xcode and runtimesFrom #194 (S06-14-xcode-image, the Xcode image variant).)”). So the step also makes the checks of S06-15-xcode-diskS06-15-xcode-disk: The Xcode DiskHow the host builds the read-only disk that holds Xcode and the simulator runtimes for an image build, under the wb-diskfmt shim's profile, and what the build records., “What the signature doesn’t seal”, refuses a file not owned by root (xcode-copy-invalid), and clears every setuid and setgid bit.
  4. It runs xcode-select -s, xcodebuild -license accept and xcodebuild -runFirstLaunch.
  5. It checks each runtime’s disk image, the one .dmg in its Restore/, with identifier image and anchor apple (xcode-runtime-signature-invalid, 29.8 s measured). It imports it with xcrun simctl runtime add, and checks that xcrun simctl runtime list then shows it as Ready.
  6. It unmounts the volume.

These steps worked, and an iOS simulator then booted on the imported runtime (X06-guest-xcodeX06-guest-xcode: Guest users and XcodeCan builds and simulators run for a guest user without a GUI login?, “Follow-up (I624I624 (closed): S06-14-xcode-image: measure the host export, signature checks and offline import of Xcode and runtimesFrom #194 (S06-14-xcode-image, the Xcode image variant).)”). They were measured in a guest with a network device whose interfaces were all down. I684I684 (open): Xcode image on the maintainer's Mac: build a named image with the host's Xcode and a runtime, and check it in a sessionPackage IMG.8 of docs/implementation-plan.md, part 4 of 4 (IMG.8d). runs them without a network device. A failure there fails the build, and the build doesn’t add a device to get past it. xcodebuild -importPlatform didn’t work there. It first copied its input into root’s temporary directory, then refused for lack of room with 22 GiB free, and left the copy behind. simctl runtime add copies the disk image once. The clone of the Xcode step needs room on its system disk for Xcode and every runtime.

A failure fails the build. The host bounds and escapes the failure text as for terminfo (S06-02-image-buildS06-02-image-build: Image BuildHow wb image build makes a guest image: the build VM, its two provisioning stages, terminfo, sealing, and storage., “Terminfo”). Then the image is sealed as any other. -runFirstLaunch adds three root launchd jobs with no file in /Library/LaunchDaemons: com.apple.CoreDevice.CoreDeviceDDIUpdaterService.job, com.apple.CoreSimulator.simdiskimaged and com.apple.PerformanceTrace.PerformanceTraceService. The sealing scan accepts these labels only in an image with the Xcode step, and never on the label alone (S06-02-image-buildS06-02-image-build: Image BuildHow wb image build makes a guest image: the build VM, its two provisioning stages, terminfo, sealing, and storage., “Sealing”). X06-guest-xcodeX06-guest-xcode: Guest users and XcodeCan builds and simulators run for a guest user without a GUI login? recorded neither the program paths nor how launchd registers these jobs. I684I684 (open): Xcode image on the maintainer's Mac: build a named image with the host's Xcode and a runtime, and check it in a sessionPackage IMG.8 of docs/implementation-plan.md, part 4 of 4 (IMG.8d)., the first real guest run, records both, and the exact paths go into code. Until then, the scan requires a program whose real path is under /Library/Developer/PrivateFrameworks, owned by root, with no group or other write permission.

Root runs -runFirstLaunch, once, in the image build, before the image is sealed. It installs the CoreSimulator and CoreDevice frameworks into /Library/Developer, and only root can write there. The Layer 2 build profile reads them (S13-02-filesystem-profileS13-02-filesystem-profile: Layer 2: Seatbelt Filesystem Profile (v1)The Seatbelt profile each session's process tree runs under, where it comes from, its exceptions for Xcode builds, and its known gaps., “Xcode build profile”).

A project user, the agent included, isn’t an admin (S06-08-projects-and-sessionsS06-08-projects-and-sessions: Projects and Sessions Inside a VMHow projects map onto guest users and sessions onto worktrees, and how Claude Code runs in the guest.), so a session can’t run it. A session never needs to: the image has the frameworks and the license record before any project code runs.

Xcode is Apple’s software under Apple’s license, which the user accepted on the host. An image with Xcode, and every image built on it, is never shared with another machine. Sharing images between machines is a later addition (S06-02-image-buildS06-02-image-build: Image BuildHow wb image build makes a guest image: the build VM, its two provisioning stages, terminfo, sealing, and storage., “Storage and distribution”), and it leaves these images out. wb image build says once, before it copies, that it copies the host’s Xcode into the image.

Xcode from a read-only disk the host builds

Section titled “Xcode from a read-only disk the host builds”

Status: Draft