1010from lib .shell import shell , cp_r
1111from lib .model import Configuration
1212from lib .lipo_util import LipoUtil
13- from lib .dependencies import FRAMEWORK_DEPS , PRIVATE_FRAMEWORK_DEPS , DYLIB_DEPS
1413
1514
1615class DefaultHelpParser (argparse .ArgumentParser ):
@@ -22,6 +21,17 @@ def error(self, message):
2221 sys .exit (2 )
2322
2423
24+ def _parse_xcode_version (version_str : str ) -> int :
25+ """Gets the version number of the given version string."""
26+ parts = version_str .split ('.' )
27+ version_number = int (parts [0 ]) * 100
28+ if len (parts ) > 1 :
29+ version_number += int (parts [1 ]) * 10
30+ if len (parts ) > 2 :
31+ version_number += int (parts [2 ])
32+ return version_number
33+
34+
2535def main (argv ) -> None :
2636 "Script entrypoint."
2737 parser = DefaultHelpParser ()
@@ -46,6 +56,11 @@ def main(argv) -> None:
4656 action = "append" ,
4757 help = "Path to xctest archive to bundle." ,
4858 )
59+ parser .add_argument (
60+ "--xcode-version" ,
61+ required = True ,
62+ help = "Current Xcode version." ,
63+ )
4964 parser .add_argument (
5065 "--verbose" ,
5166 required = False ,
@@ -142,8 +157,32 @@ def main(argv) -> None:
142157 plist ["CFBundleIdentifier" ] = config .xctrunner .bundle_identifier
143158 plistlib .dump (plist , open (config .xctrunner .info_plist_path , "wb" ))
144159
160+
161+ framework_deps = [
162+ "XCTest.framework" ,
163+ "Testing.framework" , # Xcode 16+
164+ ]
165+
166+ private_framework_deps = [
167+ "XCTAutomationSupport.framework" ,
168+ "XCTestCore.framework" ,
169+ "XCTestSupport.framework" ,
170+ "XCUnit.framework" ,
171+ ]
172+
173+ dylib_deps = [
174+ "libXCTestBundleInject.dylib" ,
175+ "libXCTestSwiftSupport.dylib" ,
176+ ]
177+
178+ xcode_version_int = _parse_xcode_version (args .xcode_version )
179+ if xcode_version_int >= 1640 :
180+ framework_deps .append ("XCUIAutomation.framework" )
181+ else :
182+ private_framework_deps .append ("XCUIAutomation.framework" )
183+
145184 # Copy dependencies to the bundle and remove unwanted architectures
146- for framework in FRAMEWORK_DEPS :
185+ for framework in framework_deps :
147186 log .info ("Bundling fwk: %s" , framework )
148187 fwk_path = f"{ config .xcode .frameworks_dir } /{ framework } "
149188
@@ -162,7 +201,7 @@ def main(argv) -> None:
162201 bin_path , archs_to_keep
163202 ) # Strip architectures not in test bundles.
164203
165- for framework in PRIVATE_FRAMEWORK_DEPS :
204+ for framework in private_framework_deps :
166205 log .info ("Bundling fwk: %s" , framework )
167206 cp_r (
168207 f"{ config .xcode .private_frameworks_dir } /{ framework } " ,
@@ -172,7 +211,7 @@ def main(argv) -> None:
172211 bin_path = f"{ config .xctrunner .path } /Frameworks/{ framework } /{ fwk_binary } "
173212 lipo .extract_or_thin (bin_path , archs_to_keep )
174213
175- for dylib in DYLIB_DEPS :
214+ for dylib in dylib_deps :
176215 log .info ("Bundling dylib: %s" , dylib )
177216 shutil .copy (
178217 f"{ config .xcode .dylib_dir } /{ dylib } " ,
0 commit comments