github.com/likebike/go--@v0.0.0-20190911215757-0bd925d16e96/go/misc/ios/README (about)

     1  Go on iOS
     2  =========
     3  
     4  To build a cross compiling toolchain for iOS on OS X, first modify clangwrap.sh
     5  in misc/ios to match your setup. And then run:
     6  
     7  	GOARM=7 CGO_ENABLED=1 GOARCH=arm CC_FOR_TARGET=`pwd`/../misc/ios/clangwrap.sh \
     8  	CXX_FOR_TARGET=`pwd`/../misc/ios/clangwrap.sh ./make.bash
     9  
    10  To build a program, use the normal go build command:
    11  
    12  	CGO_ENABLED=1 GOARCH=arm go build import/path
    13  
    14  To run a program on an iDevice, first make sure you have a valid developer
    15  certificate and have setup your iDevice properly to run apps signed by your
    16  developer certificate. Then install https://github.com/phonegap/ios-deploy.
    17  At a first step, you can try building the famous hello world program to run
    18  on your test device.
    19  (The needed files are provided at https://github.com/minux/go-ios-examples.)
    20  
    21  	# assume your program binary is helloworld.go, build it into the
    22  	# example hello.app bundle.
    23  	CGO_ENABLED=1 GOARCH=arm go build -o hello.app/hello helloworld.go
    24  	# sign the executable using your developer certificate
    25  	codesign -f -s "iPhone Developer" --entitlements hello.app/Entitlements.plist hello.app/hello
    26  	# run the program inside lldb on iDevice, run `ios-deploy` for more
    27  	# command options
    28  	ios-deploy --debug --uninstall --bundle hello.app
    29  	# Depending on your ios-deploy version, you might need to enter "run"
    30  	# into lldb to run your program, and its output will be shown by lldb.
    31  
    32  Notes:
    33   - A dummy hello.app bundle is provided in this directory to help you get started.
    34   - Running the program on an iDevice requires code sign and thus external linking,
    35     if your program uses cgo, then it will automatically use external linking.
    36     However, if your program does not use cgo, please make sure to add
    37  	import _ "runtime/cgo"
    38     so that external linking will be used.
    39  
    40  Known issues
    41  ============
    42   - crypto/x509 won't build, I don't yet know how to get system root on iOS.
    43   - Because I still want to be able to do native build, CGO_ENABLED=1 is not the
    44     default, yet.