From 958e17c2f2907426c7df076c9b0850d08d77c9a9 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Fri, 13 Sep 2019 09:46:01 +0900 Subject: [PATCH 1/5] Add language and region option to test scheme --- Sources/ProjectSpec/Scheme.swift | 24 +++++++++++++++++++++-- Sources/XcodeGenKit/SchemeGenerator.swift | 8 ++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/Sources/ProjectSpec/Scheme.swift b/Sources/ProjectSpec/Scheme.swift index 6e58be0c..f60a26da 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 @@ -146,7 +154,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 @@ -156,6 +166,8 @@ public struct Scheme: Equatable { self.preActions = preActions self.postActions = postActions self.environmentVariables = environmentVariables + self.language = language + self.region = region } public var shouldUseLaunchSchemeArgsEnv: Bool { @@ -261,6 +273,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") } } @@ -272,6 +286,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 { @@ -305,6 +321,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") } } @@ -317,6 +335,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 df9c9d53..2af0b16e 100644 --- a/Sources/XcodeGenKit/SchemeGenerator.swift +++ b/Sources/XcodeGenKit/SchemeGenerator.swift @@ -156,7 +156,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( @@ -167,7 +169,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( From fc5979150c2f14d200bfc14df704c805313a4e2c Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Fri, 13 Sep 2019 09:46:42 +0900 Subject: [PATCH 2/5] Update TestProject project.yml --- Tests/Fixtures/TestProject/project.yml | 2 ++ 1 file changed, 2 insertions(+) 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: From d33d55cc5b968997e221369211f363a4f17a465a Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Fri, 13 Sep 2019 09:48:44 +0900 Subject: [PATCH 3/5] Update generated xcscheme --- .../Project.xcodeproj/xcshareddata/xcschemes/Framework.xcscheme | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tests/Fixtures/TestProject/Project.xcodeproj/xcshareddata/xcschemes/Framework.xcscheme b/Tests/Fixtures/TestProject/Project.xcodeproj/xcshareddata/xcschemes/Framework.xcscheme index 202f16e5..85c9e498 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"> From 980d0303a6429ab20055a9ad760625fe997b3d19 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Fri, 13 Sep 2019 10:03:38 +0900 Subject: [PATCH 4/5] Update ProjectSpec.md --- Docs/ProjectSpec.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Docs/ProjectSpec.md b/Docs/ProjectSpec.md index 76fa3074..c87cf910 100644 --- a/Docs/ProjectSpec.md +++ b/Docs/ProjectSpec.md @@ -685,6 +685,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 From 7eff9031f8233bb0cbf0114bd5ebdc0288a69d7b Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Fri, 13 Sep 2019 10:05:35 +0900 Subject: [PATCH 5/5] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d113e13..d9381cfc 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) +- Added `language` and `region` options for `run` and `test` scheme [#654](https://github.com/yonaskolb/XcodeGen/pull/654) #### Fixed