Skip to content

Instantly share code, notes, and snippets.

@mitchellh
Created June 14, 2025 03:22
Show Gist options
  • Save mitchellh/351c37999031a82119cb50b41dc755ba to your computer and use it in GitHub Desktop.
Save mitchellh/351c37999031a82119cb50b41dc755ba to your computer and use it in GitHub Desktop.
A helper to check if liquid glass is available and enabled...
/// True if we have liquid glass available and enabled.
///
/// NOTE: This does not check for the UIDesignRequiresCompatibility key
/// because I didn't need it.
func hasLiquidGlass() -> Bool {
// Can't have liquid glass unless we're in macOS 26+
if #unavailable(macOS 26.0) {
return false
}
// If we aren't running SDK 26.0 or later then we definitely
// do not have liquid glass.
guard let sdkName = Bundle.main.infoDictionary?["DTSDKName"] as? String else {
// If we don't have this, we assume we're built against the latest
// since we're on macOS 26+
return true
}
// If the SDK doesn't start with macosx then we just assume we
// have it because we already verified we're on macOS above.
guard sdkName.hasPrefix("macosx") else {
return true
}
// The SDK version must be at least 26
let versionString = String(sdkName.dropFirst("macosx".count))
guard let major = if let dotIndex = versionString.firstIndex(of: ".") {
Int(String(versionString[..<dotIndex]))
} else {
Int(versionString)
} else { return true }
// Note: we could also check for the UIDesignRequiresCompatibility key
// but our project doesn't use it so there's no point.
return major >= 26
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment