golang/go · error

xcrun simctl install booted %q: %v

Error message

xcrun simctl install booted %q: %v

What it means

Returned by installSimulator (go_ios_exec.go:140) when `xcrun simctl install booted <appdir>` fails. go_ios_exec installs the compiled test app bundle into the booted iOS Simulator before spawning it; CombinedOutput is captured and written to stderr, then this error wraps the xcrun failure.

Source

Thrown at misc/ios/go_ios_exec.go:140

	}
	if err := os.WriteFile(filepath.Join(appdir, "Info.plist"), []byte(infoPlist(pkgpath)), 0744); err != nil {
		return err
	}
	if err := os.WriteFile(filepath.Join(appdir, "ResourceRules.plist"), []byte(resourceRules), 0744); err != nil {
		return err
	}
	return nil
}

func installSimulator(appdir string) error {
	cmd := exec.Command(
		"xcrun", "simctl", "install",
		"booted", // Install to the booted simulator.
		appdir,
	)
	if out, err := cmd.CombinedOutput(); err != nil {
		os.Stderr.Write(out)
		return fmt.Errorf("xcrun simctl install booted %q: %v", appdir, err)
	}
	return nil
}

func runSimulator(appdir, bundleID string, args []string) error {
	xcrunArgs := []string{"simctl", "spawn",
		"booted",
		appdir + "/gotest",
	}
	xcrunArgs = append(xcrunArgs, args...)
	cmd := exec.Command("xcrun", xcrunArgs...)
	cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr
	err := cmd.Run()
	if err != nil {
		return fmt.Errorf("xcrun simctl launch booted %q: %v", bundleID, err)
	}

	return nil

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Boot a simulator first: `xcrun simctl boot 'iPhone 15'` then `open -a Simulator`.
  2. Accept the Xcode license: `sudo xcodebuild -license accept`.
  3. Verify only one simulator is booted: `xcrun simctl list devices booted`.
  4. Re-read stderr captured by xcrun (it is written before the error) for the precise reason.
Defensive patterns

Strategy: validation

Validate before calling

func simulatorBooted() error {
    out, err := exec.Command("xcrun", "simctl", "list", "devices", "booted").Output()
    if err != nil {
        return fmt.Errorf("simctl list: %w", err)
    }
    if !strings.Contains(string(out), "(") { // no booted entries
        return errors.New("no booted simulator")
    }
    return nil
}

Prevention

When it happens

Trigger: No simulator is booted (so 'booted' resolves to nothing), the app bundle is malformed, the simulator is busy/unresponsive, disk full on the simulator, or xcrun/Command Line Tools are misconfigured.

Common situations: Developer forgot to boot a Simulator (`xcrun simctl boot <udid>`); CoreSimulator service stuck; Xcode/CLT license not accepted; appdir points to a stale/incomplete .app; multiple simulators booted confusing 'booted'.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/5b8b4e35d977345f. Report an issue: GitHub.