It is possible to build packages that are compatible with older macOS versions?

I’m using macOS 10.13 to do release builds of my applications. The applications are supposed to run on older versions of macOS as well. If I export MACOSX_DEPLOYMENT_TARGET=10.10 when running brew and make sure to never install bottles, will it work? Can I then copy the Homebrew-build dependencies into my application bundles for use on different macOS versions? Does anyone have any experiences with this?

Up until now, I’ve been building the dependencies by hand, making sure to use the correct MACOSX_DEPLOYMENT_TARGET so I can bundle them alongside my applications. But the effort for doing this manually is getting out of hand. Building glib for example is kind of a dependency hell nowadays.

Foregoing the whole “unsupported macOS versions can easily introduce security issues and probably shouldn’t be encouraged”, most environment variables are filtered by homebrew. This is true regardless of source builds. I think your easiest solution here is either statically linked dependencies outside of brew or dynamic ones that brew ships that your package encourages to install through brew.

I see. No, I don’t want to tell Mac people to enter (what to them appear to be) arcane terminal commands when what they want is simply drag&drop an icon into their Applications folder :slight_smile:

Thanks for clarifying!

You could make a cask :smile: everything brewed !!

No, sorry.

My recommendation would be to build everything you wish to with Homebrew on a VM for the oldest version of macOS you wish to support.

That’s not possible, unfortunately, because modern Xcode versions cannot be installed on older macOS versions. I use the latest available Xcode version, which allows me to use modern macOS features, but the applications still run on older versions due to the whole linking magic Apple does.

I wonder though if I can modify Homebrew to not unset the MACOSX_DEPLOYMENT_TARGET env var. It should then, in theory, apply to everything Homebrew builds, since that var is looked up directly by clang, regardless of CFLAGS/CXXFLAGS.

Yep, I realise that. You would have to use an older Xcode version.

You may be able to make this work but Homebrew makes many assumptions that this isn’t the case so it is unlikely to be reliable, unfortunately.

For anyone finding this through a search, I managed to make it work by targeting 10.3 as the oldest supported macOS version while building my applications on 10.5 with modern XCode. To do this, I’ve installed homebrew in a VM running 10.3 and installed all needed deps there. Then packaged /usr/local and copied it to my 10.5 install.

In 10.3:

cd /usr/local
tar cf ~/usr_local_10.3.tar *

(cding into /usr/local first and using * instead of ./ is required due to how tar works.)

Copy usr_local_10.3.tar to 10.5 and:

cd /usr/local
sudo rm -rf *
sudo tar xf ~/usr_local_10.3.tar
sudo rm bin/brew

Deleting the brew binary avoids the issue of using brew by mistake, which would most probably break everything. Obviously you cannot maintain this in 10.5. Every time you want to install a new dep or update, you need to do so in 10.3 and repeat the process.