gomobileでiOS用のライブラリをビルドするまで

2015-07-26#ios#go

$ cd
$ brew uninstall go
$ bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
$ vi .zprofile.local
# gvm
[[ -s "$HOME/.gvm/scripts/gvm" ]] && source "$HOME/.gvm/scripts/gvm"
$ source .zprofile
$ gvm install go1.4.2
$ gvm use go1.4.2 --default
$ GOROOT_BOOTSTRAP=$GOROOT gvm install go1.5beta2
$ gvm use go1.5beta2 --default
$ go get golang.org/x/mobile/cmd/gomobile
$ gomobile init -v
$ cd $GOROOT/src
$ mkdir gomobile_playground && cd $_
$ mkdir hello
$ vi hello/hello.go
package hello

func World() string {
    return "Hello, world!"
}
$ cd hello
$ gomobile bind -target ios
$ ls
hello.framework hello.go
// Objective-C API for talking to github.com/naoty/gomobile_playground/hello Go package.
//   gobind -lang=objc github.com/naoty/gomobile_playground/hello
//
// File is generated by gobind. Do not edit.

#ifndef __GoHello_H__
#define __GoHello_H__

#include <Foundation/Foundation.h>

FOUNDATION_EXPORT NSString* GoHelloWorld();

#endif