Skip to content

XCodebuild Environment Variable Setup #314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Mar 27, 2025
13 changes: 13 additions & 0 deletions builder/actions/setup_cross_ci_crt_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,23 @@


class SetupCrossCICrtEnvironment(Action):
""" Setup Environment Variables for CI Unit Tests """

def __init__(self, use_xcodebuild=False):
# is_xcodebuild set to true if using Apple XCodebuild
self.is_xcodebuild = use_xcodebuild

def _setenv(self, env, env_name, env_data, is_secret=False):
# Kinda silly to have a function for this, but makes the API calls consistent and looks better
# beside the other functions...

# We use xcodebuild, Apple's XCode commandline tool, to do iOS/tvOS simulation and tests.
# xcodebuild would pass in environment variables with prefix TEST_RUNNER_ for the tests. For example, if we would like to use environment
# variable FOO in the unit test, we would need set TEST_RUNNER_FOO=BAR. Then xcodebuild will pick up TEST_RUNNER_FOO and stripped
# TEST_RUNNER_ part, using FOO in it's final unit tests.
# For more details: https://developer.apple.com/documentation/xcode/environment-variable-reference
if self.is_xcodebuild:
env_name = "TEST_RUNNER_"+env_name
env.shell.setenv(env_name, str(env_data), is_secret=is_secret)
# Set it in the test environment as well, for C++
env.project.config['test_env'][env_name] = env_data
Expand Down
Loading