Saturday, June 24, 2017

Gomobile in MAC


Gomobile Installed in Mac

Download pkg

You might download golang's latest release in Mac.

And intall it by double click it.


It will install package under /Users/xxx/go

junmeinde-MacBook-Pro:src junmein$ pwd


junmeinde-MacBook-Pro:src junmein$ export GOPATH=/Users/junmein/go

Install Gomobile and Build Framework In Mac

Get gomobile

go get

Binding You golang code to IOS

junmeinde-MacBook-Pro:src junmein$ /Users/junmein/go/bin/gomobile bind -target=ios

You will get Hello.framework for IOS

junmeinde-MacBook-Pro:src junmein$ ls

Compile Hello.Framework in Xcode

Put Hello.Framework in xcode

drag and drop hello.framework to xcode project

Adding code to existed code

import Hello
let msg = HelloGreetings("golang haha")

Disable Bitcode check

Project -> search -> bicode -> no

If you ignore this steps, it will case the errors

link comand failed xcode framework

Thanks for this blog, it really help me a lot


You can download the result from my github


Gomobile Installed in Ubuntu

It failed and with this exception.

/root/golang/bin/gomobile: exec: "xcrun": executable file not found in $PATH

More Reference

No comments:

Post a Comment