iosdevice

package
v0.2.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package iosdevice owns the physical-iOS half of the driver surface: every import of go-ios lives here, so the usbmuxd/tunnel dependency has exactly one boundary package. The simulator half stays in internal/ios.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeclaredCapabilities

func DeclaredCapabilities() device.Capabilities

DeclaredCapabilities is the physical-iOS capability document. The feature truth lives in drivercontract.IOSPhysical() so preflight and this driver cannot disagree; every false there has a matching device.ErrUnsupported at call time. The platform stays the shared iOS token: flows target "ios", and the flavor is the driver's concern, not the flow's.

Types

type Device

type Device struct {
	UDID string
}

Device is one physical iOS device currently visible over usbmuxd.

func ListDevices

func ListDevices(ctx context.Context) ([]Device, error)

ListDevices returns the physical devices usbmuxd can currently reach. An unreachable usbmuxd is an error, not an empty list: callers that tolerate the tool's absence make that call themselves, mirroring android.ListDevices.

The dial honors the context directly. go-ios exposes no cancellable enumeration for the read that follows, so cancellation closes the connection instead: the close unblocks the in-flight read, and the call waits for that goroutine, leaving no socket or goroutine behind.

type Driver

type Driver struct {
	*ios.Driver
	// contains filtered or unexported fields
}

Driver drives one physical iOS device. It embeds the shared iOS driver — gestures, hierarchy, waits, and screenshots ride the same runner wire the simulator uses — and replaces only what hardware changes: the session (usbmuxd + pairing + tunnel + port forward), the out-of-app tools, and runner delivery (go-ios testmanagerd instead of xcodebuild).

func NewDriver

func NewDriver(udid string, hostPort int, client *ios.Client, bundle *ios.RunnerBundle) *Driver

NewDriver binds the runner client and the go-ios tools to one physical device. The client must point at the HOST end of the forward (the shard port); the session forwards it to the runner's device port. A non-nil bundle makes Open install and start the runner itself.

func (*Driver) Capabilities

func (driver *Driver) Capabilities() device.Capabilities

Capabilities declares the physical surface; the embedded simulator document would over-promise.

func (*Driver) ClearAppState

func (driver *Driver) ClearAppState(ctx context.Context, request device.AppRequest) error

ClearAppState uninstalls the app and reinstalls it from the operator's archive — the only state reset Apple allows on hardware.

func (*Driver) Close

func (driver *Driver) Close(ctx context.Context) error

Close stops what the embedded driver started, then this driver's own captures and runner, then the held tool sessions, then the session.

func (*Driver) CollectCrashArtifacts

func (driver *Driver) CollectCrashArtifacts(
	ctx context.Context,
	request device.ArtifactRequest,
) ([]device.Artifact, error)

CollectCrashArtifacts downloads the device's crash reports. Collection is device-wide: crash filenames carry process names, not bundle ids, so an AppID filter would silently miss reports.

func (*Driver) Name

func (driver *Driver) Name() string

Name distinguishes hardware from simulators in operator messages.

func (*Driver) Open

func (driver *Driver) Open(ctx context.Context) error

Open prepares the device (reachability, pairing, tunnel, forward) before any device mutation, binds the tools, delivers the runner when this driver manages it, and confirms the runner answers over the wire.

func (*Driver) SetPermissions

func (driver *Driver) SetPermissions(ctx context.Context, request device.PermissionsRequest) error

SetPermissions hands the whole permission map to the runner, which auto-answers the springboard permission alerts as they appear — the only permission mechanism Apple leaves open on hardware (there is no host-side TCC write like the simulator's `simctl privacy`). The alerts are device-global, so the request's app id does not travel on the wire.

func (*Driver) StartDeviceLogCapture

func (driver *Driver) StartDeviceLogCapture(
	ctx context.Context,
	request device.DeviceLogRequest,
) (device.CaptureID, error)

StartDeviceLogCapture streams the device's syslog relay into an artifact file until the matching stop. Capture is device-wide, like the simulator.

func (*Driver) StartScreenRecording

func (driver *Driver) StartScreenRecording(
	ctx context.Context,
	request device.ScreenRecordingRequest,
) (device.CaptureID, error)

StartScreenRecording begins polling frames into the requested sink.

func (*Driver) StopDeviceLogCapture

func (driver *Driver) StopDeviceLogCapture(
	ctx context.Context,
	id device.CaptureID,
) ([]device.Artifact, error)

StopDeviceLogCapture ends a capture and hands back its artifact.

func (*Driver) StopScreenRecording

func (driver *Driver) StopScreenRecording(
	ctx context.Context,
	id device.CaptureID,
) ([]device.Artifact, error)

StopScreenRecording ends a recording and returns its artifact. Mirrors the simulator: the stop half completes the lifecycle for the recording controller and is not part of the frozen v0 surface.

type Tools

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

Tools is the physical-device implementation of ios.DeviceTools: the out-of-app half the simulator covers with simctl, expressed through go-ios services instead. The DeviceEntry is bound by the session after it resolves and prepares the device; every method fails closed until then.

Operations Apple locks on hardware (keychain reset, media injection) return device.ErrUnsupported permanently. Permissions, open-link, and diagnostics gain runner-side/go-ios implementations in later slices and fail with ErrUnsupported until those land.

func NewTools

func NewTools(udid string) *Tools

NewTools returns the physical-device tools for one udid. bind must run before any device operation.

func (*Tools) AddMedia

func (tools *Tools) AddMedia(context.Context, []string) error

AddMedia is an Apple platform limit: no tool injects media into the photo library of a physical device without jailbreaking it.

func (*Tools) AppContainer

func (tools *Tools) AppContainer(context.Context, string) (string, error)

AppContainer is the simulator's clear-state mechanism (copy the bundle out of the container before uninstall). Hardware exposes no app container to the host; the physical clear-state path reinstalls from a host-supplied .ipa instead and never calls this.

func (*Tools) Diagnose

func (tools *Tools) Diagnose(context.Context, string, time.Duration) error

func (*Tools) Install

func (tools *Tools) Install(ctx context.Context, appPath string) error

func (*Tools) Launch

func (tools *Tools) Launch(
	ctx context.Context,
	bundleID string,
	arguments []ios.LaunchArgument,
	terminateRunning bool,
) error

func (*Tools) OpenURL

func (tools *Tools) OpenURL(ctx context.Context, url string) error

OpenURL opens a link by relaunching Safari with the URL as its launch argument — the same technique the WebDriverAgent ecosystem uses, because hardware has no host-side `simctl openurl`. KillExisting makes repeated openLink steps deterministic instead of reusing a stale page.

func (*Tools) ResetKeychain

func (tools *Tools) ResetKeychain(context.Context) error

ResetKeychain is an Apple platform limit: no tool resets the keychain of a physical device without jailbreaking it.

func (*Tools) SetLocation

func (tools *Tools) SetLocation(ctx context.Context, latitude, longitude float64) error

SetLocation starts location simulation through the instruments service. The service connection must stay open for the location to hold, so the session is kept until the next SetLocation or close(). The new session starts before the old one closes, so the device never snaps back to its real location between two flow steps.

func (*Tools) SetPermission

func (tools *Tools) SetPermission(context.Context, string, string, string) error

SetPermission is the simulator's per-permission simctl mechanism. The physical driver overrides SetPermissions to route the whole map through the runner (springboard alert auto-answering), so this backstop only fires if the embedded simulator path is reached by mistake.

func (*Tools) Terminate

func (tools *Tools) Terminate(ctx context.Context, bundleID string) error

func (*Tools) Uninstall

func (tools *Tools) Uninstall(ctx context.Context, bundleID string) error

Jump to

Keyboard shortcuts

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