Use xcrun to discover Apple SDK paths (#912)
Tested in https://github.com/flutter/engine/pull/55818
diff --git a/build/config/ios/ios_sdk.py b/build/config/ios/ios_sdk.py
index 607a425..bcbd700 100644
--- a/build/config/ios/ios_sdk.py
+++ b/build/config/ios/ios_sdk.py
@@ -93,11 +93,10 @@
for sdk in sdks:
command = [
- 'xcodebuild',
- '-version',
- '-sdk',
+ 'xcrun',
+ '--sdk',
sdk,
- 'Path'
+ '--show-sdk-path',
]
sdk_output = run_command_with_retry(command, timeout=300)
if symlink_path:
diff --git a/build/mac/find_sdk.py b/build/mac/find_sdk.py
index 73cf268..2471eba 100755
--- a/build/mac/find_sdk.py
+++ b/build/mac/find_sdk.py
@@ -91,32 +91,14 @@
'|sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer| '
'if you are using Xcode 4.') % job.returncode)
- sdk_command = ['xcodebuild',
- '-showsdks',
- '-json']
- sdk_json_output = run_command_with_retry(sdk_command, timeout=300)
- sdk_json = json.loads(sdk_json_output)
-
- best_sdk = None
- sdk_output = None
-
- # Xcode can return the same version for different symlinked paths.
- # Sort by path to keep the list stable between runs.
- for properties in sorted(list(sdk_json), key=lambda d: d['sdkPath']):
- # Filter out macOS DriverKit, watchOS, AppleTV, and other SDKs.
- if properties.get('platform') != 'macosx' or 'driver' in properties.get('canonicalName'):
- continue
- sdk_version = properties['sdkVersion']
- parsed_version = parse_version(sdk_version)
- if (parsed_version >= parse_version(min_sdk_version) and
- (not best_sdk or parsed_version < parse_version(best_sdk))):
- best_sdk = sdk_version
- sdk_output = properties['sdkPath']
-
- if not best_sdk:
- print(sdk_json_output)
- raise Exception('No %s+ SDK found' % min_sdk_version)
-
+ # xcrun --sdk macosx --show-sdk-path
+ sdk_command = [
+ 'xcrun',
+ '--sdk',
+ 'macosx',
+ '--show-sdk-path',
+ ]
+ sdk_output = run_command_with_retry(sdk_command, timeout=300)
if symlink_path:
sdks_path = os.path.join(symlink_path, 'SDKs')
symlink_target = os.path.join(sdks_path, os.path.basename(sdk_output))
@@ -125,7 +107,6 @@
if not options.as_gclient_hook:
print(sdk_output)
- print(best_sdk)
return 0