Skip to content

Commit 785f548

Browse files
committed
Support StoreKit Configuration setting in xcscheme Run action
Signed-off-by: Aaron Sky <aaronsky@skyaaron.com>
1 parent e51f451 commit 785f548

26 files changed

+240
-10
lines changed

docs/bazel.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ Defines the Profile action.
464464

465465
<pre>
466466
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>,
467-
<a href="#xcschemes.run-xcode_configuration">xcode_configuration</a>)
467+
<a href="#xcschemes.run-storekit_configuration">storekit_configuration</a>, <a href="#xcschemes.run-xcode_configuration">xcode_configuration</a>)
468468
</pre>
469469

470470
Defines the Run action.
@@ -480,6 +480,7 @@ Defines the Run action.
480480
| <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"` |
481481
| <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` |
482482
| <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` |
483+
| <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` |
483484
| <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` |
484485

485486

examples/integration/Lib/BUILD

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ load("@build_bazel_rules_apple//apple:tvos.bzl", "tvos_framework")
77
load("@build_bazel_rules_apple//apple:watchos.bzl", "watchos_framework")
88
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
99

10-
exports_files(["README.md"])
10+
exports_files([
11+
"README.md",
12+
"Resources/Configuration.storekit",
13+
])
1114

1215
exports_files(
1316
["Info.plist"],
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"appPolicies" : {
3+
"eula" : "",
4+
"policies" : [
5+
{
6+
"locale" : "en_US",
7+
"policyText" : "",
8+
"policyURL" : ""
9+
}
10+
]
11+
},
12+
"identifier" : "",
13+
"nonRenewingSubscriptions" : [
14+
15+
],
16+
"products" : [
17+
18+
],
19+
"settings" : {
20+
"_failTransactionsEnabled" : false
21+
},
22+
"subscriptionGroups" : [
23+
24+
],
25+
"version" : {
26+
"major" : 4,
27+
"minor" : 0
28+
}
29+
}

examples/integration/xcodeproj_targets.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ XCSCHEMES = [
228228
],
229229
),
230230
],
231+
storekit_configuration = "//Lib:Resources/Configuration.storekit",
231232
),
232233
),
233234
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

test/internal/xcschemes/info_constructors_tests.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ def info_constructors_test_suite(name):
589589
env = None,
590590
env_include_defaults = "1",
591591
launch_target = xcscheme_infos_testable.make_launch_target(),
592+
storekit_configuration = "",
592593
xcode_configuration = "",
593594
),
594595
)
@@ -621,6 +622,7 @@ def info_constructors_test_suite(name):
621622
},
622623
env_include_defaults = "0",
623624
launch_target = xcscheme_infos_testable.make_launch_target("L"),
625+
storekit_configuration = "",
624626
xcode_configuration = "Run",
625627
),
626628

@@ -651,6 +653,7 @@ def info_constructors_test_suite(name):
651653
launch_target = xcscheme_infos_testable.make_launch_target(
652654
id = "L",
653655
),
656+
storekit_configuration = "",
654657
xcode_configuration = "Run",
655658
),
656659
)

test/internal/xcschemes/infos_from_json_tests.bzl

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ def _infos_from_json_test_impl(ctx):
4141

4242
infos = xcscheme_infos.from_json(
4343
ctx.attr.json_str,
44+
install_path = ctx.attr.install_path,
4445
default_xcode_configuration = ctx.attr.default_xcode_configuration,
46+
storekit_configurations_map = ctx.attr.storekit_configurations_map,
4547
top_level_deps = _json_to_top_level_deps(ctx.attr.top_level_deps),
4648
)
4749

@@ -62,7 +64,9 @@ infos_from_json_test = unittest.make(
6264
attrs = {
6365
# Inputs
6466
"default_xcode_configuration": attr.string(mandatory = True),
67+
"install_path": attr.string(mandatory = True),
6568
"json_str": attr.string(mandatory = True),
69+
"storekit_configurations_map": attr.string_dict(mandatory = True),
6670
"top_level_deps": attr.string(mandatory = True),
6771

6872
# Expected
@@ -86,7 +90,9 @@ def infos_from_json_test_suite(name):
8690

8791
# Inputs
8892
default_xcode_configuration,
93+
install_path,
8994
json_str,
95+
storekit_configurations_map,
9096
top_level_deps,
9197

9298
# Expected
@@ -97,7 +103,9 @@ def infos_from_json_test_suite(name):
97103

98104
# Inputs
99105
default_xcode_configuration = default_xcode_configuration,
106+
install_path = install_path,
100107
json_str = json_str,
108+
storekit_configurations_map = storekit_configurations_map,
101109
top_level_deps = json.encode(top_level_deps),
102110

103111
# Expected
@@ -149,6 +157,7 @@ def infos_from_json_test_suite(name):
149157
},
150158
}
151159

