Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ END_UNRELEASED_TEMPLATE

### New

* TBD
* Added support for pre- and post-actions on autogenerated schemes, including explicit build post-action failure handling: [#3307](https://github.com/MobileNativeFoundation/rules_xcodeproj/pull/3307)
* Added `run_build_post_actions_on_failure` to custom scheme `xcschemes.run(...)` configuration for explicit build post-action failure handling: [#3307](https://github.com/MobileNativeFoundation/rules_xcodeproj/pull/3307)

### Adjusted

* TBD
* We now resolve `bazel_env` earlier to reduce analysis cache invalidation when environment values are resolved dynamically: [#3305](https://github.com/MobileNativeFoundation/rules_xcodeproj/pull/3305)

### Fixed

Expand Down
68 changes: 64 additions & 4 deletions docs/bazel.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ xcodeproj(
| <a id="xcodeproj-project_name"></a>project_name | Optional. The name to use for the `.xcodeproj` file.<br><br>If not specified, the value of the `name` argument is used. | `None` |
| <a id="xcodeproj-project_options"></a>project_options | Optional. A value returned by `project_options`. | `None` |
| <a id="xcodeproj-scheme_autogeneration_mode"></a>scheme_autogeneration_mode | Optional. Specifies how Xcode schemes are automatically generated:<br><br><ul> <li> `auto`: If no custom schemes are specified, via `schemes`, an Xcode scheme will be created for every buildable target. If custom schemes are provided, no autogenerated schemes will be created. </li> <li> `none`: No schemes are automatically generated. </li> <li> `all`: A scheme is generated for every buildable target even if custom schemes are provided. </li> </ul> | `"auto"` |
| <a id="xcodeproj-scheme_autogeneration_config"></a>scheme_autogeneration_config | Optional. A value returned by [`xcschemes.autogeneration_config`](#xcschemes.autogeneration_config).<br><br>Allows further configuration of `scheme_autogeneration_mode`. | `{}` |
| <a id="xcodeproj-scheme_autogeneration_config"></a>scheme_autogeneration_config | Optional. A value returned by [`xcschemes.autogeneration_config`](#xcschemes.autogeneration_config).<br><br>Allows further configuration of `scheme_autogeneration_mode`. | `None` |
| <a id="xcodeproj-target_name_mode"></a>target_name_mode | Optional. Specifies how Xcode targets names are represented:<br><br><ul> <li> `auto`: Use the product name if it is available and there is no collision. Otherwise select the target name from the label. And if there is a collision, use the full label. </li> <li> `label`: Always use full label for Xcode targets names. </li> </ul> | `"auto"` |
| <a id="xcodeproj-top_level_targets"></a>top_level_targets | A `list` of a list of top-level targets.<br><br>Each target can be specified as either a `Label` (or label-like `string`), a value returned by `top_level_target`, or a value returned by `top_level_targets`. | none |
| <a id="xcodeproj-tvos_device_cpus"></a>tvos_device_cpus | Optional. The value to use for `--tvos_cpus` when building the transitive dependencies of the targets specified in the `top_level_targets` argument with the `"device"` `target_environment`.<br><br>**Warning:** Changing this value will affect the Starlark transition hash of all transitive dependencies of the targets specified in the `top_level_targets` argument with the `"device"` `target_environment`, even if they aren't tvOS targets. | `"arm64"` |
Expand Down Expand Up @@ -235,14 +235,69 @@ Defines a command-line argument.
| <a id="xcschemes.arg-literal_string"></a>literal_string | Whether `value` should be interpreted as a literal string.<br><br>If `True`, any spaces will be escaped. This means that `value` will be passed to the launch target as a single string. If `False`, any spaces will not be escaped. This is useful to group multiple arguments under a single checkbox in Xcode. | `True` |


<a id="xcschemes.autogeneration.profile"></a>

## xcschemes.autogeneration.profile

<pre>
load("@rules_xcodeproj//xcodeproj/internal/docs:xcschemes.bzl", "xcschemes")

xcschemes.autogeneration.profile(*, <a href="#xcschemes.autogeneration.profile-post_actions">post_actions</a>, <a href="#xcschemes.autogeneration.profile-pre_actions">pre_actions</a>)
</pre>

Creates a value for the `profile` argument of `xcschemes.autogeneration_config`.

**PARAMETERS**


| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="xcschemes.autogeneration.profile-post_actions"></a>post_actions | Profile post-actions for autogenerated schemes.<br><br>Defaults to `[]`. | `[]` |
| <a id="xcschemes.autogeneration.profile-pre_actions"></a>pre_actions | Profile pre-actions for autogenerated schemes.<br><br>Defaults to `[]`. | `[]` |

**RETURNS**

An opaque value for the
[`profile`](user-content-xcschemes.autogeneration_config-profile)
argument of `xcschemes.autogeneration_config`.


<a id="xcschemes.autogeneration.run"></a>

## xcschemes.autogeneration.run

<pre>
load("@rules_xcodeproj//xcodeproj/internal/docs:xcschemes.bzl", "xcschemes")

xcschemes.autogeneration.run(*, <a href="#xcschemes.autogeneration.run-post_actions">post_actions</a>, <a href="#xcschemes.autogeneration.run-pre_actions">pre_actions</a>, <a href="#xcschemes.autogeneration.run-run_build_post_actions_on_failure">run_build_post_actions_on_failure</a>)
</pre>

Creates a value for the `run` argument of `xcschemes.autogeneration_config`.

**PARAMETERS**


| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="xcschemes.autogeneration.run-post_actions"></a>post_actions | Build and run post-actions for autogenerated schemes.<br><br>Defaults to `[]`. | `[]` |
| <a id="xcschemes.autogeneration.run-pre_actions"></a>pre_actions | Build and run pre-actions for autogenerated schemes.<br><br>Defaults to `[]`. | `[]` |
| <a id="xcschemes.autogeneration.run-run_build_post_actions_on_failure"></a>run_build_post_actions_on_failure | Whether autogenerated build post-actions should run even when the build fails. | `False` |

**RETURNS**

An opaque value for the
[`run`](user-content-xcschemes.autogeneration_config-run)
argument of `xcschemes.autogeneration_config`.


<a id="xcschemes.autogeneration.test"></a>

## xcschemes.autogeneration.test

<pre>
load("@rules_xcodeproj//xcodeproj/internal/docs:xcschemes.bzl", "xcschemes")

xcschemes.autogeneration.test(*, <a href="#xcschemes.autogeneration.test-options">options</a>)
xcschemes.autogeneration.test(*, <a href="#xcschemes.autogeneration.test-options">options</a>, <a href="#xcschemes.autogeneration.test-post_actions">post_actions</a>, <a href="#xcschemes.autogeneration.test-pre_actions">pre_actions</a>)
</pre>

Creates a value for the `test` argument of `xcschemes.autogeneration_config`.
Expand All @@ -253,6 +308,8 @@ Creates a value for the `test` argument of `xcschemes.autogeneration_config`.
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="xcschemes.autogeneration.test-options"></a>options | Test options for autogeneration.<br><br>Defaults to `None`. | `None` |
| <a id="xcschemes.autogeneration.test-post_actions"></a>post_actions | Test post-actions for autogenerated schemes.<br><br>Defaults to `[]`. | `[]` |
| <a id="xcschemes.autogeneration.test-pre_actions"></a>pre_actions | Test pre-actions for autogenerated schemes.<br><br>Defaults to `[]`. | `[]` |

**RETURNS**

Expand All @@ -268,7 +325,7 @@ An opaque value for the
<pre>
load("@rules_xcodeproj//xcodeproj/internal/docs:xcschemes.bzl", "xcschemes")

xcschemes.autogeneration_config(*, <a href="#xcschemes.autogeneration_config-scheme_name_exclude_patterns">scheme_name_exclude_patterns</a>, <a href="#xcschemes.autogeneration_config-test">test</a>)
xcschemes.autogeneration_config(*, <a href="#xcschemes.autogeneration_config-profile">profile</a>, <a href="#xcschemes.autogeneration_config-run">run</a>, <a href="#xcschemes.autogeneration_config-scheme_name_exclude_patterns">scheme_name_exclude_patterns</a>, <a href="#xcschemes.autogeneration_config-test">test</a>)
</pre>

Creates a value for the [`scheme_autogeneration_config`](xcodeproj-scheme_autogeneration_config) attribute of `xcodeproj`.
Expand All @@ -278,6 +335,8 @@ Creates a value for the [`scheme_autogeneration_config`](xcodeproj-scheme_autoge

| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="xcschemes.autogeneration_config-profile"></a>profile | Options to use for the profile action.<br><br>Example:<br><br><pre><code class="language-starlark">xcodeproj(&#10; ...&#10; scheme_autogeneration_config = xcschemes.autogeneration_config(&#10; profile = xcschemes.autogeneration.profile(&#10; pre_actions = [&#10; xcschemes.pre_post_actions.launch_script(&#10; title = "Profile Start",&#10; script_text = "echo profile",&#10; ),&#10; ],&#10; ),&#10; ),&#10;)</code></pre> | `None` |
| <a id="xcschemes.autogeneration_config-run"></a>run | Options to use for the build and run actions.<br><br>Example:<br><br><pre><code class="language-starlark">xcodeproj(&#10; ...&#10; scheme_autogeneration_config = xcschemes.autogeneration_config(&#10; run = xcschemes.autogeneration.run(&#10; pre_actions = [&#10; xcschemes.pre_post_actions.build_script(&#10; title = "Build Start",&#10; script_text = "echo build start",&#10; ),&#10; xcschemes.pre_post_actions.launch_script(&#10; title = "Run Start",&#10; script_text = "echo run",&#10; ),&#10; ],&#10; ),&#10; ),&#10;)</code></pre> | `None` |
| <a id="xcschemes.autogeneration_config-scheme_name_exclude_patterns"></a>scheme_name_exclude_patterns | A `list` of regex patterns used to skip creating matching autogenerated schemes.<br><br>Example:<br><br><pre><code class="language-starlark">xcodeproj(&#10; ...&#10; scheme_name_exclude_patterns = xcschemes.autogeneration_config(&#10; scheme_name_exclude_patterns = [&#10; ".*somePattern.*",&#10; "^AnotherPattern.*",&#10; ],&#10; ),&#10;)</code></pre> | `None` |
| <a id="xcschemes.autogeneration_config-test"></a>test | Options to use for the test action.<br><br>Example:<br><br><pre><code class="language-starlark">xcodeproj(&#10; ...&#10; scheme_autogeneration_config = xcschemes.autogeneration_config(&#10; test = xcschemes.autogeneration.test(&#10; options = xcschemes.test_options(&#10; app_language = "en",&#10; app_region = "US",&#10; code_coverage = False,&#10; )&#10; )&#10; )&#10;)</code></pre> | `None` |

Expand Down Expand Up @@ -496,7 +555,7 @@ Defines the Profile action.
load("@rules_xcodeproj//xcodeproj/internal/docs:xcschemes.bzl", "xcschemes")

xcschemes.run(*, <a href="#xcschemes.run-args">args</a>, <a href="#xcschemes.run-build_targets">build_targets</a>, <a href="#xcschemes.run-diagnostics">diagnostics</a>, <a href="#xcschemes.run-env">env</a>, <a href="#xcschemes.run-env_include_defaults">env_include_defaults</a>, <a href="#xcschemes.run-launch_target">launch_target</a>,
<a href="#xcschemes.run-storekit_configuration">storekit_configuration</a>, <a href="#xcschemes.run-xcode_configuration">xcode_configuration</a>)
<a href="#xcschemes.run-run_build_post_actions_on_failure">run_build_post_actions_on_failure</a>, <a href="#xcschemes.run-storekit_configuration">storekit_configuration</a>, <a href="#xcschemes.run-xcode_configuration">xcode_configuration</a>)
</pre>

Defines the Run action.
Expand All @@ -512,6 +571,7 @@ Defines the Run action.
| <a id="xcschemes.run-env"></a>env | Environment variables to use when running the launch target.<br><br>If set to `"inherit"`, then the environment variables will be supplied by the launch target (e.g. [`cc_binary.env`](https://bazel.build/reference/be/common-definitions#binary.env)). Otherwise, the `dict` of environment variables will be set as provided, and `None` or `{}` will result in no environment variables.<br><br>Each value of the `dict` can either be a string or a value returned by [`xcschemes.env_value`](#xcschemes.env_value). If a value is a string, it will be transformed into `xcschemes.env_value(value)`. For example, <pre><code>xcschemes.run(&#10; env = {&#10; "VAR1": "value 1",&#10; "VAR 2": xcschemes.env_value("value2", enabled = False),&#10; },&#10;)</code></pre> will be transformed into: <pre><code>xcschemes.run(&#10; env = {&#10; "VAR1": xcschemes.env_value("value 1"),&#10; "VAR 2": xcschemes.env_value("value2", enabled = False),&#10; },&#10;)</code></pre> | `"inherit"` |
| <a id="xcschemes.run-env_include_defaults"></a>env_include_defaults | Whether to include the rules_xcodeproj provided default Bazel environment variables (e.g. `BUILD_WORKING_DIRECTORY` and `BUILD_WORKSPACE_DIRECTORY`), in addition to any set by [`env`](#xcschemes.run-env). This does not apply to [`xcschemes.launch_path`](#xcschemes.launch_path)s. | `True` |
| <a id="xcschemes.run-launch_target"></a>launch_target | The target to launch when running.<br><br>Can be `None`, a label string, a value returned by [`xcschemes.launch_target`](#xcschemes.launch_target), or a value returned by [`xcschemes.launch_path`](#xcschemes.launch_path). If a label string, `xcschemes.launch_target(label_str)` will be used. If `None`, `xcschemes.launch_target()` will be used, which means no launch target will be set (i.e. the `Executable` dropdown will be set to `None`). | `None` |
| <a id="xcschemes.run-run_build_post_actions_on_failure"></a>run_build_post_actions_on_failure | Whether build post-actions should run even when the scheme's `BuildAction` fails. | `False` |
| <a id="xcschemes.run-storekit_configuration"></a>storekit_configuration | A StoreKit configuration file for use with [StoreKit Testing](https://developer.apple.com/documentation/xcode/setting-up-storekit-testing-in-xcode).<br><br>Can be `None`, or a label string referring to a single configuration file. | `None` |
| <a id="xcschemes.run-xcode_configuration"></a>xcode_configuration | The name of the Xcode configuration to use to build the targets referenced in the Run action (i.e in the [`build_targets`](#xcschemes.run-build_targets) and [`launch_target`](#xcschemes.run-launch_target) attributes).<br><br>If not set, the value of [`xcodeproj.default_xcode_configuration`](#xcodeproj-default_xcode_configuration) is used. | `None` |

Expand Down
5 changes: 5 additions & 0 deletions test/internal/xcschemes/info_constructors_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ def info_constructors_test_suite(name):
env = None,
env_include_defaults = "1",
launch_target = xcscheme_infos_testable.make_launch_target(),
run_build_post_actions_on_failure = "0",
storekit_configuration = "",
xcode_configuration = "",
),
Expand Down Expand Up @@ -625,6 +626,7 @@ def info_constructors_test_suite(name):
},
env_include_defaults = "0",
launch_target = xcscheme_infos_testable.make_launch_target("L"),
run_build_post_actions_on_failure = "1",
storekit_configuration = "",
xcode_configuration = "Run",
),
Expand Down Expand Up @@ -656,6 +658,7 @@ def info_constructors_test_suite(name):
launch_target = xcscheme_infos_testable.make_launch_target(
id = "L",
),
run_build_post_actions_on_failure = "1",
storekit_configuration = "",
xcode_configuration = "Run",
),
Expand Down Expand Up @@ -689,6 +692,7 @@ def info_constructors_test_suite(name):
),
run = xcscheme_infos_testable.make_run(
xcode_configuration = "R",
run_build_post_actions_on_failure = "1",
),
test = xcscheme_infos_testable.make_test(
xcode_configuration = "R",
Expand All @@ -703,6 +707,7 @@ def info_constructors_test_suite(name):
),
run = xcscheme_infos_testable.make_run(
xcode_configuration = "R",
run_build_post_actions_on_failure = "1",
),
test = xcscheme_infos_testable.make_test(
xcode_configuration = "R",
Expand Down
4 changes: 4 additions & 0 deletions test/internal/xcschemes/infos_from_json_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ def infos_from_json_test_suite(name):
env = {"A": "B"},
env_include_defaults = "1",
launch_target = full_launch_target,
run_build_post_actions_on_failure = "0",
storekit_configuration = "",
xcode_configuration = "custom",
),
Expand Down Expand Up @@ -704,6 +705,7 @@ def infos_from_json_test_suite(name):
target_environment = "",
working_directory = "",
),
run_build_post_actions_on_failure = "0",
storekit_configuration = "",
xcode_configuration = "",
),
Expand Down Expand Up @@ -807,6 +809,7 @@ def infos_from_json_test_suite(name):
],
working_directory = "wd",
),
run_build_post_actions_on_failure = "0",
storekit_configuration = "",
xcode_configuration = "custom",
),
Expand Down Expand Up @@ -867,6 +870,7 @@ def infos_from_json_test_suite(name):
env = full_env,
env_include_defaults = "0",
launch_target = full_launch_target,
run_build_post_actions_on_failure = "0",
use_run_args_and_env = "0",
storekit_configuration = "//test/internal/xcschemes:fixture.storekit",
xcode_configuration = "custom",
Expand Down
1 change: 1 addition & 0 deletions test/internal/xcschemes/utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def _dict_to_run_info(d):
env = _dict_of_dicts_to_env_infos(d["env"]),
env_include_defaults = d["env_include_defaults"],
launch_target = _dict_to_launch_target_info(d["launch_target"]),
run_build_post_actions_on_failure = d["run_build_post_actions_on_failure"],
storekit_configuration = d["storekit_configuration"],
xcode_configuration = d["xcode_configuration"],
)
Expand Down
Loading
Loading