Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/mobile: Building the framework for OSX #13310

Closed
damouse opened this issue Nov 18, 2015 · 4 comments
Closed

x/mobile: Building the framework for OSX #13310

damouse opened this issue Nov 18, 2015 · 4 comments

Comments

@damouse
Copy link

damouse commented Nov 18, 2015

Using gomobile bind I'm able to build my go package into a framework for iOS. I would like to do this for OSX as well. I tried working around gomobile and creating a library using just go build but I get warnings that -linkshared is only supported on linux/amd64. Also tried setting ARCH and OS flags, didn't seem to affect gomobile.

I would like to put together a script that compiles both frameworks at once. Is such a thing possible using just gomobile? Can I build the library on linux and move it to OSX?

@crawshaw
Copy link
Member

Sorry, supporting non-mobile operating systems is not a goal right now for gomobile. It would be nice to see gobind generally supported for OS X one day, but there's significant work to be done.

@damouse
Copy link
Author

damouse commented Nov 18, 2015

Damn. I was hoping I could just compile a library for x86 using go build and essentially replace the lib gomobile produces. I take it theres more going on here?

Alternatively, can you briefly outline what would need to be done?

@crawshaw
Copy link
Member

I believe an OS X framework can be dynamically loaded, which is different from iOS and not yet supported. So what the gomobile tool is doing will not generate a framework for OS X.

@hyangah reminded me today that in its current state, gobind can be used on OS X. But you have to statically link the generated code into your C program. You can try building a .a file with go build -buildmode=c-archive. Have a read through https://github.com/golang/mobile/blob/master/bind/objc/test.bash.

@jeanlucmongrain
Copy link

@damouse

With that simple commit https://github.com/bclermont/mobile/commit/27e1b66f2aabbd2abe32bd8cf7e316cb9f9f9371

I switched from iPhone simulator to OSX to build a .framework with gomobile bind.

Using https://github.com/bclermont/mobile/commit/27e1b66f2aabbd2abe32bd8cf7e316cb9f9f9371#commitcomment-16297002 I could remove the iOS binary.

Then, this .framework can be used in Xcode to build a native OSX application.

@crawshaw I think it's a simple change that could add to gomobile a new target for OSX. At least for the bind part of it.

@golang golang locked and limited conversation to collaborators Feb 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants