1
0
mirror of https://github.com/golang/go synced 2024-09-24 01:20:13 -06:00
go/misc/ios
Elias Naur 746f405f98 cmd/go,misc/ios: fix tests on iOS
Now that modules are always on, cmd/go tests require a valid
GOCACHE. However, on iOS where the go tool is not available, the
cmd/go test driver ends up setting GOCACHE to the empty string.
Fix it by falling back to the builtin default cache directory.

The iOS exec wrapper passes the environment variables to the app
on the device, including $HOME used for the default cache directory.
Skip $HOME to let the device specific and writable $HOME be used
instead.

Should fix cmd/go on the iOS builders that broke when GO111MODULE
defaulted to on.

Change-Id: I0939f5b8aaa1d2db95e64c99f4130eee2d0b4d4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/167938
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-17 17:00:42 +00:00
..
clangwrap.sh build: fix darwin/arm broken on macOS 10.12 with Xcode 8.0 2016-12-21 12:27:41 +00:00
detect.go misc/ios: remove note from output of detect.go 2018-10-24 15:33:31 +00:00
go_darwin_arm_exec.go cmd/go,misc/ios: fix tests on iOS 2019-03-17 17:00:42 +00:00
README misc/ios: update documentation for running iOS programs and tests 2018-05-10 18:01:20 +00:00

Go on iOS
=========

For details on developing Go for iOS on macOS, see the documentation in the mobile
subrepository:

    https://github.com/golang/mobile

It is necessary to set up the environment before running tests or programs directly on a
device.

First make sure you have a valid developer certificate and have setup your device properly
to run apps signed by your developer certificate. Then install the libimobiledevice and
ideviceinstaller tools from https://www.libimobiledevice.org/. Use the HEAD versions from
source; the stable versions have bugs that prevents the Go exec wrapper to install and run
apps.

Second, the Go exec wrapper must be told the developer account signing identity, the team
id and a provisioned bundle id to use. They're specified with the environment variables
GOIOS_DEV_ID, GOIOS_TEAM_ID and GOIOS_APP_ID. The detect.go program in this directory will
attempt to auto-detect suitable values. Run it as

	go run detect.go

which will output something similar to

	export GOIOS_DEV_ID="iPhone Developer: xxx@yyy.zzz (XXXXXXXX)"
	export GOIOS_APP_ID=YYYYYYYY.some.bundle.id
	export GOIOS_TEAM_ID=ZZZZZZZZ

If you have multiple devices connected, specify the device UDID with the GOIOS_DEVICE_ID
variable. Use `idevice_id -l` to list all available UDIDs.

Finally, to run the standard library tests, run iostest.bash with GOARCH set. For example,

	GOARCH=arm64 ./iostest.bash

To use the go tool directly to run programs and tests, put $GOROOT/bin into PATH to ensure
the go_darwin_$GOARCH_exec wrapper is found. For example, to run the archive/tar tests

	export PATH=$GOROOT/bin:$PATH
	GOARCH=arm64 go test archive/tar

Note that the go_darwin_$GOARCH_exec wrapper uninstalls any existing app identified by
the bundle id before installing a new app. If the uninstalled app is the last app by
the developer identity, the device might also remove the permission to run apps from
that developer, and the exec wrapper will fail to install the new app. To avoid that,
install another app with the same developer identity but with a different bundle id.
That way, the permission to install apps is held on to while the primary app is
uninstalled.