Version: v0.0.0-...-ae31599 Latest Latest

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

Go to latest
Published: Oct 8, 2015 License: BSD-3-Clause Imports: 15 Imported by: 0


Go on iOS

To build a cross compiling toolchain for iOS on OS X, first modify
in misc/ios to match your setup. And then run:

	GOARM=7 CGO_ENABLED=1 GOARCH=arm CC_FOR_TARGET=`pwd`/../misc/ios/ \
	CXX_FOR_TARGET=`pwd`/../misc/ios/ ./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
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

	# assume your program binary is helloworld.go, build it into the
	# example bundle.
	CGO_ENABLED=1 GOARCH=arm go build -o helloworld.go
	# sign the executable using your developer certificate
	codesign -f -s "iPhone Developer" --entitlements
	# run the program inside lldb on iDevice, run `ios-deploy` for more
	# command options
	ios-deploy --debug --uninstall --bundle
	# 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.

 - A dummy 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.



This program can be used as go_darwin_arm_exec by the Go tool. It executes binaries on an iOS device using the XCode toolchain and the ios-deploy program:

This script supports an extra flag, -lldb, that pauses execution just before the main program begins and allows the user to control the remote lldb session. This flag is appended to the end of the script's arguments and is not passed through to the underlying binary.

This script requires that three environment variables be set:

GOIOS_DEV_ID: The codesigning developer id or certificate identifier
GOIOS_APP_ID: The provisioning app id prefix. Must support wildcard app ids.
GOIOS_TEAM_ID: The team id that owns the app id prefix.

$GOROOT/misc/ios contains a script, detect.go, that attempts to autodetect these.

Jump to

Keyboard shortcuts

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