Documentation
¶
Overview ¶
Package iostool holds what `glutter-ios` does that does not need a Mac to be understood: the Info.plist of an iOS app, the layout of its bundle, its icons, the command lines of `simctl`, and the build of the program with the compiler of Xcode (SPEC §30.1). Everything here but the build and the signing runs on any host, so the tests of the plist, the layout and the command lines run everywhere; the build needs Xcode and the tests of it skip without.
Flutter: no counterpart
Index ¶
- Constants
- func DefaultID(name string) string
- func DefaultIcon() ([]byte, error)
- func DefaultName(pkg, dir string) string
- func DefaultUsage(name string) map[string]string
- func Entitlements(team, id string) []byte
- func Env(t Toolchain, simulator bool) []string
- func Icons(pngData []byte) (map[string][]byte, error)
- func InfoPlist(i Info) ([]byte, error)
- func Sign(ctx context.Context, app string, o SignOptions) error
- type BuildOptions
- type BuildResult
- type Bundle
- type Device
- type DeviceType
- type ExecRunner
- type IconFile
- type Info
- type Layout
- type Runner
- type Runtime
- type SignOptions
- type Simctl
- func (s Simctl) Args(sub string, args ...string) []string
- func (s Simctl) Boot(ctx context.Context, udid string) error
- func (s Simctl) Container(ctx context.Context, udid, id string) (string, error)
- func (s Simctl) Create(ctx context.Context, name, deviceType, runtime string) (string, error)
- func (s Simctl) Delete(ctx context.Context, udid string) error
- func (s Simctl) Devices(ctx context.Context, booted bool) ([]Device, error)
- func (s Simctl) Install(ctx context.Context, udid, app string) error
- func (s Simctl) LaunchArgs(udid, id string, console bool) []string
- func (s Simctl) Pbcopy(ctx context.Context, udid, text string) error
- func (s Simctl) Pbpaste(ctx context.Context, udid string) (string, error)
- func (s Simctl) Screenshot(ctx context.Context, udid, file string) error
- func (s Simctl) Shutdown(ctx context.Context, udid string) error
- func (s Simctl) Terminate(ctx context.Context, udid, id string) error
- func (s Simctl) UI(ctx context.Context, udid string, args ...string) error
- type Simulator
- type Toolchain
Constants ¶
const ( // TagIOSBuildFailed is the tag of the error for a package that does not build for iOS, or a build that is asked for with // parameters that cannot go together. // // Flutter: no counterpart TagIOSBuildFailed = "IOSBuildFailed" // TagIOSSignFailed is the tag of the error for a bundle that codesign cannot sign. // // Flutter: no counterpart TagIOSSignFailed = "IOSSignFailed" )
The tags of the errors that this file makes (rm4n0s/errors, R5).
const ( // DefaultVersion is the version of an app that does not say. // // Flutter: no counterpart DefaultVersion = "1.0.0" // MinOSVersion is the MinimumOSVersion of every bundle. // // Flutter: no counterpart MinOSVersion = "15.0" )
The defaults of an app's identity and the lowest iOS that runs it (D36: iOS 15 is the minimum).
const ( // OrientationPortrait is UIInterfaceOrientationPortrait. // // Flutter: no counterpart OrientationPortrait = "UIInterfaceOrientationPortrait" // OrientationPortraitUpsideDown is UIInterfaceOrientationPortraitUpsideDown. // // Flutter: no counterpart OrientationPortraitUpsideDown = "UIInterfaceOrientationPortraitUpsideDown" // OrientationLandscapeLeft is UIInterfaceOrientationLandscapeLeft. // // Flutter: no counterpart OrientationLandscapeLeft = "UIInterfaceOrientationLandscapeLeft" // OrientationLandscapeRight is UIInterfaceOrientationLandscapeRight. // // Flutter: no counterpart OrientationLandscapeRight = "UIInterfaceOrientationLandscapeRight" )
The orientations that an Info.plist can allow (the values of UISupportedInterfaceOrientations).
const ( // TagIOSCommandFailed is the tag of the error for a program of Xcode (xcrun, xcode-select, codesign) that cannot be run at all. // // Flutter: no counterpart TagIOSCommandFailed = "IOSCommandFailed" // TagIOSSimctlFailed is the tag of the error for a `simctl` command that cannot be run or says no, or whose list it cannot read. // // Flutter: no counterpart TagIOSSimctlFailed = "IOSSimctlFailed" )
The tags of the errors that this file makes (rm4n0s/errors, R5).
const ( // TagIOSXcodeMissing is the tag of the error for a machine without the full Xcode selected, or without its compiler or SDKs. // // Flutter: no counterpart TagIOSXcodeMissing = "IOSXcodeMissing" // TagIOSRuntimeMissing is the tag of the error for a machine without an iOS Simulator runtime of iOS 15 or later, or whose runtime // has no model of the family that was asked for. // // Flutter: no counterpart TagIOSRuntimeMissing = "IOSRuntimeMissing" )
The tags of the errors that this file makes (rm4n0s/errors, R5).
const IconBase = "AppIcon"
IconBase is the start of the names of the icon files and the name of the icon in the Info.plist.
Flutter: no counterpart
const ( // TagIOSBundleInvalid is the tag of the error for an app identity that a bundle cannot have: an identifier that is not in reverse // DNS form, a name with a slash, an empty version, an orientation that UIKit does not have, or a bundle that cannot be written. // // Flutter: no counterpart TagIOSBundleInvalid = "IOSBundleInvalid" )
The tags of the errors that this file makes (rm4n0s/errors, R5).
const ( // TagIOSIconInvalid is the tag of the error for an icon that is not a square PNG of at least 167 pixels, or that cannot be // encoded. // // Flutter: no counterpart TagIOSIconInvalid = "IOSIconInvalid" )
The tags of the errors that this file makes (rm4n0s/errors, R5).
Variables ¶
This section is empty.
Functions ¶
func DefaultID ¶
DefaultID is the identifier of an app that has none: "dev.glutter." and the name in letters, digits and hyphens.
Flutter: no counterpart
func DefaultIcon ¶
DefaultIcon returns Glutter's icon as a PNG of 1024 pixels: a white ring with a gap and a bar, the shape of a "G", on the blue of the Material seed color, over the whole square (iOS rounds the corners itself).
Flutter: no counterpart
func DefaultName ¶
DefaultName is the name of an app that has none: the last element of its package path, or of the directory for ".".
Flutter: no counterpart
func DefaultUsage ¶
DefaultUsage are the usage strings that every bundle has: the system asks for the microphone and the motion sensors only when an app uses them, and shows the string then.
Flutter: no counterpart
func Entitlements ¶
Entitlements writes the entitlements file of a build for a device: the application identifier (the team and the bundle identifier) and the permission to be debugged, which a development profile gives.
Flutter: no counterpart
func Env ¶
Env is the environment that makes `go build` build for iOS with Xcode's compiler: GOOS=ios, GOARCH=arm64, cgo on (Go's iOS port links externally, and purego needs cgo there, D35), and the compiler, the SDK and the target of the Simulator or of a device in the compiler and linker flags. The target says "-simulator" for the Simulator, which makes the executable one of the platform iOS Simulator, which a device refuses and a Simulator needs.
Flutter: no counterpart
func Icons ¶
Icons makes the PNG files of an icon from a square PNG of at least 167 pixels. It fails with IOSIconInvalid when the picture is not a PNG, not square, or smaller than the largest file.
Flutter: no counterpart
func InfoPlist ¶
InfoPlist writes the Info.plist of the bundle as XML, with the keys in a fixed order (so a build is the same file every time) and the usage strings sorted by key. The launch screen is a dictionary (UILaunchScreen), so that no storyboard needs compiling; the scene manifest has no configurations, because the app delegate answers for the scene (SPEC §30.2); the icons are the PNG files that Icons makes, named in CFBundleIcons. It fails with IOSBundleInvalid for an identity that a bundle cannot have.
Flutter: no counterpart
func Sign ¶
func Sign(ctx context.Context, app string, o SignOptions) error
Sign signs the bundle with codesign: ad hoc for the Simulator, and for a device with the identity and the entitlements of the team and the bundle identifier. It fails with IOSSignFailed, with codesign's output, when codesign cannot be run or says no.
Flutter: no counterpart
Types ¶
type BuildOptions ¶
type BuildOptions struct {
// Package is the main package to build, as `go build` takes it: "./examples/counter".
Package string
// Dir is the directory to run the go command in, which Package is relative to. The default is the current directory.
Dir string
// Out is the bundle to write, which ends in ".app"; "<Name>.app" in the current directory when empty.
Out string
// Simulator builds for the iOS Simulator (arm64, signed ad hoc) and not for a device.
Simulator bool
// Release builds with -tags glutter_release and -ldflags=-s -w.
Release bool
// Team and Profile are the developer team (its ten characters) and the provisioning profile file of a build for a device; both or
// neither. The owner has them; the tool only signs with them.
Team, Profile string
// Identity is the signing identity of a build for a device; "Apple Development" when empty.
Identity string
// ID, Name and Version go into the Info.plist; the defaults are DefaultID, the name of the package, and DefaultVersion.
ID, Name, Version string
// Icon is a PNG of at least 167 pixels, square, for the icon; Glutter's icon when empty.
Icon string
// Usage are usage strings added to those of DefaultUsage (a key of the plist and its text).
Usage map[string]string
// Orientations are the orientations the app supports (the Orientation constants); the default of InfoPlist when empty.
Orientations []string
// Env is added to the environment of the go command.
Env []string
// Runner runs the programs of Xcode; ExecRunner when nil.
Runner Runner
}
BuildOptions are the parameters of Build (the flags of `glutter-ios build`, SPEC §30.1).
Flutter: no counterpart
type BuildResult ¶
type BuildResult struct {
// Layout has the paths of the bundle.
Layout Layout
// Info is what went into the plist, with the defaults filled in.
Info Info
// Size is the size of the executable in bytes.
Size int64
}
BuildResult says what Build wrote.
Flutter: no counterpart
func Build ¶
func Build(ctx context.Context, o BuildOptions) (BuildResult, error)
Build compiles the package for iOS, makes the icon files and the bundle, and signs it (ad hoc for the Simulator, with the team, the profile and the identity for a device). It fails with IOSXcodeMissing when Xcode is not there, IOSBuildFailed, with the output of the go command, when the package does not build, and with the tags of the pieces (IOSIconInvalid, IOSBundleInvalid, IOSSignFailed) otherwise.
Flutter: no counterpart
type Bundle ¶
type Bundle struct {
// Info is the Info.plist.
Info Info
// Executable is the program.
Executable []byte
// Icons are the icon files by name (the result of Icons); none for no icon.
Icons map[string][]byte
// Profile is the provisioning profile of a build for a device (embedded.mobileprovision); none for the Simulator.
Profile []byte
}
Bundle is what Write puts into an app bundle.
Flutter: no counterpart
type Device ¶
type Device struct {
Name, UDID, State, Runtime string
}
Device is a device of the set, as `simctl list devices -j` says.
Flutter: no counterpart
func ParseDevices ¶
ParseDevices reads the JSON of `simctl list devices -j`. It fails with IOSSimctlFailed when the text is not that.
Flutter: no counterpart
type DeviceType ¶
type DeviceType struct {
// ID is the identifier that `simctl create` takes.
ID string
// Name is "iPhone 17".
Name string
// Family is "iPhone" or "iPad".
Family string
}
DeviceType is a model of device that the Simulator can make.
Flutter: no counterpart
func ChooseDeviceType ¶
func ChooseDeviceType(r Runtime, family string) (DeviceType, error)
ChooseDeviceType picks the model of the family ("iPhone" or "iPad") to test on: the current plain phone and the current plain iPad when the runtime has them, and the first of the family otherwise. It fails with IOSRuntimeMissing when the runtime has no model of the family.
Flutter: no counterpart
type ExecRunner ¶
type ExecRunner struct{}
ExecRunner runs the programs of the machine.
Flutter: no counterpart
type IconFile ¶
type IconFile struct {
// Name is the file name, with the size and the scale that iOS looks for ("AppIcon60x60@2x.png").
Name string
// Pixels is the width and the height of the picture.
Pixels int
}
IconFile is a PNG of the icon of an app: its name in the bundle and its size in pixels.
Flutter: no counterpart
func IconFiles ¶
func IconFiles() []IconFile
IconFiles are the icons an app of iOS 15 or later needs without an asset catalog: the iPhone's 60 points at 2x and 3x, and the iPad's 76 points at 2x and its 83.5 points at 2x (the Pro). The 1024 pixels of the App Store are the owner's, with the provisioning profile.
Flutter: no counterpart
type Info ¶
type Info struct {
// Executable is the name of the file in the bundle (CFBundleExecutable).
Executable string
// ID is the bundle identifier (CFBundleIdentifier), in reverse DNS form.
ID string
// Name is what the home screen calls the app (CFBundleName and CFBundleDisplayName).
Name string
// Version is CFBundleShortVersionString and CFBundleVersion.
Version string
// Simulator says that the bundle is for the Simulator (CFBundleSupportedPlatforms is iPhoneSimulator) and not for devices.
Simulator bool
// Orientations are the orientations the app supports, the values of the Orientation constants; all four on an iPad and the
// first three on an iPhone when empty.
Orientations []string
// Icons says that the bundle has the icon files that Icons makes, and names them in the plist (Write sets it).
Icons bool
// Usage are the usage strings that the system shows when the app first asks for something: the keys are those of the plist
// ("NSMicrophoneUsageDescription"), the values the text.
Usage map[string]string
}
Info is what goes into the Info.plist of an app bundle.
Flutter: no counterpart
type Layout ¶
type Layout struct {
// App is the directory of the bundle ("Counter.app").
App string
// Executable is the program.
Executable string
// Plist is the Info.plist.
Plist string
// Profile is embedded.mobileprovision.
Profile string
}
Layout has the paths of a bundle. An iOS bundle is flat: the executable, the Info.plist and the resources sit in the directory of the app, unlike a bundle of macOS.
Flutter: no counterpart
type Runner ¶
type Runner interface {
Run(ctx context.Context, name string, args ...string) (out []byte, exit int, err error)
}
Runner runs a program and returns what it wrote to the standard output and the standard error together, and its exit code. The error is for a program that cannot be run at all (IOSCommandFailed); a program that runs and exits with a code other than zero is the caller's to judge. The tests of the command lines of simctl give a fake one.
Flutter: no counterpart
type Runtime ¶
type Runtime struct {
// ID is the identifier that `simctl create` takes ("com.apple.CoreSimulator.SimRuntime.iOS-27-2").
ID string
// Version is "27.2".
Version string
// DeviceTypes are the devices that the runtime can run.
DeviceTypes []DeviceType
}
Runtime is an iOS Simulator runtime that is installed.
Flutter: no counterpart
func ChooseRuntime ¶
ChooseRuntime picks the runtime to test on: the newest iOS of at least 15 (D36), and among runtimes of one version the one that runs the most models (Xcode has an extra runtime for a single model). It fails with IOSRuntimeMissing, whose message says what to run, when there is none.
Flutter: no counterpart
func ParseRuntimes ¶
ParseRuntimes reads the JSON of `simctl list runtimes -j` and returns the iOS runtimes that are available. It fails with IOSSimctlFailed when the text is not that.
Flutter: no counterpart
type SignOptions ¶
type SignOptions struct {
// Team is the developer team of a build for a device; empty signs ad hoc (the Simulator).
Team string
// ID is the bundle identifier, which goes into the entitlements of a build for a device.
ID string
// Identity is the signing identity of a build for a device; "Apple Development" when empty.
Identity string
// Runner runs codesign; ExecRunner when nil.
Runner Runner
}
SignOptions are what Sign is asked for.
Flutter: no counterpart
type Simctl ¶
type Simctl struct {
// Set is the directory of the device set; the default set of the user when empty.
Set string
// Runner runs xcrun; ExecRunner when nil.
Runner Runner
}
Simctl runs `xcrun simctl` for a set of Simulator devices. The set is a directory of its own (`.ios-test/devices` for the tests), so that Glutter's devices are not the ones of the owner's Xcode.
Flutter: no counterpart
func (Simctl) Args ¶
Args is the command line (the arguments of xcrun) of a simctl subcommand: the set goes before the subcommand, as simctl wants it.
Flutter: no counterpart
func (Simctl) Boot ¶
Boot starts the device and waits until it has finished booting (`bootstatus -b`, which boots it when it is not booted).
Flutter: no counterpart
func (Simctl) Container ¶
Container is the directory of the data of the app (what the app sees as its home).
Flutter: no counterpart
func (Simctl) Create ¶
Create makes a device of the type and the runtime (identifiers from `simctl list`) and returns its UDID.
Flutter: no counterpart
func (Simctl) Devices ¶
Devices lists the devices of the set that have a state (all of them, or only the booted ones).
Flutter: no counterpart
func (Simctl) LaunchArgs ¶
LaunchArgs is the command line of Launch: with the console, the output of the app is the output of the command; the environment of the app is given by SIMCTL_CHILD_ variables, which the caller puts in the environment of the command.
Flutter: no counterpart
func (Simctl) Pbcopy ¶
Pbcopy makes text the content of the device's pasteboard (`simctl pbcopy`, which reads its standard input). It is for a test that copies something as another program would; it fails with IOSCommandFailed when xcrun cannot run and with IOSSimctlFailed when simctl says no.
Flutter: no counterpart
func (Simctl) Pbpaste ¶
Pbpaste is the text of the device's pasteboard: what `simctl pbpaste` prints.
Flutter: no counterpart
func (Simctl) Screenshot ¶
Screenshot writes the screen of the device to a file.
Flutter: no counterpart
func (Simctl) UI ¶
UI changes a setting of the device's interface with `simctl ui`: "appearance" with light or dark, "content_size" with the name of a Dynamic Type size (extra-small, small, medium, large, extra-large, extra-extra-large, extra-extra-extra-large, accessibility-medium, accessibility-large, accessibility-extra-large, accessibility-extra-extra-large, accessibility-extra-extra-extra-large), or "increase_contrast" with enabled or disabled. It fails with IOSSimctlFailed when simctl says no.
Flutter: no counterpart
type Simulator ¶
type Simulator struct {
// Simctl is the device set.
Simctl Simctl
// Runtime is the runtime of the devices (ChooseRuntime).
Runtime Runtime
}
Simulator is a device set with the runtime that its devices run: the part of the harness of the tests and of `glutter-ios run` that makes the iPhone and the iPad of Glutter and boots them.
Flutter: no counterpart
func Discover ¶
Discover reads the runtimes of the machine and picks the one to use. It fails with IOSRuntimeMissing, whose message says what to run, when there is none of iOS 15 or later.
Flutter: no counterpart
func (Simulator) Device ¶
Device returns the device of the family, "iphone" or "ipad": it makes it the first time (named glutter-iphone or glutter-ipad, of the model that ChooseDeviceType picks) and does not boot it. It fails with IOSSimctlFailed when the device cannot be made, and with IOSRuntimeMissing when the runtime has no model of the family.
Flutter: no counterpart
type Toolchain ¶
type Toolchain struct {
// Developer is the developer directory (`xcode-select -p`), inside Xcode.app.
Developer string
// Clang is the C compiler of Xcode, which Go's external linker and cgo use.
Clang string
// DeviceSDK and SimulatorSDK are the paths of the iPhoneOS and the iPhoneSimulator SDKs.
DeviceSDK, SimulatorSDK string
}
Toolchain is where Xcode's pieces are on this machine.
Flutter: no counterpart
func CheckXcode ¶
CheckXcode looks for the full Xcode: `xcode-select -p` must point into Xcode.app (the Command Line Tools have no iOS SDK) and `xcrun` must find a compiler and the two SDKs. It fails with IOSXcodeMissing, whose message says what to run, when one is missing.
Flutter: no counterpart