'How to build a Go app that can cross-macOS-version?

Here is my recently created macOS app: https://github.com/evillt/macmineable-release
and here is my facing issue: https://github.com/evillt/macmineable-release/issues/18

I built the app on my machine it can run normally on any BigSur device, even M1 devices, but can not run on Catalina(10.15).

So what I want is to build a version that can run on multi-macOS-version with a single app.

Huge thanks for any suggestions!

update

My device is MacBook Pro 2015, Intel I5 chip, Big Sur 11.5.2.

I build this app on my device, it can run normally on:

  • My device
  • MacBook 12-inch Big Sur 11.0
  • Other M1 devices (Big Sur 11.0 or above)

But can not run on MacBook Pro Intel I7 Catalina 10.15.7. The issue here.

That is all I know.



Solution 1:[1]

You need to change the CC compile go uses during your builds.

 go env CC

 clang

which most likely uses the version in /usr/bin/clang

if you have Xcode installed - or really just the Command Line Tools you can see a variety of versions for the last few major releases e.g.:

$ find  /Library/Developer/CommandLineTools -name clang

/Library/Developer/CommandLineTools/usr/bin/clang
/Library/Developer/CommandLineTools/usr/lib/clang
/Library/Developer/CommandLineTools/usr/lib/swift/clang
/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/A/lib/clang
/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk/System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/A/lib/clang
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/A/lib/clang
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang

so to build against an older SDK like MaxOSX10.15, set CC to the explicit version you need for your go build like so:

CC=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang go build

Solution 2:[2]

I have good experience building as a Unix executable and packaging as a Mac app, by using the instructions manual at https://medium.com/@mattholt/packaging-a-go-application-for-macos-f7084b00f6b5

build Unix exec file
go build -o bin/{program} {program}

Packaging the application on macOS (Big Sur) and installing it on macOS (High Sierra) was successful.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 colm.anseo
Solution 2 Dave Yarwood