aboutsummaryrefslogtreecommitdiff
path: root/misc/ios
diff options
context:
space:
mode:
authorElias Naur <elias.naur@gmail.com>2018-05-10 17:38:23 +0200
committerElias Naur <elias.naur@gmail.com>2018-05-10 18:01:20 +0000
commit25f73db0b66c9bfbf7ea7d46feb6db4de49da003 (patch)
tree8db1786ad801b37b3fd6aa58ad7132f48a00063c /misc/ios
parent599f56dc0502d36d9dcae73c72ed114a41d1ecc0 (diff)
downloadgo-25f73db0b66c9bfbf7ea7d46feb6db4de49da003.tar.gz
go-25f73db0b66c9bfbf7ea7d46feb6db4de49da003.zip
misc/ios: update documentation for running iOS programs and tests
Change-Id: I8e3077ab9c7dff66877ac00dc4600b53c07eb1f8 Reviewed-on: https://go-review.googlesource.com/112655 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'misc/ios')
-rw-r--r--misc/ios/README88
1 files changed, 47 insertions, 41 deletions
diff --git a/misc/ios/README b/misc/ios/README
index 417a217892..83fa2d6fc7 100644
--- a/misc/ios/README
+++ b/misc/ios/README
@@ -1,44 +1,50 @@
Go on iOS
=========
-To build a cross compiling toolchain for iOS on OS X, first modify clangwrap.sh
-in misc/ios to match your setup. And then run:
-
- GOARM=7 CGO_ENABLED=1 GOARCH=arm CC_FOR_TARGET=`pwd`/../misc/ios/clangwrap.sh \
- CXX_FOR_TARGET=`pwd`/../misc/ios/clangwrap.sh ./make.bash
-
-To build a program, use the normal go build command:
-
- CGO_ENABLED=1 GOARCH=arm go build import/path
-
-To run a program on an iDevice, first make sure you have a valid developer
-certificate and have setup your iDevice properly to run apps signed by your
-developer certificate. Then install https://github.com/phonegap/ios-deploy.
-At a first step, you can try building the famous hello world program to run
-on your test device.
-(The needed files are provided at https://github.com/minux/go-ios-examples.)
-
- # assume your program binary is helloworld.go, build it into the
- # example hello.app bundle.
- CGO_ENABLED=1 GOARCH=arm go build -o hello.app/hello helloworld.go
- # sign the executable using your developer certificate
- codesign -f -s "iPhone Developer" --entitlements hello.app/Entitlements.plist hello.app/hello
- # run the program inside lldb on iDevice, run `ios-deploy` for more
- # command options
- ios-deploy --debug --uninstall --bundle hello.app
- # Depending on your ios-deploy version, you might need to enter "run"
- # into lldb to run your program, and its output will be shown by lldb.
-
-Notes:
- - A dummy hello.app bundle is provided in this directory to help you get started.
- - Running the program on an iDevice requires code sign and thus external linking,
- if your program uses cgo, then it will automatically use external linking.
- However, if your program does not use cgo, please make sure to add
- import _ "runtime/cgo"
- so that external linking will be used.
-
-Known issues
-============
- - crypto/x509 won't build, I don't yet know how to get system root on iOS.
- - Because I still want to be able to do native build, CGO_ENABLED=1 is not the
- default, yet.
+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.