Cross-compiling for macOS

With Windows and Linux (and some BSD flavours), all cross-compiling completes without CGO, therefore, we only need to look at macOS as a special case. To cross-compile successfully for macOS, we must add CGO_ENABLED=1 to our build, which will then look for the required system libraries. Clearly, these are not normally available and so we must set up our development environment to provide the required APIs.

The procedure for setting up the clang binary and required API bundles for macOS cross-compiling is a complicated process, but if you worked through Chapter 5, andlabs UI - Cross-platform Native UIs, this will already be set up. If you've jumped straight to this chapter, then you may need to follow the steps in the Appendix, Cross-Compiler Setup, under Cross-compiling for macOS with cgo. Once that's complete, you should have a new compiler available named o32-clang, which is able to link to macOS Foundation APIs.

To build the application, we now set up the GOOS and CGO_ENABLED flags as before, but also specify the compiler to use through an extra CC environment variable, setting it to o32-clang. With that configuration complete, we can build a macOS Shiny application from our Linux Terminal:

Building a macOS application from a Linux terminal

Applications built in this manner will have full OpenGL acceleration as though they were built directly on a macOS computer.

Now that we've seen all of the details for building with Shiny, let's explore how these applications are designed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.65.130