We have been able to make a few improvements to the
gomobile bind command that enables Swift bindings more seamlessly. I have published a comprehensive document as a blog post that provides a step by step guide. If you are already a Swift developer, please take a look and give feedback directly here.
Please note that this is highly experimental and the APIs require improvement.
$ gomobile bind -target=ios golang.org/x/mobile/example/bind/hello
Drag and drop the Hello.framework to the Xcode project.
I ran through the blog post. Nicely done. Straight forward and easy to follow. I got the framework built and added to a test project. Works like a charm. I ran into two things I figured I should give feedback on.
- When running the initial
gomobile init I received this error:
gomobile: go install -p=4 -pkgdir=/Users/Austin/Documents/code/go/pkg/gomobile/pkg_darwin_arm std failed: exit status 2
exec: "2015-10-03": executable file not found in $PATH
I changed into my $GOPATH (I wasn’t originally there when I ran
gomobile init) and it worked the second time.
2.Clang/ld is giving a linker error about position independent code, like so:
ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in runtime.rodata from /Users/Austin/Documents/code/swift/Gopher/Gopher/Hello.framework/Hello(go.o). To fix this warning, don’t compile with -mdynamic-no-pic or link with -Wl,-no_pie
Do you get the same warning? I’m using Xcode 7.0.1 (7A1001) against an iOS 9 project on the simulator.
One other thing that I might add to the example would be to print the output from
Hello.GoHelloGreetings("gopher") call. I figured it would print at first until I looked up the code. Overall, everything worked quite smoothly though. Excited to see Go working on iOS!
Could you file bug for the first case at https://golang.org/issue/new? If you can provide
gomobile init -x's output, it would be beneficial.
The absolute addressing bug has been fixed at https://github.com/golang/go/issues/12590, and will be a part of 1.6. Unfortunately, this is going to be blocker for iOS bindings until Go 1.6 is released
I am making sure that I am logging the output of GoHelloGreetings. Thanks!
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.