Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ END_UNRELEASED_TEMPLATE

* Added `--@rules_xcodeproj//xcodeproj:separate_index_build_output_base` flag to configure the generator to use a separate output base for index builds: [#3243](https://github.com/MobileNativeFoundation/rules_xcodeproj/pull/3243)
* Add support for viewing and edit xcmappingmodel files: [#3242](https://github.com/MobileNativeFoundation/rules_xcodeproj/pull/3242)
* Added support for StoreKit configuration files to `xcschemes.run`, for use with [StoreKit Testing](https://developer.apple.com/documentation/xcode/setting-up-storekit-testing-in-xcode). [#3242](https://github.com/MobileNativeFoundation/rules_xcodeproj/pull/3245)

### Adjusted

Expand Down
3 changes: 2 additions & 1 deletion docs/bazel.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ Defines the Profile action.

<pre>
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-xcode_configuration">xcode_configuration</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 @@ -480,6 +480,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-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: 4 additions & 1 deletion examples/integration/Lib/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ load("@build_bazel_rules_apple//apple:tvos.bzl", "tvos_framework")
load("@build_bazel_rules_apple//apple:watchos.bzl", "watchos_framework")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")

exports_files(["README.md"])
exports_files([
"README.md",
"Resources/Configuration.storekit",
])

exports_files(
["Info.plist"],
Expand Down
29 changes: 29 additions & 0 deletions examples/integration/Lib/Resources/Configuration.storekit
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"appPolicies" : {
"eula" : "",
"policies" : [
{
"locale" : "en_US",
"policyText" : "",
"policyURL" : ""
}
]
},
"identifier" : "",
"nonRenewingSubscriptions" : [

],
"products" : [

],
"settings" : {
"_failTransactionsEnabled" : false
},
"subscriptionGroups" : [

],
"version" : {
"major" : 4,
"minor" : 0
}
}
1 change: 1 addition & 0 deletions examples/integration/xcodeproj_targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ XCSCHEMES = [
],
),
],
storekit_configuration = "//Lib:Resources/Configuration.storekit",
),
),
]
1 change: 1 addition & 0 deletions test/internal/xcschemes/fixture.storekit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
3 changes: 3 additions & 0 deletions test/internal/xcschemes/info_constructors_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ def info_constructors_test_suite(name):
env = None,
env_include_defaults = "1",
launch_target = xcscheme_infos_testable.make_launch_target(),
storekit_configuration = "",
xcode_configuration = "",
),
)
Expand Down Expand Up @@ -621,6 +622,7 @@ def info_constructors_test_suite(name):
},
env_include_defaults = "0",
launch_target = xcscheme_infos_testable.make_launch_target("L"),
storekit_configuration = "",
xcode_configuration = "Run",
),

Expand Down Expand Up @@ -651,6 +653,7 @@ def info_constructors_test_suite(name):
launch_target = xcscheme_infos_testable.make_launch_target(
id = "L",
),
storekit_configuration = "",
xcode_configuration = "Run",
),
)
Expand Down
40 changes: 40 additions & 0 deletions test/internal/xcschemes/infos_from_json_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def _infos_from_json_test_impl(ctx):
infos = xcscheme_infos.from_json(
ctx.attr.json_str,
default_xcode_configuration = ctx.attr.default_xcode_configuration,
storekit_configurations_map = ctx.attr.storekit_configurations_map,
top_level_deps = _json_to_top_level_deps(ctx.attr.top_level_deps),
)

Expand All @@ -62,7 +63,9 @@ infos_from_json_test = unittest.make(
attrs = {
# Inputs
"default_xcode_configuration": attr.string(mandatory = True),
"install_path": attr.string(mandatory = True),
"json_str": attr.string(mandatory = True),
"storekit_configurations_map": attr.string_dict(mandatory = True),
"top_level_deps": attr.string(mandatory = True),

# Expected
Expand All @@ -86,7 +89,9 @@ def infos_from_json_test_suite(name):

# Inputs
default_xcode_configuration,
install_path,
json_str,
storekit_configurations_map,
top_level_deps,

# Expected
Expand All @@ -97,7 +102,9 @@ def infos_from_json_test_suite(name):

# Inputs
default_xcode_configuration = default_xcode_configuration,
install_path = install_path,
json_str = json_str,
storekit_configurations_map = storekit_configurations_map,
top_level_deps = json.encode(top_level_deps),

# Expected
Expand Down Expand Up @@ -149,6 +156,7 @@ def infos_from_json_test_suite(name):
},
}

install_path = "test/internal/InfosFromJSONTests.xcodeproj"
full_args = [
"-a\nnewline",
xcscheme_infos_testable.make_arg(
Expand Down Expand Up @@ -390,7 +398,9 @@ def infos_from_json_test_suite(name):

# Inputs
default_xcode_configuration = "AppStore",
install_path = install_path,
json_str = json.encode([]),
storekit_configurations_map = {},
top_level_deps = {},

# Expected
Expand All @@ -404,6 +414,7 @@ def infos_from_json_test_suite(name):

# Inputs
default_xcode_configuration = "AppStore",
install_path = install_path,
json_str = json.encode([
{
"name": "A scheme",
Expand All @@ -418,6 +429,7 @@ def infos_from_json_test_suite(name):
"test": None,
},
]),
storekit_configurations_map = {},
top_level_deps = {},

# Expected
Expand All @@ -438,6 +450,7 @@ def infos_from_json_test_suite(name):

# Inputs
default_xcode_configuration = "custom",
install_path = install_path,
json_str = json.encode([
{
"name": "A scheme",
Expand Down Expand Up @@ -485,6 +498,7 @@ def infos_from_json_test_suite(name):
"test": None,
},
]),
storekit_configurations_map = {},
top_level_deps = top_level_deps,

# Expected
Expand Down Expand Up @@ -514,6 +528,7 @@ def infos_from_json_test_suite(name):

# Inputs
default_xcode_configuration = "AppStore",
install_path = install_path,
json_str = json.encode([
{
"name": "A scheme",
Expand All @@ -530,6 +545,7 @@ def infos_from_json_test_suite(name):
"test": None,
},
]),
storekit_configurations_map = {},
top_level_deps = top_level_deps,

# Expected
Expand Down Expand Up @@ -557,6 +573,7 @@ def infos_from_json_test_suite(name):

# Inputs
default_xcode_configuration = "AppStore",
install_path = install_path,
json_str = json.encode([
{
"name": "A scheme",
Expand All @@ -565,6 +582,7 @@ def infos_from_json_test_suite(name):
"test": None,
},
]),
storekit_configurations_map = {},
top_level_deps = {},

# Expected
Expand All @@ -581,6 +599,7 @@ def infos_from_json_test_suite(name):

# Inputs
default_xcode_configuration = "AppStore",
install_path = install_path,
json_str = json.encode([
{
"name": "A scheme",
Expand All @@ -594,11 +613,13 @@ def infos_from_json_test_suite(name):
env = {"A": "B"},
env_include_defaults = "1",
launch_target = full_launch_target,
storekit_configuration = "",
xcode_configuration = "custom",
),
"test": None,
},
]),
storekit_configurations_map = {},
top_level_deps = top_level_deps,

# Expected
Expand Down Expand Up @@ -626,6 +647,7 @@ def infos_from_json_test_suite(name):
env = {"A": xcscheme_infos_testable.make_env("B")},
env_include_defaults = "1",
launch_target = expected_full_launch_target,
storekit_configuration = "",
xcode_configuration = "custom",
),
),
Expand All @@ -639,6 +661,7 @@ def infos_from_json_test_suite(name):

# Inputs
default_xcode_configuration = "custom",
install_path = install_path,
json_str = json.encode([
{
"name": "A scheme",
Expand Down Expand Up @@ -681,11 +704,13 @@ def infos_from_json_test_suite(name):
target_environment = "",
working_directory = "",
),
storekit_configuration = "",
xcode_configuration = "",
),
"test": None,
},
]),
storekit_configurations_map = {},
top_level_deps = top_level_deps,

# Expected
Expand Down Expand Up @@ -744,6 +769,7 @@ def infos_from_json_test_suite(name):

# Inputs
default_xcode_configuration = "AppStore",
install_path = install_path,
json_str = json.encode([
{
"name": "A scheme",
Expand Down Expand Up @@ -781,11 +807,13 @@ def infos_from_json_test_suite(name):
],
working_directory = "wd",
),
storekit_configuration = "",
xcode_configuration = "custom",
),
"test": None,
},
]),
storekit_configurations_map = {},
top_level_deps = top_level_deps,

# Expected
Expand Down Expand Up @@ -821,6 +849,7 @@ def infos_from_json_test_suite(name):

# Inputs
default_xcode_configuration = "AppStore",
install_path = install_path,
json_str = json.encode([
{
"name": "A scheme",
Expand All @@ -839,11 +868,15 @@ def infos_from_json_test_suite(name):
env_include_defaults = "0",
launch_target = full_launch_target,
use_run_args_and_env = "0",
storekit_configuration = "//test/internal/xcschemes:fixture.storekit",
xcode_configuration = "custom",
),
"test": None,
},
]),
storekit_configurations_map = {
"//test/internal/xcschemes:fixture.storekit": "test/internal/xcschemes/fixture.storekit",
},
top_level_deps = top_level_deps,

# Expected
Expand All @@ -866,6 +899,9 @@ def infos_from_json_test_suite(name):
env = expected_full_env,
env_include_defaults = "0",
launch_target = expected_full_launch_target,
# from the install path and two levels inside the project, up to the execution root
# <install_path>/xcshareddata/xcschemes
storekit_configuration = "test/internal/xcschemes/fixture.storekit",
xcode_configuration = "custom",
),
),
Expand All @@ -879,6 +915,7 @@ def infos_from_json_test_suite(name):

# Inputs
default_xcode_configuration = "custom",
install_path = install_path,
json_str = json.encode([
{
"name": "A scheme",
Expand Down Expand Up @@ -913,6 +950,7 @@ def infos_from_json_test_suite(name):
),
},
]),
storekit_configurations_map = {},
top_level_deps = top_level_deps,

# Expected
Expand All @@ -938,6 +976,7 @@ def infos_from_json_test_suite(name):

# Inputs
default_xcode_configuration = "AppStore",
install_path = install_path,
json_str = json.encode([
{
"name": "A scheme",
Expand Down Expand Up @@ -1009,6 +1048,7 @@ def infos_from_json_test_suite(name):
),
},
]),
storekit_configurations_map = {},
top_level_deps = top_level_deps,

# Expected
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 @@ -64,6 +64,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"]),
storekit_configuration = d["storekit_configuration"],
xcode_configuration = d["xcode_configuration"],
)

Expand Down
Loading