160+
install_path = "test/internal/InfosFromJSONTests.xcodeproj"
152161
full_args = [
153162
"-a\nnewline",
154163
xcscheme_infos_testable.make_arg(
@@ -390,7 +399,9 @@ def infos_from_json_test_suite(name):
390399

391400
# Inputs
392401
default_xcode_configuration = "AppStore",
402+
install_path = install_path,
393403
json_str = json.encode([]),
404+
storekit_configurations_map = {},
394405
top_level_deps = {},
395406

396407
# Expected
@@ -404,6 +415,7 @@ def infos_from_json_test_suite(name):
404415

405416
# Inputs
406417
default_xcode_configuration = "AppStore",
418+
install_path = install_path,
407419
json_str = json.encode([
408420
{
409421
"name": "A scheme",
@@ -418,6 +430,7 @@ def infos_from_json_test_suite(name):
418430
"test": None,
419431
},
420432
]),
433+
storekit_configurations_map = {},
421434
top_level_deps = {},
422435

423436
# Expected
@@ -438,6 +451,7 @@ def infos_from_json_test_suite(name):
438451

439452
# Inputs
440453
default_xcode_configuration = "custom",
454+
install_path = install_path,
441455
json_str = json.encode([
442456
{
443457
"name": "A scheme",
@@ -485,6 +499,7 @@ def infos_from_json_test_suite(name):
485499
"test": None,
486500
},
487501
]),
502+
storekit_configurations_map = {},
488503
top_level_deps = top_level_deps,
489504

490505
# Expected
@@ -514,6 +529,7 @@ def infos_from_json_test_suite(name):
514529

515530
# Inputs
516531
default_xcode_configuration = "AppStore",
532+
install_path = install_path,
517533
json_str = json.encode([
518534
{
519535
"name": "A scheme",
@@ -530,6 +546,7 @@ def infos_from_json_test_suite(name):
530546
"test": None,
531547
},
532548
]),
549+
storekit_configurations_map = {},
533550
top_level_deps = top_level_deps,
534551

535552
# Expected
@@ -557,6 +574,7 @@ def infos_from_json_test_suite(name):
557574

558575
# Inputs
559576
default_xcode_configuration = "AppStore",
577+
install_path = install_path,
560578
json_str = json.encode([
561579
{
562580
"name": "A scheme",
@@ -565,6 +583,7 @@ def infos_from_json_test_suite(name):
565583
"test": None,
566584
},
567585
]),
586+
storekit_configurations_map = {},
568587
top_level_deps = {},
569588

570589
# Expected
@@ -581,6 +600,7 @@ def infos_from_json_test_suite(name):
581600

582601
# Inputs
583602
default_xcode_configuration = "AppStore",
603+
install_path = install_path,
584604
json_str = json.encode([
585605
{
586606
"name": "A scheme",
@@ -594,11 +614,13 @@ def infos_from_json_test_suite(name):
594614
env = {"A": "B"},
595615
env_include_defaults = "1",
596616
launch_target = full_launch_target,
617+
storekit_configuration = "",
597618
xcode_configuration = "custom",
598619
),
599620
"test": None,
600621
},
601622
]),
623+
storekit_configurations_map = {},
602624
top_level_deps = top_level_deps,
603625

604626
# Expected
@@ -626,6 +648,7 @@ def infos_from_json_test_suite(name):
626648
env = {"A": xcscheme_infos_testable.make_env("B")},
627649
env_include_defaults = "1",
628650
launch_target = expected_full_launch_target,
651+
storekit_configuration = "",
629652
xcode_configuration = "custom",
630653
),
631654
),
@@ -639,6 +662,7 @@ def infos_from_json_test_suite(name):
639662

640663
# Inputs
641664
default_xcode_configuration = "custom",
665+
install_path = install_path,
642666
json_str = json.encode([
643667
{
644668
"name": "A scheme",
@@ -681,11 +705,13 @@ def infos_from_json_test_suite(name):
681705
target_environment = "",
682706
working_directory = "",
683707
),
708+
storekit_configuration = "",
684709
xcode_configuration = "",
685710
),
686711
"test": None,
687712
},
688713
]),
714+
storekit_configurations_map = {},
689715
top_level_deps = top_level_deps,
690716

691717
# Expected
@@ -744,6 +770,7 @@ def infos_from_json_test_suite(name):
744770

