diff --git a/Library/Homebrew/os/mac/sdk.rb b/Library/Homebrew/os/mac/sdk.rb index bfc648fce5..d5869888db 100644 --- a/Library/Homebrew/os/mac/sdk.rb +++ b/Library/Homebrew/os/mac/sdk.rb @@ -52,7 +52,17 @@ module OS rescue NoSDKError latest_sdk end - # Only return an SDK older than the OS version if it was specifically requested + # Accept an SDK for another OS version if it shares a major version + # with the current OS - for example, the 11.0 SDK on 11.1, + # or vice versa. + # Note that this only applies on macOS 11 + # or greater, given the way the versioning has changed. + # This shortcuts the below check, since we *do* accept an older version + # on macOS 11 or greater if the major version matches. + return sdk if sdk.present? && OS::Mac.version >= :big_sur && sdk.version.major == OS::Mac.version.major + + # On OSs lower than 11, or where the major versions don't match, + # only return an SDK older than the OS version if it was specifically requested return unless v || (sdk.present? && sdk.version >= OS::Mac.sdk_version) sdk