From e36b03af5fc88b993233e3f70d740bcb0a2eecd0 Mon Sep 17 00:00:00 2001 From: Jeffrey Forbes Date: Tue, 20 May 2025 18:13:29 -0400 Subject: [PATCH] Add StoreKit Configuration support to Xcode Schemes. --- docs/bazel.md | 7 +++- test/internal/xcode_schemes/model_tests.bzl | 1 + .../xcschemes/info_constructors_tests.bzl | 3 ++ .../xcschemes/infos_from_json_tests.bzl | 7 ++++ test/internal/xcschemes/utils.bzl | 1 + .../xcschemes/write_schemes_tests.bzl | 7 ++++ .../lib/XCScheme/src/CreateLaunchAction.swift | 18 +++++++++ .../test/CreateLaunchActionTests.swift | 1 + .../Generator/CreateAutomaticSchemeInfo.swift | 1 + .../Generator/CreateCustomSchemeInfos.swift | 38 ++++++++++++++++--- .../src/Generator/CreateScheme.swift | 1 + .../xcschemes/src/Generator/Generator.swift | 4 +- .../xcschemes/src/Generator/SchemeInfo.swift | 1 + .../src/Generator/URL+Extensions.swift | 26 +++++++++++++ .../test/CreateAutomaticSchemeInfoTests.swift | 9 +++++ .../xcschemes/test/SchemeInfo+Testing.swift | 2 + xcodeproj/internal/xcode_schemes.bzl | 7 +++- xcodeproj/internal/xcode_schemes_internal.bzl | 6 ++- .../internal/xcschemes/xcscheme_infos.bzl | 5 ++- .../internal/xcschemes/xcscheme_labels.bzl | 1 + xcodeproj/internal/xcschemes/xcschemes.bzl | 5 ++- .../xcschemes/xcschemes_execution.bzl | 1 + 22 files changed, 139 insertions(+), 13 deletions(-) create mode 100644 tools/generators/xcschemes/src/Generator/URL+Extensions.swift diff --git a/docs/bazel.md b/docs/bazel.md index ba029953c0..16efd12eca 100755 --- a/docs/bazel.md +++ b/docs/bazel.md @@ -479,7 +479,7 @@ Defines the Profile action.
 xcschemes.run(args, build_targets, diagnostics, env, env_include_defaults, launch_target,
-              xcode_configuration)
+              xcode_configuration, storekit_configuration)
 
Defines the Run action. @@ -496,6 +496,7 @@ Defines the Run action. | 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` | | launch_target | The target to launch when running.

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` | | 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).

