simctl

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package simctl is a thin read-only wrapper over `xcrun simctl` for discovering the iOS simulators installed on this machine. It does not boot, install, or otherwise mutate devices — allocation is simbroker's job; provisioning is the consumer's. The one mutation simctl exposes (Boot) is opt-in and used only when a caller passes `claim --boot`.

Index

Constants

View Source
const DefaultTimeout = 20 * time.Second

DefaultTimeout bounds a single `xcrun simctl list` so simulator discovery can't hang a command if CoreSimulator wedges. Applied by ListAvailable.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to simctl. The zero value is NOT ready — use New.

func New

func New() *Client

New returns a Client backed by the real `xcrun` binary.

func NewWithRunner

func NewWithRunner(r Runner) *Client

NewWithRunner returns a Client backed by a custom Runner (tests).

func (*Client) Boot

func (c *Client) Boot(ctx context.Context, udid string) error

Boot boots a device if it isn't already up. Idempotent: an "Unable to boot ... current state: Booted" is treated as success. Best-effort and only used for `claim --boot`; allocation never depends on it.

func (*Client) Class

func (c *Client) Class() device.Class

Class identifies this controller as the iOS simulator platform.

func (*Client) ListAvailable

func (c *Client) ListAvailable(ctx context.Context) ([]device.Device, error)

ListAvailable returns every available iOS simulator as a class-neutral device.Device — the vocabulary the broker speaks. It maps simctl's rich internal type down (ID := UDID, OS "iOS", Version "major.minor.patch") while preserving the (name, newest-version-first) ordering established by list.

type Device

type Device struct {
	UDID        string  `json:"udid"`
	Name        string  `json:"name"`       // e.g. "iPhone 17 Pro"
	Runtime     string  `json:"runtime"`    // raw runtime id, e.g. com.apple.CoreSimulator.SimRuntime.iOS-26-4
	OS          string  `json:"os"`         // "iOS"
	Version     Version `json:"version"`    // parsed from the runtime id, e.g. {26,4}
	State       string  `json:"state"`      // "Booted" | "Shutdown" | "Booting" | ...
	TypeID      string  `json:"deviceType"` // deviceTypeIdentifier
	IsAvailable bool    `json:"isAvailable"`
}

Device is one installed simulator, flattened from simctl's per-runtime map.

func (Device) Booted

func (d Device) Booted() bool

Booted reports whether the device is up (or coming up).

type Runner

type Runner func(ctx context.Context, name string, args ...string) ([]byte, error)

Runner runs an argv and returns combined stdout. Swapped out in tests so the package can be exercised without a Mac / Xcode.

type Version

type Version struct {
	Major, Minor, Patch int
}

Version is a parsed OS version (major[.minor[.patch]]) used to prefer the newest runtime when several instances of the same model exist.

func (Version) Less

func (v Version) Less(w Version) bool

Less reports whether v sorts before w (older runtime first).

func (Version) String

func (v Version) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL