diff --git a/CHANGELOG.md b/CHANGELOG.md index f5c529ba..05073361 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Added `includes` to `sources` for a Target. This follows the same glob-style as `excludes` but functions as a way to only include files that match a specified pattern. Useful if you only want a certain file type, for example specifying `**/*.swift`. [#637](https://github.com/yonaskolb/XcodeGen/pull/637) @bclymer - Support `dylib` SDK. [#650](https://github.com/yonaskolb/XcodeGen/pull/650) @kateinoigakukun +- Added `language` and `region` options for `run` and `test` scheme [#654](https://github.com/yonaskolb/XcodeGen/pull/654) @kateinoigakukun - Support External Target Reference. [#655](https://github.com/yonaskolb/XcodeGen/pull/655) @kateinoigakukun #### Fixed diff --git a/Docs/ProjectSpec.md b/Docs/ProjectSpec.md index 65ff487a..3f887516 100644 --- a/Docs/ProjectSpec.md +++ b/Docs/ProjectSpec.md @@ -689,6 +689,8 @@ The different actions share some properties: - [ ] **postActions**: **[[Execution Action](#execution-action)]** - Scripts that are run *after* the action - [ ] **environmentVariables**: **[[Environment Variable](#environment-variable)]** or **[String:String]** - `run`, `test` and `profile` actions can define the environment variables. When passing a dictionary, every key-value entry maps to a corresponding variable that is enabled. - [ ] **disableMainThreadChecker**: **Bool** - `run` and `test` actions can define a boolean that indicates that this scheme should disable the Main Thread Checker. This defaults to false +- [ ] **language**: **String** - `run` and `test` actions can define a language that is used for Application Language +- [ ] **region**: **String** - `run` and `test` actions can define a language that is used for Application Region ### Execution Action diff --git a/Sources/ProjectSpec/Scheme.swift b/Sources/ProjectSpec/Scheme.swift index 4796e276..dcc9d82b 100644 --- a/Sources/ProjectSpec/Scheme.swift +++ b/Sources/ProjectSpec/Scheme.swift @@ -76,6 +76,8 @@ public struct Scheme: Equatable { public var postActions: [ExecutionAction] public var environmentVariables: [XCScheme.EnvironmentVariable] public var disableMainThreadChecker: Bool + public var language: String? + public var region: String? public init( config: String, @@ -83,7 +85,9 @@ public struct Scheme: Equatable { preActions: [ExecutionAction] = [], postActions: [ExecutionAction] = [], environmentVariables: [XCScheme.EnvironmentVariable] = [], - disableMainThreadChecker: Bool = disableMainThreadCheckerDefault + disableMainThreadChecker: Bool = disableMainThreadCheckerDefault, + language: String? = nil, + region: String? = nil ) { self.config = config self.commandLineArguments = commandLineArguments @@ -91,6 +95,8 @@ public struct Scheme: Equatable { self.postActions = postActions self.environmentVariables = environmentVariables self.disableMainThreadChecker = disableMainThreadChecker + self.language = language + self.region = region } } @@ -106,6 +112,8 @@ public struct Scheme: Equatable { public var preActions: [ExecutionAction] public var postActions: [ExecutionAction] public var environmentVariables: [XCScheme.EnvironmentVariable] + public var language: String? + public var region: String? public struct TestTarget: Equatable, ExpressibleByStringLiteral { public static let randomExecutionOrderDefault = false @@ -150,7 +158,9 @@ public struct Scheme: Equatable { targets: [TestTarget] = [], preActions: [ExecutionAction] = [], postActions: [ExecutionAction] = [], - environmentVariables: [XCScheme.EnvironmentVariable] = [] + environmentVariables: [XCScheme.EnvironmentVariable] = [], + language: String? = nil, + region: String? = nil ) { self.config = config self.gatherCoverageData = gatherCoverageData @@ -160,6 +170,8 @@ public struct Scheme: Equatable { self.preActions = preActions self.postActions = postActions self.environmentVariables = environmentVariables + self.language = language + self.region = region } public var shouldUseLaunchSchemeArgsEnv: Bool { @@ -267,6 +279,8 @@ extension Scheme.Run: JSONObjectConvertible { postActions = jsonDictionary.json(atKeyPath: "postActions") ?? [] environmentVariables = try XCScheme.EnvironmentVariable.parseAll(jsonDictionary: jsonDictionary) disableMainThreadChecker = jsonDictionary.json(atKeyPath: "disableMainThreadChecker") ?? Scheme.Run.disableMainThreadCheckerDefault + language = jsonDictionary.json(atKeyPath: "language") + region = jsonDictionary.json(atKeyPath: "region") } } @@ -278,6 +292,8 @@ extension Scheme.Run: JSONEncodable { "postActions": postActions.map { $0.toJSONValue() }, "environmentVariables": environmentVariables.map { $0.toJSONValue() }, "config": config, + "language": language, + "region": region, ] if disableMainThreadChecker != Scheme.Run.disableMainThreadCheckerDefault { @@ -311,6 +327,8 @@ extension Scheme.Test: JSONObjectConvertible { preActions = jsonDictionary.json(atKeyPath: "preActions") ?? [] postActions = jsonDictionary.json(atKeyPath: "postActions") ?? [] environmentVariables = try XCScheme.EnvironmentVariable.parseAll(jsonDictionary: jsonDictionary) + language = jsonDictionary.json(atKeyPath: "language") + region = jsonDictionary.json(atKeyPath: "region") } } @@ -323,6 +341,8 @@ extension Scheme.Test: JSONEncodable { "postActions": postActions.map { $0.toJSONValue() }, "environmentVariables": environmentVariables.map { $0.toJSONValue() }, "config": config, + "language": language, + "region": region, ] if gatherCoverageData != Scheme.Test.gatherCoverageDataDefault { diff --git a/Sources/XcodeGenKit/SchemeGenerator.swift b/Sources/XcodeGenKit/SchemeGenerator.swift index 3c9dc8e9..8f214e88 100644 --- a/Sources/XcodeGenKit/SchemeGenerator.swift +++ b/Sources/XcodeGenKit/SchemeGenerator.swift @@ -161,7 +161,9 @@ public class SchemeGenerator { codeCoverageEnabled: scheme.test?.gatherCoverageData ?? Scheme.Test.gatherCoverageDataDefault, disableMainThreadChecker: scheme.test?.disableMainThreadChecker ?? Scheme.Test.disableMainThreadCheckerDefault, commandlineArguments: testCommandLineArgs, - environmentVariables: testVariables + environmentVariables: testVariables, + language: scheme.test?.language, + region: scheme.test?.region ) let launchAction = XCScheme.LaunchAction( @@ -172,7 +174,9 @@ public class SchemeGenerator { macroExpansion: shouldExecuteOnLaunch ? nil : buildableReference, disableMainThreadChecker: scheme.run?.disableMainThreadChecker ?? Scheme.Run.disableMainThreadCheckerDefault, commandlineArguments: launchCommandLineArgs, - environmentVariables: launchVariables + environmentVariables: launchVariables, + language: scheme.run?.language, + region: scheme.run?.region ) let profileAction = XCScheme.ProfileAction( diff --git a/Tests/Fixtures/TestProject/Project.xcodeproj/xcshareddata/xcschemes/Framework.xcscheme b/Tests/Fixtures/TestProject/Project.xcodeproj/xcshareddata/xcschemes/Framework.xcscheme index e07ddcef..ecc9364b 100644 --- a/Tests/Fixtures/TestProject/Project.xcodeproj/xcshareddata/xcschemes/Framework.xcscheme +++ b/Tests/Fixtures/TestProject/Project.xcodeproj/xcshareddata/xcschemes/Framework.xcscheme @@ -44,6 +44,8 @@ buildConfiguration = "Production Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "ja" + region = "en" codeCoverageEnabled = "YES" shouldUseLaunchSchemeArgsEnv = "YES"> diff --git a/Tests/Fixtures/TestProject/project.yml b/Tests/Fixtures/TestProject/project.yml index 12aee852..dc60a0ba 100644 --- a/Tests/Fixtures/TestProject/project.yml +++ b/Tests/Fixtures/TestProject/project.yml @@ -257,6 +257,8 @@ schemes: argument.with.dot: YES test: gatherCoverageData: true + language: ja + region: en App_Scheme: build: targets: