macOS version number problems in build script
ryandesign opened this issue · 1 comments
Hi,
There are several problems in lisaem/scripts/build-wx3.1.4-modern-macosx.sh relating to macOS versions.
Near the top, there is code to determine the latest SDK version, which runs xcodebuild -showsdks 2>/dev/null | grep macosx10
. This will fail to locate the macOS 11 SDK and future versions. If you need to identify the SDK version—which I am not certain that you do—you could instead use xcodebuild -showsdks 2>/dev/null | grep 'sdk macosx'
.
It then interprets this SDK version as if it were the deployment target—the earliest macOS version to build for—by passing it to ./configure
as the flag --with-macosx-version-min=$MIN_MACOSX_VERSION
. This will not necessarily be correct; the SDK version number should not be used in this way. It has been Apple's habit for years to release versions of Xcode that contain only the latest macOS SDK, even if that version of Xcode runs on a previous macOS version. For example, Xcode 7.2.1 runs on OS X 10.10 and 10.11 but only contains MacOSX10.11.sdk. On OS X 10.10 with Xcode 7.2.1, your code would run ./configure
with --with-macosx-version-min=10.11
which could result in a program that cannot run on 10.10. The simplest solution could be not to specify the min version at all. macOS will default to the current OS version in that case. If that's not satisfactory, perhaps because the configure script picks its own incorrect default if it's not specified, then you could use --with-macosx-version-min=$(sw_vers -productVersion | cut -d. -f1-2)
.
Finally, your script uses the bash operators <
and >
to do version comparisons, which will not have the desired result because that's not what those operators do. Instead, they check ASCII sort order. For example, the script contains the check if [[ "$OSVER" > "macOS-10.14" ]]
which will not have the desired result if for example OSVER
is macOS-10.9
: the script will consider macOS-10.9
to be greater than macOS-10.14
. Version number comparison is a difficult task to perform generally. There is no function to do this built into bash. There are several attempts at implementing such a function on Stack Overflow with various tradeoffs. If you only need to compare OS version numbers, it would be simpler to use the Darwin major version (uname -r | cut -d. -f1
) rather than the macOS version since the Darwin major version is a single integer and Bash does have integer comparison operators.
This is fixed in the unstable branch (as well as RC3a I think):
https://github.com/rayarachelian/lisaem/blob/unstable/scripts/build-wx3.1.4-modern-macosx.sh