745771
# Inputs
746772
default_xcode_configuration = "AppStore",
773+
install_path = install_path,
747774
json_str = json.encode([
748775
{
749776
"name": "A scheme",
@@ -781,11 +808,13 @@ def infos_from_json_test_suite(name):
781808
],
782809
working_directory = "wd",
783810
),
811+
storekit_configuration = "",
784812
xcode_configuration = "custom",
785813
),
786814
"test": None,
787815
},
788816
]),
817+
storekit_configurations_map = {},
789818
top_level_deps = top_level_deps,
790819

791820
# Expected
@@ -821,6 +850,7 @@ def infos_from_json_test_suite(name):
821850

822851
# Inputs
823852
default_xcode_configuration = "AppStore",
853+
install_path = install_path,
824854
json_str = json.encode([
825855
{
826856
"name": "A scheme",
@@ -839,11 +869,15 @@ def infos_from_json_test_suite(name):
839869
env_include_defaults = "0",
840870
launch_target = full_launch_target,
841871
use_run_args_and_env = "0",
872+
storekit_configuration = "//test/internal/xcschemes:fixture.storekit",
842873
xcode_configuration = "custom",
843874
),
844875
"test": None,
845876
},
846877
]),
878+
storekit_configurations_map = {
879+
"//test/internal/xcschemes:fixture.storekit": "test/internal/xcschemes/fixture.storekit",
880+
},
847881
top_level_deps = top_level_deps,
848882

849883
# Expected
@@ -866,6 +900,9 @@ def infos_from_json_test_suite(name):
866900
env = expected_full_env,
867901
env_include_defaults = "0",
868902
launch_target = expected_full_launch_target,
903+
# from the install path and two levels inside the project, up to the execution root
904+
# <install_path>/xcshareddata/xcschemes
905+
storekit_configuration = "../../xcschemes/fixture.storekit",
869906
xcode_configuration = "custom",
870907
),
871908
),
@@ -879,6 +916,7 @@ def infos_from_json_test_suite(name):
879916

880917
# Inputs
881918
default_xcode_configuration = "custom",
919+
install_path = install_path,
882920
json_str = json.encode([
883921
{
884922
"name": "A scheme",
@@ -913,6 +951,7 @@ def infos_from_json_test_suite(name):
913951
),
914952
},
915953
]),
954+
storekit_configurations_map = {},
916955
top_level_deps = top_level_deps,
917956

918957
# Expected
@@ -938,6 +977,7 @@ def infos_from_json_test_suite(name):
938977

939978
# Inputs
940979
default_xcode_configuration = "AppStore",
980+
install_path = install_path,
941981
json_str = json.encode([
942982
{
943983
"name": "A scheme",
@@ -1009,6 +1049,7 @@ def infos_from_json_test_suite(name):
10091049
),
10101050
},
10111051
]),
1052+
storekit_configurations_map = {},
10121053
top_level_deps = top_level_deps,
10131054

10141055
# Expected

test/internal/xcschemes/utils.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def _dict_to_run_info(d):
6464
env = _dict_of_dicts_to_env_infos(d["env"]),
6565
env_include_defaults = d["env_include_defaults"],
6666
launch_target = _dict_to_launch_target_info(d["launch_target"]),
67+
storekit_configuration = d["storekit_configuration"],
6768
xcode_configuration = d["xcode_configuration"],
6869
)
6970

test/internal/xcschemes/write_schemes_tests.bzl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ def write_schemes_test_suite(name):
552552
],
553553
working_directory = "run working dir",
554554
),
555+
storekit_configuration = "StoreKitConfig",
555556
xcode_configuration = "Run",
556557
),
557558
test = xcscheme_infos_testable.make_test(
@@ -1110,6 +1111,8 @@ def write_schemes_test_suite(name):
11101111
"1",
11111112
# - test - enableThreadPerformanceChecker
11121113
"1",
1114+
# - run - storekitConfiguration
1115+
"",
11131116
# - run - xcodeConfiguration
11141117
"",
11151118
# - run - launchTarget - isPath
@@ -1236,6 +1239,8 @@ def write_schemes_test_suite(name):
12361239
"1",
12371240
# - test - enableThreadPerformanceChecker
12381241
"1",
1242+
# - run - storekitConfiguration
1243+
"StoreKitConfig",
12391244
# - run - xcodeConfiguration
12401245
"Run",
12411246
# - run - launchTarget - isPath
@@ -1340,6 +1345,8 @@ def write_schemes_test_suite(name):
13401345
"1",
13411346
# - test - enableThreadPerformanceChecker
13421347
"1",
1348+
# - run - storekitConfiguration
1349+
"",
13431350
# - run - xcodeConfiguration
13441351
"",
13451352
# - run - launchTarget - isPath

0 commit comments

Comments
 (0)