mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2026-03-18 20:02:25 +00:00
Merge pull request #601 from wag-miles/disable_main_thread_checker
Added disableMainThreadChecker to TargetScheme and Run/Test Actions
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
|
||||
## Next Version
|
||||
|
||||
#### Added
|
||||
- Added ability to disable main thread checker on Run and Test schemes and TargetSchemes [#601](https://github.com/yonaskolb/XcodeGen/pull/601) @wag-miles
|
||||
|
||||
#### Fixed
|
||||
- Fixed included specs that were referenced multiple times from duplicating content [#599](https://github.com/yonaskolb/XcodeGen/pull/599) @haritowa
|
||||
- Fixed `.orig` files being added to the project [#627](https://github.com/yonaskolb/XcodeGen/pull/627) @keith
|
||||
|
||||
@@ -547,6 +547,7 @@ This is a convenience used to automatically generate schemes for a target based
|
||||
- [x] **configVariants**: **[String]** - This generates a scheme for each entry, using configs that contain the name with debug and release variants. This is useful for having different environment schemes.
|
||||
- [ ] **testTargets**: **[[Test Target](#test-target)]** - a list of test targets that should be included in the scheme. These will be added to the build targets and the test entries. Each entry can either be a simple string, or a [Test Target](#test-target)
|
||||
- [ ] **gatherCoverageData**: **Bool** - a boolean that indicates if this scheme should gather coverage data. This defaults to false
|
||||
- [ ] **disableMainThreadChecker**: **Bool** - a boolean that indicates if this scheme should disable disable the Main Thread Checker. This defaults to false
|
||||
- [ ] **commandLineArguments**: **[String:Bool]** - a dictionary from the argument name (`String`) to if it is enabled (`Bool`). These arguments will be added to the Test, Profile and Run scheme actions
|
||||
- [ ] **environmentVariables**: **[[Environment Variable](#environment-variable)]** or **[String:String]** - environment variables for Run, Test and Profile scheme actions. When passing a dictionary, every key-value entry maps to a corresponding variable that is enabled.
|
||||
- [ ] **preActions**: **[[Execution Action](#execution-action)]** - Scripts that are run *before* all actions
|
||||
@@ -679,6 +680,7 @@ The different actions share some properties:
|
||||
- [ ] **preActions**: **[[Execution Action](#execution-action)]** - Scripts that are run *before* the action
|
||||
- [ ] **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
|
||||
|
||||
### Execution Action
|
||||
|
||||
|
||||
@@ -68,31 +68,39 @@ public struct Scheme: Equatable {
|
||||
}
|
||||
|
||||
public struct Run: BuildAction {
|
||||
public static let disableMainThreadCheckerDefault = false
|
||||
|
||||
public var config: String?
|
||||
public var commandLineArguments: [String: Bool]
|
||||
public var preActions: [ExecutionAction]
|
||||
public var postActions: [ExecutionAction]
|
||||
public var environmentVariables: [XCScheme.EnvironmentVariable]
|
||||
public var disableMainThreadChecker: Bool
|
||||
|
||||
public init(
|
||||
config: String,
|
||||
commandLineArguments: [String: Bool] = [:],
|
||||
preActions: [ExecutionAction] = [],
|
||||
postActions: [ExecutionAction] = [],
|
||||
environmentVariables: [XCScheme.EnvironmentVariable] = []
|
||||
environmentVariables: [XCScheme.EnvironmentVariable] = [],
|
||||
disableMainThreadChecker: Bool = disableMainThreadCheckerDefault
|
||||
) {
|
||||
self.config = config
|
||||
self.commandLineArguments = commandLineArguments
|
||||
self.preActions = preActions
|
||||
self.postActions = postActions
|
||||
self.environmentVariables = environmentVariables
|
||||
self.disableMainThreadChecker = disableMainThreadChecker
|
||||
}
|
||||
}
|
||||
|
||||
public struct Test: BuildAction {
|
||||
public static let gatherCoverageDataDefault = false
|
||||
public static let disableMainThreadCheckerDefault = false
|
||||
|
||||
public var config: String?
|
||||
public var gatherCoverageData: Bool
|
||||
public var disableMainThreadChecker: Bool
|
||||
public var commandLineArguments: [String: Bool]
|
||||
public var targets: [TestTarget]
|
||||
public var preActions: [ExecutionAction]
|
||||
@@ -131,6 +139,7 @@ public struct Scheme: Equatable {
|
||||
public init(
|
||||
config: String,
|
||||
gatherCoverageData: Bool = gatherCoverageDataDefault,
|
||||
disableMainThreadChecker: Bool = disableMainThreadCheckerDefault,
|
||||
randomExecutionOrder: Bool = false,
|
||||
parallelizable: Bool = false,
|
||||
commandLineArguments: [String: Bool] = [:],
|
||||
@@ -141,6 +150,7 @@ public struct Scheme: Equatable {
|
||||
) {
|
||||
self.config = config
|
||||
self.gatherCoverageData = gatherCoverageData
|
||||
self.disableMainThreadChecker = disableMainThreadChecker
|
||||
self.commandLineArguments = commandLineArguments
|
||||
self.targets = targets
|
||||
self.preActions = preActions
|
||||
@@ -250,18 +260,25 @@ extension Scheme.Run: JSONObjectConvertible {
|
||||
preActions = jsonDictionary.json(atKeyPath: "preActions") ?? []
|
||||
postActions = jsonDictionary.json(atKeyPath: "postActions") ?? []
|
||||
environmentVariables = try XCScheme.EnvironmentVariable.parseAll(jsonDictionary: jsonDictionary)
|
||||
disableMainThreadChecker = jsonDictionary.json(atKeyPath: "disableMainThreadChecker") ?? Scheme.Run.disableMainThreadCheckerDefault
|
||||
}
|
||||
}
|
||||
|
||||
extension Scheme.Run: JSONEncodable {
|
||||
public func toJSONValue() -> Any {
|
||||
return [
|
||||
var dict: [String: Any?] = [
|
||||
"commandLineArguments": commandLineArguments,
|
||||
"preActions": preActions.map { $0.toJSONValue() },
|
||||
"postActions": postActions.map { $0.toJSONValue() },
|
||||
"environmentVariables": environmentVariables.map { $0.toJSONValue() },
|
||||
"config": config
|
||||
] as [String: Any?]
|
||||
]
|
||||
|
||||
if disableMainThreadChecker != Scheme.Run.disableMainThreadCheckerDefault {
|
||||
dict["disableMainThreadChecker"] = disableMainThreadChecker
|
||||
}
|
||||
|
||||
return dict
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,6 +287,7 @@ extension Scheme.Test: JSONObjectConvertible {
|
||||
public init(jsonDictionary: JSONDictionary) throws {
|
||||
config = jsonDictionary.json(atKeyPath: "config")
|
||||
gatherCoverageData = jsonDictionary.json(atKeyPath: "gatherCoverageData") ?? Scheme.Test.gatherCoverageDataDefault
|
||||
disableMainThreadChecker = jsonDictionary.json(atKeyPath: "disableMainThreadChecker") ?? Scheme.Test.disableMainThreadCheckerDefault
|
||||
commandLineArguments = jsonDictionary.json(atKeyPath: "commandLineArguments") ?? [:]
|
||||
if let targets = jsonDictionary["targets"] as? [Any] {
|
||||
self.targets = try targets.compactMap { target in
|
||||
@@ -292,15 +310,24 @@ extension Scheme.Test: JSONObjectConvertible {
|
||||
|
||||
extension Scheme.Test: JSONEncodable {
|
||||
public func toJSONValue() -> Any {
|
||||
return [
|
||||
"gatherCoverageData": gatherCoverageData,
|
||||
var dict: [String: Any?] = [
|
||||
"commandLineArguments": commandLineArguments,
|
||||
"targets": targets.map { $0.toJSONValue() },
|
||||
"preActions": preActions.map { $0.toJSONValue() },
|
||||
"postActions": postActions.map { $0.toJSONValue() },
|
||||
"environmentVariables": environmentVariables.map { $0.toJSONValue() },
|
||||
"config": config
|
||||
] as [String: Any?]
|
||||
]
|
||||
|
||||
if gatherCoverageData != Scheme.Test.gatherCoverageDataDefault {
|
||||
dict["gatherCoverageData"] = gatherCoverageData
|
||||
}
|
||||
|
||||
if disableMainThreadChecker != Scheme.Test.disableMainThreadCheckerDefault {
|
||||
dict["disableMainThreadChecker"] = disableMainThreadChecker
|
||||
}
|
||||
|
||||
return dict
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,12 @@ import XcodeProj
|
||||
|
||||
public struct TargetScheme: Equatable {
|
||||
public static let gatherCoverageDataDefault = false
|
||||
public static let disableMainThreadCheckerDefault = false
|
||||
|
||||
public var testTargets: [Scheme.Test.TestTarget]
|
||||
public var configVariants: [String]
|
||||
public var gatherCoverageData: Bool
|
||||
public var disableMainThreadChecker: Bool
|
||||
public var commandLineArguments: [String: Bool]
|
||||
public var environmentVariables: [XCScheme.EnvironmentVariable]
|
||||
public var preActions: [Scheme.ExecutionAction]
|
||||
@@ -17,6 +19,7 @@ public struct TargetScheme: Equatable {
|
||||
testTargets: [Scheme.Test.TestTarget] = [],
|
||||
configVariants: [String] = [],
|
||||
gatherCoverageData: Bool = gatherCoverageDataDefault,
|
||||
disableMainThreadChecker: Bool = disableMainThreadCheckerDefault,
|
||||
commandLineArguments: [String: Bool] = [:],
|
||||
environmentVariables: [XCScheme.EnvironmentVariable] = [],
|
||||
preActions: [Scheme.ExecutionAction] = [],
|
||||
@@ -25,6 +28,7 @@ public struct TargetScheme: Equatable {
|
||||
self.testTargets = testTargets
|
||||
self.configVariants = configVariants
|
||||
self.gatherCoverageData = gatherCoverageData
|
||||
self.disableMainThreadChecker = disableMainThreadChecker
|
||||
self.commandLineArguments = commandLineArguments
|
||||
self.environmentVariables = environmentVariables
|
||||
self.preActions = preActions
|
||||
@@ -50,6 +54,7 @@ extension TargetScheme: JSONObjectConvertible {
|
||||
}
|
||||
configVariants = jsonDictionary.json(atKeyPath: "configVariants") ?? []
|
||||
gatherCoverageData = jsonDictionary.json(atKeyPath: "gatherCoverageData") ?? TargetScheme.gatherCoverageDataDefault
|
||||
disableMainThreadChecker = jsonDictionary.json(atKeyPath: "disableMainThreadChecker") ?? TargetScheme.disableMainThreadCheckerDefault
|
||||
commandLineArguments = jsonDictionary.json(atKeyPath: "commandLineArguments") ?? [:]
|
||||
environmentVariables = try XCScheme.EnvironmentVariable.parseAll(jsonDictionary: jsonDictionary)
|
||||
preActions = jsonDictionary.json(atKeyPath: "preActions") ?? []
|
||||
@@ -72,6 +77,10 @@ extension TargetScheme: JSONEncodable {
|
||||
dict["gatherCoverageData"] = gatherCoverageData
|
||||
}
|
||||
|
||||
if disableMainThreadChecker != TargetScheme.disableMainThreadCheckerDefault {
|
||||
dict["disableMainThreadChecker"] = disableMainThreadChecker
|
||||
}
|
||||
|
||||
return dict
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,8 @@ public class SchemeGenerator {
|
||||
preActions: scheme.test?.preActions.map(getExecutionAction) ?? [],
|
||||
postActions: scheme.test?.postActions.map(getExecutionAction) ?? [],
|
||||
shouldUseLaunchSchemeArgsEnv: scheme.test?.shouldUseLaunchSchemeArgsEnv ?? true,
|
||||
codeCoverageEnabled: scheme.test?.gatherCoverageData ?? false,
|
||||
codeCoverageEnabled: scheme.test?.gatherCoverageData ?? Scheme.Test.gatherCoverageDataDefault,
|
||||
disableMainThreadChecker: scheme.test?.disableMainThreadChecker ?? Scheme.Test.disableMainThreadCheckerDefault,
|
||||
commandlineArguments: testCommandLineArgs,
|
||||
environmentVariables: testVariables
|
||||
)
|
||||
@@ -164,6 +165,7 @@ public class SchemeGenerator {
|
||||
preActions: scheme.run?.preActions.map(getExecutionAction) ?? [],
|
||||
postActions: scheme.run?.postActions.map(getExecutionAction) ?? [],
|
||||
macroExpansion: shouldExecuteOnLaunch ? nil : buildableReference,
|
||||
disableMainThreadChecker: scheme.run?.disableMainThreadChecker ?? Scheme.Run.disableMainThreadCheckerDefault,
|
||||
commandlineArguments: launchCommandLineArgs,
|
||||
environmentVariables: launchVariables
|
||||
)
|
||||
@@ -212,11 +214,13 @@ extension Scheme {
|
||||
commandLineArguments: targetScheme.commandLineArguments,
|
||||
preActions: targetScheme.preActions,
|
||||
postActions: targetScheme.postActions,
|
||||
environmentVariables: targetScheme.environmentVariables
|
||||
environmentVariables: targetScheme.environmentVariables,
|
||||
disableMainThreadChecker: targetScheme.disableMainThreadChecker
|
||||
),
|
||||
test: .init(
|
||||
config: debugConfig,
|
||||
gatherCoverageData: targetScheme.gatherCoverageData,
|
||||
disableMainThreadChecker: targetScheme.disableMainThreadChecker,
|
||||
commandLineArguments: targetScheme.commandLineArguments,
|
||||
targets: targetScheme.testTargets,
|
||||
preActions: targetScheme.preActions,
|
||||
|
||||
+4
-2
@@ -27,7 +27,8 @@
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
codeCoverageEnabled = "YES"
|
||||
shouldUseLaunchSchemeArgsEnv = "NO">
|
||||
shouldUseLaunchSchemeArgsEnv = "NO"
|
||||
disableMainThreadChecker = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
@@ -83,7 +84,8 @@
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
allowLocationSimulation = "YES"
|
||||
disableMainThreadChecker = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
|
||||
+4
-2
@@ -27,7 +27,8 @@
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
codeCoverageEnabled = "YES"
|
||||
shouldUseLaunchSchemeArgsEnv = "NO">
|
||||
shouldUseLaunchSchemeArgsEnv = "NO"
|
||||
disableMainThreadChecker = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
@@ -83,7 +84,8 @@
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
allowLocationSimulation = "YES"
|
||||
disableMainThreadChecker = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
|
||||
+4
-2
@@ -27,7 +27,8 @@
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
codeCoverageEnabled = "YES"
|
||||
shouldUseLaunchSchemeArgsEnv = "NO">
|
||||
shouldUseLaunchSchemeArgsEnv = "NO"
|
||||
disableMainThreadChecker = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
@@ -83,7 +84,8 @@
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
allowLocationSimulation = "YES"
|
||||
disableMainThreadChecker = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
|
||||
@@ -96,6 +96,7 @@ targets:
|
||||
- App_iOS_Tests
|
||||
- App_iOS_UITests
|
||||
gatherCoverageData: true
|
||||
disableMainThreadChecker: true
|
||||
configVariants:
|
||||
- Test
|
||||
- Staging
|
||||
|
||||
@@ -18,6 +18,7 @@ extension Project {
|
||||
testTargets: [],
|
||||
configVariants: ["Test", "Staging", "Prod"],
|
||||
gatherCoverageData: true,
|
||||
disableMainThreadChecker: true,
|
||||
commandLineArguments: [
|
||||
"--command": true,
|
||||
"--command2": false,
|
||||
|
||||
@@ -337,6 +337,7 @@ class ProjectSpecTests: XCTestCase {
|
||||
parallelizable: false)],
|
||||
configVariants: ["foo"],
|
||||
gatherCoverageData: true,
|
||||
disableMainThreadChecker: true,
|
||||
commandLineArguments: ["foo": true],
|
||||
environmentVariables: [XCScheme.EnvironmentVariable(variable: "environmentVariable",
|
||||
value: "bar",
|
||||
@@ -374,6 +375,7 @@ class ProjectSpecTests: XCTestCase {
|
||||
parallelizable: false)],
|
||||
configVariants: ["foo"],
|
||||
gatherCoverageData: true,
|
||||
disableMainThreadChecker: true,
|
||||
commandLineArguments: ["foo": true],
|
||||
environmentVariables: [XCScheme.EnvironmentVariable(variable: "environmentVariable",
|
||||
value: "bar",
|
||||
@@ -419,6 +421,7 @@ class ProjectSpecTests: XCTestCase {
|
||||
enabled: false)]),
|
||||
test: Scheme.Test(config: "Config",
|
||||
gatherCoverageData: true,
|
||||
disableMainThreadChecker: true,
|
||||
randomExecutionOrder: false,
|
||||
parallelizable: false,
|
||||
commandLineArguments: ["foo": true],
|
||||
|
||||
@@ -699,6 +699,7 @@ class SpecLoadingTests: XCTestCase {
|
||||
"ENV1": true,
|
||||
],
|
||||
"gatherCoverageData": true,
|
||||
"disableMainThreadChecker": true,
|
||||
"environmentVariables": [
|
||||
"TEST_VAR": "TEST_VAL",
|
||||
],
|
||||
@@ -722,6 +723,7 @@ class SpecLoadingTests: XCTestCase {
|
||||
testTargets: ["t1", "t2"],
|
||||
configVariants: ["dev", "app-store"],
|
||||
gatherCoverageData: true,
|
||||
disableMainThreadChecker: true,
|
||||
commandLineArguments: ["ENV1": true],
|
||||
environmentVariables: [XCScheme.EnvironmentVariable(variable: "TEST_VAR", value: "TEST_VAL", enabled: true)],
|
||||
preActions: [.init(name: "Do Thing", script: "dothing", settingsTarget: "test")],
|
||||
@@ -764,6 +766,7 @@ class SpecLoadingTests: XCTestCase {
|
||||
],
|
||||
],
|
||||
"gatherCoverageData": true,
|
||||
"disableMainThreadChecker": true
|
||||
],
|
||||
]
|
||||
let scheme = try Scheme(name: "Scheme", jsonDictionary: schemeDictionary)
|
||||
@@ -787,6 +790,7 @@ class SpecLoadingTests: XCTestCase {
|
||||
let expectedTest = Scheme.Test(
|
||||
config: "debug",
|
||||
gatherCoverageData: true,
|
||||
disableMainThreadChecker: true,
|
||||
targets: [
|
||||
"Target1",
|
||||
Scheme.Test.TestTarget(
|
||||
|
||||
Reference in New Issue
Block a user