Skip to content

Commit c8f93f2

Browse files
authored
Use xcrun to discover Apple SDK paths (#912)
Tested in flutter/engine#55818
1 parent 54a9a91 commit c8f93f2

File tree

2 files changed

+11
-31
lines changed

2 files changed

+11
-31
lines changed

build/config/ios/ios_sdk.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,10 @@ def main(argv):
9393

9494
for sdk in sdks:
9595
command = [
96-
'xcodebuild',
97-
'-version',
98-
'-sdk',
96+
'xcrun',
97+
'--sdk',
9998
sdk,
100-
'Path'
99+
'--show-sdk-path',
101100
]
102101
sdk_output = run_command_with_retry(command, timeout=300)
103102
if symlink_path:

build/mac/find_sdk.py

+8-27
Original file line numberDiff line numberDiff line change
@@ -91,32 +91,14 @@ def main():
9191
'|sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer| '
9292
'if you are using Xcode 4.') % job.returncode)
9393

94-
sdk_command = ['xcodebuild',
95-
'-showsdks',
96-
'-json']
97-
sdk_json_output = run_command_with_retry(sdk_command, timeout=300)
98-
sdk_json = json.loads(sdk_json_output)
99-
100-
best_sdk = None
101-
sdk_output = None
102-
103-
# Xcode can return the same version for different symlinked paths.
104-
# Sort by path to keep the list stable between runs.
105-
for properties in sorted(list(sdk_json), key=lambda d: d['sdkPath']):
106-
# Filter out macOS DriverKit, watchOS, AppleTV, and other SDKs.
107-
if properties.get('platform') != 'macosx' or 'driver' in properties.get('canonicalName'):
108-
continue
109-
sdk_version = properties['sdkVersion']
110-
parsed_version = parse_version(sdk_version)
111-
if (parsed_version >= parse_version(min_sdk_version) and
112-
(not best_sdk or parsed_version < parse_version(best_sdk))):
113-
best_sdk = sdk_version
114-
sdk_output = properties['sdkPath']
115-
116-
if not best_sdk:
117-
print(sdk_json_output)
118-
raise Exception('No %s+ SDK found' % min_sdk_version)
119-
94+
# xcrun --sdk macosx --show-sdk-path
95+
sdk_command = [
96+
'xcrun',
97+
'--sdk',
98+
'macosx',
99+
'--show-sdk-path',
100+
]
101+
sdk_output = run_command_with_retry(sdk_command, timeout=300)
120102
if symlink_path:
121103
sdks_path = os.path.join(symlink_path, 'SDKs')
122104
symlink_target = os.path.join(sdks_path, os.path.basename(sdk_output))
@@ -125,7 +107,6 @@ def main():
125107

126108
if not options.as_gclient_hook:
127109
print(sdk_output)
128-
print(best_sdk)
129110
return 0
130111

131112

0 commit comments

Comments
 (0)