Add language and region options for scheme (#654)

Add language and region options for scheme
This commit is contained in:
Yonas Kolb
2019-09-14 13:15:08 +10:00
committed by GitHub
6 changed files with 35 additions and 4 deletions
+1
View File
@@ -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
+2
View File
@@ -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
+22 -2
View File
@@ -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 {
+6 -2
View File
@@ -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(
@@ -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">
<Testables>
+2
View File
@@ -257,6 +257,8 @@ schemes:
argument.with.dot: YES
test:
gatherCoverageData: true
language: ja
region: en
App_Scheme:
build:
targets: