Skip to content

Commit 2f183e2

Browse files
authored
build_testapps.py tvOS device profiles (#522)
* Update `build_testapps.py` to pass the target os (`iOS` or `tvOS`) to the `xcodebuild.py` build script. * `xcodebuild.py` now populates the correct device profiles `appletvos` and `appletvsimulator` for `device` and `simulator` iOS SDK types, respectively.
1 parent a6af776 commit 2f183e2

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

scripts/gha/build_testapps.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,8 @@ def build_testapp(dir_helper, api_config, ios_config, target):
474474
os.path.join(dir_helper.unity_project_editor_dir, "dev.entitlements"))
475475
_run(arg_builder.get_args_to_open_project(build_flags))
476476
logging.info("Finished building target %s xcode project", target)
477-
run_xcodebuild(dir_helper=dir_helper, ios_config=ios_config, device_type = device_type)
477+
run_xcodebuild(dir_helper=dir_helper, ios_config=ios_config, device_type = device_type,
478+
target_os = target)
478479
else:
479480
if api_config.minify:
480481
build_flags += ["-AppBuilderHelper.minify", api_config.minify]
@@ -617,7 +618,7 @@ def perform_in_editor_tests(dir_helper, retry_on_license_check=True):
617618
return text
618619

619620

620-
def run_xcodebuild(dir_helper, ios_config, device_type):
621+
def run_xcodebuild(dir_helper, ios_config, device_type, target_os):
621622
"""Uses xcode project generated by Unity to build an iOS or tvOS binary."""
622623
build_output_dir = os.path.join(dir_helper.output_dir, "ios_output_"+device_type)
623624
_run(
@@ -626,6 +627,7 @@ def run_xcodebuild(dir_helper, ios_config, device_type):
626627
scheme=ios_config.scheme,
627628
output_dir=build_output_dir,
628629
ios_sdk=_IOS_SDK[device_type],
630+
target_os=target_os,
629631
configuration=ios_config.configuration))
630632
if device_type == _DEVICE_REAL:
631633
xcodebuild.generate_unsigned_ipa(

scripts/gha/integration_testing/xcodebuild.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import shutil
3737

3838

39-
def get_args_for_build(path, scheme, output_dir, ios_sdk, configuration):
39+
def get_args_for_build(path, scheme, output_dir, ios_sdk, target_os, configuration):
4040
"""Constructs subprocess args for an unsigned xcode build.
4141
4242
Args:
@@ -45,7 +45,8 @@ def get_args_for_build(path, scheme, output_dir, ios_sdk, configuration):
4545
scheme (str): Name of the scheme to build.
4646
output_dir (str): Directory for the resulting build artifacts. Will be
4747
created if it doesn't already exist.
48-
ios_sdk (str): Where this build will be run: device or simulator.
48+
ios_sdk (str): Where this build will be run: "device" or "simulator".
49+
target_os (str): one of "iOS" or "tvOS".
4950
configuration (str): Value for the -configuration flag.
5051
5152
Returns:
@@ -54,7 +55,7 @@ def get_args_for_build(path, scheme, output_dir, ios_sdk, configuration):
5455
"""
5556
args = [
5657
"xcodebuild",
57-
"-sdk", _get_ios_env_from_target(ios_sdk),
58+
"-sdk", _get_ios_env_from_target(ios_sdk, target_os),
5859
"-scheme", scheme,
5960
"-configuration", configuration,
6061
"-quiet",
@@ -79,14 +80,24 @@ def get_args_for_build(path, scheme, output_dir, ios_sdk, configuration):
7980
return args
8081

8182

82-
def _get_ios_env_from_target(ios_sdk):
83+
def _get_ios_env_from_target(ios_sdk, target_os):
8384
"""Return a value for the -sdk flag based on the target (device/simulator)."""
84-
if ios_sdk == "device":
85-
return "iphoneos"
86-
elif ios_sdk == "simulator":
87-
return "iphonesimulator"
85+
if target_os == "iOS":
86+
if ios_sdk == "device":
87+
return "iphoneos"
88+
elif ios_sdk == "simulator":
89+
return "iphonesimulator"
90+
else:
91+
raise ValueError("Unrecognized iOS ios_sdk paramter: %s" % ios_sdk)
92+
elif target_os == "tvOS":
93+
if ios_sdk == "device":
94+
return "appletvos"
95+
elif ios_sdk == "simulator":
96+
return "appletvsimulator"
97+
else:
98+
raise ValueError("Unrecognized tvOS ios_sdk parameter: %s" % sdk)
8899
else:
89-
raise ValueError("Unrecognized ios_sdk: %s" % ios_sdk)
100+
raise ValueError("Unrecognized target_os %s for ios_sdk %s" % (target_os, ios_sdk))
90101

91102

92103
def generate_unsigned_ipa(output_dir, configuration):

0 commit comments

Comments
 (0)