If not set, the value of [`xcodeproj.default_xcode_configuration`](#xcodeproj-default_xcode_configuration) is used. | `None` | +| storekit_configuration | a label that points to a storekit configuration file. | `None` | @@ -757,7 +758,8 @@ A `struct` representing scheme's diagnostics. ## xcode_schemes.launch_action
-xcode_schemes.launch_action(target, args, build_configuration, diagnostics, env, working_directory)
+xcode_schemes.launch_action(target, args, build_configuration, diagnostics, env, working_directory,
+                            storekit_configuration)
 
Constructs a launch action for an Xcode scheme. @@ -773,6 +775,7 @@ Constructs a launch action for an Xcode scheme. | diagnostics | Optional. A value returned by `xcode_schemes.diagnostics`. | `None` | | env | Optional. A `dict` of `string` values that will be set as environment variables when the target is executed. | `None` | | working_directory | Optional. A `string` that will be set as the custom working directory in the Xcode scheme's launch action. Relative paths will be relative to the value of `target`'s `BUILT_PRODUCTS_DIR`, which is unique to it. | `None` | +| storekit_configuration | Optional. A `string` that will be set as the custom StoreKit configuration in the Xcode scheme's launch action. This should be a path relative to the workspace root. | `None` | **RETURNS** diff --git a/test/internal/xcode_schemes/model_tests.bzl b/test/internal/xcode_schemes/model_tests.bzl index 84f0796dc3..d853b03c5b 100644 --- a/test/internal/xcode_schemes/model_tests.bzl +++ b/test/internal/xcode_schemes/model_tests.bzl @@ -256,6 +256,7 @@ def _launch_action_test(ctx): diagnostics = None, env = env, working_directory = None, + storekit_configuration = None, ) asserts.equals(test_env, expected, actual) diff --git a/test/internal/xcschemes/info_constructors_tests.bzl b/test/internal/xcschemes/info_constructors_tests.bzl index 3036f69e82..646e6af4a6 100644 --- a/test/internal/xcschemes/info_constructors_tests.bzl +++ b/test/internal/xcschemes/info_constructors_tests.bzl @@ -590,6 +590,7 @@ def info_constructors_test_suite(name): env_include_defaults = "1", launch_target = xcscheme_infos_testable.make_launch_target(), xcode_configuration = "", + storekit_configuration = "", ), ) @@ -622,6 +623,7 @@ def info_constructors_test_suite(name): env_include_defaults = "0", launch_target = xcscheme_infos_testable.make_launch_target("L"), xcode_configuration = "Run", + storekit_configuration = "", ), # Expected @@ -652,6 +654,7 @@ def info_constructors_test_suite(name): id = "L", ), xcode_configuration = "Run", + storekit_configuration = "", ), ) diff --git a/test/internal/xcschemes/infos_from_json_tests.bzl b/test/internal/xcschemes/infos_from_json_tests.bzl index ae1331bc25..4bfcf5d7c7 100644 --- a/test/internal/xcschemes/infos_from_json_tests.bzl +++ b/test/internal/xcschemes/infos_from_json_tests.bzl @@ -595,6 +595,7 @@ def infos_from_json_test_suite(name): env_include_defaults = "1", launch_target = full_launch_target, xcode_configuration = "custom", + storekit_configuration = "", ), "test": None, }, @@ -627,6 +628,7 @@ def infos_from_json_test_suite(name): env_include_defaults = "1", launch_target = expected_full_launch_target, xcode_configuration = "custom", + storekit_configuration = "", ), ), ], @@ -682,6 +684,7 @@ def infos_from_json_test_suite(name): working_directory = "", ), xcode_configuration = "", + storekit_configuration = "", ), "test": None, }, @@ -782,6 +785,7 @@ def infos_from_json_test_suite(name): working_directory = "wd", ), xcode_configuration = "custom", + storekit_configuration = "", ), "test": None, }, @@ -840,6 +844,8 @@ def infos_from_json_test_suite(name): launch_target = full_launch_target, use_run_args_and_env = "0", xcode_configuration = "custom", + run = "", + storekit_configuration = "", ), "test": None, }, @@ -867,6 +873,7 @@ def infos_from_json_test_suite(name): env_include_defaults = "0", launch_target = expected_full_launch_target, xcode_configuration = "custom", + storekit_configuration = "", ), ), ], diff --git a/test/internal/xcschemes/utils.bzl b/test/internal/xcschemes/utils.bzl index 0aa2fff8be..27a1742e9c 100644 --- a/test/internal/xcschemes/utils.bzl +++ b/test/internal/xcschemes/utils.bzl @@ -65,6 +65,7 @@ def _dict_to_run_info(d): env_include_defaults = d["env_include_defaults"], launch_target = _dict_to_launch_target_info(d["launch_target"]), xcode_configuration = d["xcode_configuration"], + storekit_configuration = d["storekit_configuration"], ) def _dict_to_test_info(d): diff --git a/test/internal/xcschemes/write_schemes_tests.bzl b/test/internal/xcschemes/write_schemes_tests.bzl index 35b920991a..8dda65d921 100644 --- a/test/internal/xcschemes/write_schemes_tests.bzl +++ b/test/internal/xcschemes/write_schemes_tests.bzl @@ -553,6 +553,7 @@ def write_schemes_test_suite(name): working_directory = "run working dir", ), xcode_configuration = "Run", + storekit_configuration = "StorekitConfig", ), test = xcscheme_infos_testable.make_test( args = [ @@ -1112,6 +1113,8 @@ def write_schemes_test_suite(name): "1", # - run - xcodeConfiguration "", + # - run - storekitConfiguration + "", # - run - launchTarget - isPath "0", # - run - launchTarget - id @@ -1238,6 +1241,8 @@ def write_schemes_test_suite(name): "1", # - run - xcodeConfiguration "Run", + # - run - storekitConfiguration + "StorekitConfig", # - run - launchTarget - isPath "0", # - run - launchTarget - id @@ -1342,6 +1347,8 @@ def write_schemes_test_suite(name): "1", # - run - xcodeConfiguration "", + # - run - storekitConfiguration + "", # - run - launchTarget - isPath "1", # - run - launchTarget - path diff --git a/tools/generators/lib/XCScheme/src/CreateLaunchAction.swift b/tools/generators/lib/XCScheme/src/CreateLaunchAction.swift index a569187035..5a348ba810 100644 --- a/tools/generators/lib/XCScheme/src/CreateLaunchAction.swift +++ b/tools/generators/lib/XCScheme/src/CreateLaunchAction.swift @@ -18,6 +18,7 @@ public struct CreateLaunchAction { enableUBSanitizer: Bool, enableMainThreadChecker: Bool, enableThreadPerformanceChecker: Bool, + storeKitConfiguration: String?, environmentVariables: [EnvironmentVariable], postActions: [ExecutionAction], preActions: [ExecutionAction], @@ -32,6 +33,7 @@ public struct CreateLaunchAction { /*enableUBSanitizer:*/ enableUBSanitizer, /*enableMainThreadChecker:*/ enableMainThreadChecker, /*enableThreadPerformanceChecker:*/ enableThreadPerformanceChecker, + /*storeKitConfiguration:*/ storeKitConfiguration, /*environmentVariables:*/ environmentVariables, /*postActions:*/ postActions, /*preActions:*/ preActions, @@ -52,6 +54,7 @@ extension CreateLaunchAction { _ enableUBSanitizer: Bool, _ enableMainThreadChecker: Bool, _ enableThreadPerformanceChecker: Bool, + _ storeKitConfiguration: String?, _ environmentVariables: [EnvironmentVariable], _ postActions: [ExecutionAction], _ preActions: [ExecutionAction], @@ -67,6 +70,7 @@ extension CreateLaunchAction { enableUBSanitizer: Bool, enableMainThreadChecker: Bool, enableThreadPerformanceChecker: Bool, + storeKitConfiguration: String?, environmentVariables: [EnvironmentVariable], postActions: [ExecutionAction], preActions: [ExecutionAction], @@ -202,12 +206,26 @@ ignoresPersistentStateOnLaunch = "NO" runnableString = "" } + let storeKitConfigurationString: String + if let storeKitConfiguration, storeKitConfiguration.count > 0, storeKitConfiguration != "None" { + + storeKitConfigurationString = #""" + + + +"""# + } else { + storeKitConfigurationString = "" + } + return #""" \#(preActions.preActionsString)\# \#(postActions.postActionsString)\# \#(runnableString)\# +\#(storeKitConfigurationString)\# \#(commandLineArguments.commandLineArgumentsString)\# \#(environmentVariables.environmentVariablesString)\# diff --git a/tools/generators/lib/XCScheme/test/CreateLaunchActionTests.swift b/tools/generators/lib/XCScheme/test/CreateLaunchActionTests.swift index 4cfb8368af..07bd1c9d87 100644 --- a/tools/generators/lib/XCScheme/test/CreateLaunchActionTests.swift +++ b/tools/generators/lib/XCScheme/test/CreateLaunchActionTests.swift @@ -605,6 +605,7 @@ private func createLaunchActionWithDefaults( enableUBSanitizer: enableUBSanitizer, enableMainThreadChecker: enableMainThreadChecker, enableThreadPerformanceChecker: enableThreadPerformanceChecker, + storeKitConfiguration: nil, environmentVariables: environmentVariables, postActions: postActions, preActions: preActions, diff --git a/tools/generators/xcschemes/src/Generator/CreateAutomaticSchemeInfo.swift b/tools/generators/xcschemes/src/Generator/CreateAutomaticSchemeInfo.swift index ea1dcc5072..87259732b0 100644 --- a/tools/generators/xcschemes/src/Generator/CreateAutomaticSchemeInfo.swift +++ b/tools/generators/xcschemes/src/Generator/CreateAutomaticSchemeInfo.swift @@ -137,6 +137,7 @@ extension Generator.CreateAutomaticSchemeInfo { enableUBSanitizer: false, enableMainThreadChecker: false, enableThreadPerformanceChecker: false, + storeKitConfiguration: nil, environmentVariables: runEnvironmentVariables, launchTarget: launchTarget, xcodeConfiguration: nil diff --git a/tools/generators/xcschemes/src/Generator/CreateCustomSchemeInfos.swift b/tools/generators/xcschemes/src/Generator/CreateCustomSchemeInfos.swift index 56996b2938..7472c73977 100644 --- a/tools/generators/xcschemes/src/Generator/CreateCustomSchemeInfos.swift +++ b/tools/generators/xcschemes/src/Generator/CreateCustomSchemeInfos.swift @@ -23,7 +23,9 @@ extension Generator { environmentVariables: [TargetID: [EnvironmentVariable]], executionActionsFile: URL, extensionHostIDs: [TargetID: [TargetID]], - targetsByID: [TargetID: Target] + targetsByID: [TargetID: Target], + installPath: String, + workspace: String ) async throws -> [SchemeInfo] { try await callable( /*commandLineArguments:*/ commandLineArguments, @@ -31,7 +33,9 @@ extension Generator { /*environmentVariables:*/ environmentVariables, /*executionActionsFile:*/ executionActionsFile, /*extensionHostIDs:*/ extensionHostIDs, - /*targetsByID:*/ targetsByID + /*targetsByID:*/ targetsByID, + /*installPath:*/ installPath, + /*workspace:*/ workspace ) } } @@ -40,13 +44,15 @@ extension Generator { // MARK: - CreateCustomSchemeInfos.Callable extension Generator.CreateCustomSchemeInfos { - typealias Callable = ( + typealias Callable = ( _ commandLineArguments: [TargetID: [CommandLineArgument]], _ customSchemesFile: URL, _ environmentVariables: [TargetID: [EnvironmentVariable]], _ executionActionsFile: URL, _ extensionHostIDs: [TargetID: [TargetID]], - _ targetsByID: [TargetID: Target] + _ targetsByID: [TargetID: Target], + _ installPath: String, + _ workspace: String ) async throws -> [SchemeInfo] static func defaultCallable( @@ -55,7 +61,9 @@ extension Generator.CreateCustomSchemeInfos { environmentVariables: [TargetID: [EnvironmentVariable]], executionActionsFile: URL, extensionHostIDs: [TargetID: [TargetID]], - targetsByID: [TargetID: Target] + targetsByID: [TargetID: Target], + installPath: String, + workspace: String ) async throws -> [SchemeInfo] { let executionActions: [String: [SchemeInfo.ExecutionAction]] = try await .parse( @@ -95,7 +103,9 @@ extension Generator.CreateCustomSchemeInfos { name: name, targetCommandLineArguments: commandLineArguments, targetEnvironmentVariables: environmentVariables, - targetsByID: targetsByID + targetsByID: targetsByID, + installPath: installPath, + workspace: workspace ) let profile = try rawArgs.consumeArg( @@ -453,6 +463,8 @@ set targetCommandLineArguments: [TargetID: [CommandLineArgument]], targetEnvironmentVariables: [TargetID: [EnvironmentVariable]], targetsByID: [TargetID: Target], + installPath: String, + workspace: String, file: StaticString = #filePath, line: UInt = #line ) throws -> SchemeInfo.Run { @@ -502,6 +514,19 @@ set let xcodeConfiguration = try consumeArg("run-xcode-configuration", as: String?.self, in: url) + let storeKitConfiguration = try consumeArg( + "run-storekit-configuration", + as: String?.self, + in: url + ) + var storeKitConfigurationWorkspaceRelativePath: String? + if let storeKitConfiguration { + // Provide an example path to xcschemes to relativize against + let installRootURL = URL(filePath: "\(workspace)/\(installPath)/xcshareddata/xcschemes") + let storekitConfigAbsolutePath = URL(filePath: "\(workspace)/\(storeKitConfiguration)") + storeKitConfigurationWorkspaceRelativePath = storekitConfigAbsolutePath.relativize(from: installRootURL) + } + var ( launchTarget, commandLineArguments, @@ -543,6 +568,7 @@ set enableUBSanitizer: enableUBSanitizer, enableMainThreadChecker: enableMainThreadChecker, enableThreadPerformanceChecker: enableThreadPerformanceChecker, + storeKitConfiguration: storeKitConfigurationWorkspaceRelativePath, environmentVariables: environmentVariables, launchTarget: launchTarget, xcodeConfiguration: xcodeConfiguration diff --git a/tools/generators/xcschemes/src/Generator/CreateScheme.swift b/tools/generators/xcschemes/src/Generator/CreateScheme.swift index 0725e0c238..bf9662524d 100644 --- a/tools/generators/xcschemes/src/Generator/CreateScheme.swift +++ b/tools/generators/xcschemes/src/Generator/CreateScheme.swift @@ -392,6 +392,7 @@ extension Generator.CreateScheme { enableUBSanitizer: schemeInfo.run.enableUBSanitizer, enableMainThreadChecker: schemeInfo.run.enableMainThreadChecker, enableThreadPerformanceChecker: schemeInfo.run.enableThreadPerformanceChecker, + storeKitConfiguration: schemeInfo.run.storeKitConfiguration, environmentVariables: launchRunnable == nil ? [] : schemeInfo.run.environmentVariables, postActions: launchPostActions diff --git a/tools/generators/xcschemes/src/Generator/Generator.swift b/tools/generators/xcschemes/src/Generator/Generator.swift index b7ffd0c674..536397dca6 100644 --- a/tools/generators/xcschemes/src/Generator/Generator.swift +++ b/tools/generators/xcschemes/src/Generator/Generator.swift @@ -45,7 +45,9 @@ struct Generator { environmentVariables: environmentVariables, executionActionsFile: arguments.executionActionsFile, extensionHostIDs: extensionHostIDs, - targetsByID: targetsByID + targetsByID: targetsByID, + installPath: arguments.installPath, + workspace: arguments.workspace ) let automaticSchemeInfos = try environment.createAutomaticSchemeInfos( diff --git a/tools/generators/xcschemes/src/Generator/SchemeInfo.swift b/tools/generators/xcschemes/src/Generator/SchemeInfo.swift index b9b05e1714..62b420b4a3 100644 --- a/tools/generators/xcschemes/src/Generator/SchemeInfo.swift +++ b/tools/generators/xcschemes/src/Generator/SchemeInfo.swift @@ -68,6 +68,7 @@ struct SchemeInfo: Equatable { let enableUBSanitizer: Bool let enableMainThreadChecker: Bool let enableThreadPerformanceChecker: Bool + let storeKitConfiguration: String? let environmentVariables: [EnvironmentVariable] let launchTarget: LaunchTarget? let xcodeConfiguration: String? diff --git a/tools/generators/xcschemes/src/Generator/URL+Extensions.swift b/tools/generators/xcschemes/src/Generator/URL+Extensions.swift new file mode 100644 index 0000000000..f2805fac43 --- /dev/null +++ b/tools/generators/xcschemes/src/Generator/URL+Extensions.swift @@ -0,0 +1,26 @@ +import Foundation +extension URL { + func relativize(from source: URL) -> String { + let sourceComponents = source.deletingLastPathComponent().pathComponents + let destComponents = self.pathComponents + + // Find common prefix + var commonPrefixCount = 0 + while commonPrefixCount < sourceComponents.count && + commonPrefixCount < destComponents.count && + sourceComponents[commonPrefixCount] == destComponents[commonPrefixCount] { + commonPrefixCount += 1 + } + + // Build relative path + var result = [String]() + + // Add "../" for each level to go up + result.append(contentsOf: Array(repeating: "..", count: sourceComponents.count - commonPrefixCount)) + + // Add remaining destination components + result.append(contentsOf: destComponents[commonPrefixCount...]) + + return result.joined(separator: "/") + } +} \ No newline at end of file diff --git a/tools/generators/xcschemes/test/CreateAutomaticSchemeInfoTests.swift b/tools/generators/xcschemes/test/CreateAutomaticSchemeInfoTests.swift index 95aff2f5a8..e9db8c4df2 100644 --- a/tools/generators/xcschemes/test/CreateAutomaticSchemeInfoTests.swift +++ b/tools/generators/xcschemes/test/CreateAutomaticSchemeInfoTests.swift @@ -150,6 +150,7 @@ final class CreateAutomaticSchemeInfoTests: XCTestCase { enableUBSanitizer: false, enableMainThreadChecker: false, enableThreadPerformanceChecker: false, + storeKitConfiguration: nil, environmentVariables: baseEnvironmentVariables, launchTarget: .target( primary: launchable, @@ -232,6 +233,7 @@ final class CreateAutomaticSchemeInfoTests: XCTestCase { enableUBSanitizer: false, enableMainThreadChecker: false, enableThreadPerformanceChecker: false, + storeKitConfiguration: nil, environmentVariables: baseEnvironmentVariables, launchTarget: .target( primary: launchable, @@ -310,6 +312,7 @@ final class CreateAutomaticSchemeInfoTests: XCTestCase { enableUBSanitizer: false, enableMainThreadChecker: false, enableThreadPerformanceChecker: false, + storeKitConfiguration: nil, environmentVariables: baseEnvironmentVariables, launchTarget: .target( primary: launchable, @@ -387,6 +390,7 @@ final class CreateAutomaticSchemeInfoTests: XCTestCase { enableUBSanitizer: false, enableMainThreadChecker: false, enableThreadPerformanceChecker: false, + storeKitConfiguration: nil, environmentVariables: baseEnvironmentVariables + environmentVariables, launchTarget: .target( @@ -463,6 +467,7 @@ final class CreateAutomaticSchemeInfoTests: XCTestCase { enableUBSanitizer: false, enableMainThreadChecker: false, enableThreadPerformanceChecker: false, + storeKitConfiguration: nil, environmentVariables: baseEnvironmentVariables, launchTarget: nil, xcodeConfiguration: nil @@ -531,6 +536,7 @@ final class CreateAutomaticSchemeInfoTests: XCTestCase { enableUBSanitizer: false, enableMainThreadChecker: false, enableThreadPerformanceChecker: false, + storeKitConfiguration: nil, environmentVariables: [], launchTarget: nil, xcodeConfiguration: nil @@ -602,6 +608,7 @@ final class CreateAutomaticSchemeInfoTests: XCTestCase { enableUBSanitizer: false, enableMainThreadChecker: false, enableThreadPerformanceChecker: false, + storeKitConfiguration: nil, environmentVariables: [], launchTarget: nil, xcodeConfiguration: nil @@ -674,6 +681,7 @@ final class CreateAutomaticSchemeInfoTests: XCTestCase { enableUBSanitizer: false, enableMainThreadChecker: false, enableThreadPerformanceChecker: false, + storeKitConfiguration: nil, environmentVariables: [], launchTarget: nil, xcodeConfiguration: nil @@ -741,6 +749,7 @@ final class CreateAutomaticSchemeInfoTests: XCTestCase { enableUBSanitizer: false, enableMainThreadChecker: false, enableThreadPerformanceChecker: false, + storeKitConfiguration: nil, environmentVariables: [], launchTarget: nil, xcodeConfiguration: nil diff --git a/tools/generators/xcschemes/test/SchemeInfo+Testing.swift b/tools/generators/xcschemes/test/SchemeInfo+Testing.swift index 9868cd1bd9..ee8cb1af13 100644 --- a/tools/generators/xcschemes/test/SchemeInfo+Testing.swift +++ b/tools/generators/xcschemes/test/SchemeInfo+Testing.swift @@ -52,6 +52,7 @@ extension SchemeInfo.Run { enableAddressSanitizer: Bool = false, enableThreadSanitizer: Bool = false, enableUBSanitizer: Bool = false, + storeKitConfiguration: String? = nil, environmentVariables: [EnvironmentVariable] = [], launchTarget: SchemeInfo.LaunchTarget? = nil, xcodeConfiguration: String? = nil @@ -65,6 +66,7 @@ extension SchemeInfo.Run { enableUBSanitizer: enableUBSanitizer, enableMainThreadChecker: enableMainThreadChecker, enableThreadPerformanceChecker: enableThreadPerformanceChecker, + storeKitConfiguration: storeKitConfiguration, environmentVariables: environmentVariables, launchTarget: launchTarget, xcodeConfiguration: xcodeConfiguration diff --git a/xcodeproj/internal/xcode_schemes.bzl b/xcodeproj/internal/xcode_schemes.bzl index 5daca94bbf..fd6b698705 100644 --- a/xcodeproj/internal/xcode_schemes.bzl +++ b/xcodeproj/internal/xcode_schemes.bzl @@ -352,7 +352,8 @@ also be modified in Xcode. build_configuration = None, diagnostics = None, env = None, - working_directory = None): + working_directory = None, + storekit_configuration = None): """Constructs a launch action for an Xcode scheme. Args: @@ -372,6 +373,9 @@ also be modified in Xcode. custom working directory in the Xcode scheme's launch action. Relative paths will be relative to the value of `target`'s `BUILT_PRODUCTS_DIR`, which is unique to it. + storekit_configuration: Optional. A `string` that will be set as + the custom StoreKit configuration in the Xcode scheme's launch + action. This should be a path relative to the workspace root. Returns: A `struct` representing a launch action. @@ -383,6 +387,7 @@ also be modified in Xcode. diagnostics = diagnostics, env = env, working_directory = working_directory, + storekit_configuration = storekit_configuration, ) def _profile_action( diff --git a/xcodeproj/internal/xcode_schemes_internal.bzl b/xcodeproj/internal/xcode_schemes_internal.bzl index f20b609da5..4306973844 100644 --- a/xcodeproj/internal/xcode_schemes_internal.bzl +++ b/xcodeproj/internal/xcode_schemes_internal.bzl @@ -184,7 +184,8 @@ def _launch_action( args = None, diagnostics = None, env = None, - working_directory = None): + working_directory = None, + storekit_configuration = None): """Constructs a launch action for an Xcode scheme. Args: @@ -198,6 +199,8 @@ def _launch_action( environment variables when the target is executed. working_directory: Optional. A `string` that will be set as the custom working directory in the Xcode scheme's launch action. + storekit_configuration: Optional. A `string` that will be set as the + StoreKit configuration in the Xcode scheme's launch action. Returns: A `struct` representing a launch action. @@ -209,6 +212,7 @@ def _launch_action( diagnostics = diagnostics, env = env if env != None else {}, working_directory = working_directory, + storekit_configuration = storekit_configuration, ) def _profile_action( diff --git a/xcodeproj/internal/xcschemes/xcscheme_infos.bzl b/xcodeproj/internal/xcschemes/xcscheme_infos.bzl index afe7ae7e2e..b83f274ed4 100644 --- a/xcodeproj/internal/xcschemes/xcscheme_infos.bzl +++ b/xcodeproj/internal/xcschemes/xcscheme_infos.bzl @@ -143,7 +143,8 @@ def _make_run( env = None, env_include_defaults = TRUE_ARG, launch_target = _make_launch_target(), - xcode_configuration = EMPTY_STRING): + xcode_configuration = EMPTY_STRING, + storekit_configuration = EMPTY_STRING): return struct( args = args, build_targets = build_targets, @@ -152,6 +153,7 @@ def _make_run( env_include_defaults = env_include_defaults, launch_target = launch_target, xcode_configuration = xcode_configuration, + storekit_configuration = storekit_configuration, ) def _make_test( @@ -620,6 +622,7 @@ def _run_info_from_dict( env_include_defaults = run["env_include_defaults"], launch_target = launch_target, xcode_configuration = xcode_configuration, + storekit_configuration = run["storekit_configuration"], ) def _test_info_from_dict( diff --git a/xcodeproj/internal/xcschemes/xcscheme_labels.bzl b/xcodeproj/internal/xcschemes/xcscheme_labels.bzl index bdc4617fc4..e0f5113fae 100644 --- a/xcodeproj/internal/xcschemes/xcscheme_labels.bzl +++ b/xcodeproj/internal/xcschemes/xcscheme_labels.bzl @@ -112,6 +112,7 @@ def _resolve_run_labels(run): env_include_defaults = run.env_include_defaults, launch_target = _resolve_launch_target_labels(run.launch_target), xcode_configuration = run.xcode_configuration, + storekit_configuration = run.storekit_configuration, ) def _resolve_test_labels(test): diff --git a/xcodeproj/internal/xcschemes/xcschemes.bzl b/xcodeproj/internal/xcschemes/xcschemes.bzl index c43793736a..5680430b47 100644 --- a/xcodeproj/internal/xcschemes/xcschemes.bzl +++ b/xcodeproj/internal/xcschemes/xcschemes.bzl @@ -212,7 +212,8 @@ def _run( env = "inherit", env_include_defaults = True, launch_target = None, - xcode_configuration = None): + xcode_configuration = None, + storekit_configuration = None): """Defines the Run action. Args: @@ -343,6 +344,7 @@ def _run( If not set, the value of [`xcodeproj.default_xcode_configuration`](#xcodeproj-default_xcode_configuration) is used. + storekit_configuration: a label that points to a storekit configuration file. """ return struct( args = args or [], @@ -352,6 +354,7 @@ def _run( env_include_defaults = TRUE_ARG if env_include_defaults else FALSE_ARG, launch_target = launch_target, xcode_configuration = xcode_configuration or "", + storekit_configuration = storekit_configuration, ) def _test( diff --git a/xcodeproj/internal/xcschemes/xcschemes_execution.bzl b/xcodeproj/internal/xcschemes/xcschemes_execution.bzl index 8c2d05f1de..086fc0fffe 100644 --- a/xcodeproj/internal/xcschemes/xcschemes_execution.bzl +++ b/xcodeproj/internal/xcschemes/xcschemes_execution.bzl @@ -342,6 +342,7 @@ def _write_schemes( custom_scheme_args.add(info.run.env_include_defaults) _add_diagnostics(info.run.diagnostics) custom_scheme_args.add(info.run.xcode_configuration) + custom_scheme_args.add(info.run.storekit_configuration) _add_launch_target( info.run.launch_target,