diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f9fb160..4365cc05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ - Add the ability to output a dependency graph in graphviz format [#852](https://github.com/yonaskolb/XcodeGen/pull/852) @jeffctown - Adds uncluttering the project manifest dumped to YAML from empty values [#858](https://github.com/yonaskolb/XcodeGen/pull/858) @paciej00 - Added ability to name the executable target when declaring schemes. [#869](https://github.com/yonaskolb/XcodeGen/pull/869) @elland - +- Added ability to set executable to Ask to Launch. [#871](https://github.com/yonaskolb/XcodeGen/pull/871) @pinda #### Fixed - Fixed issue when linking and embeding static frameworks: they should be linked and NOT embed. [#820](https://github.com/yonaskolb/XcodeGen/pull/820) @acecilia diff --git a/Sources/ProjectSpec/Scheme.swift b/Sources/ProjectSpec/Scheme.swift index 8910b760..e5022f98 100644 --- a/Sources/ProjectSpec/Scheme.swift +++ b/Sources/ProjectSpec/Scheme.swift @@ -108,6 +108,7 @@ public struct Scheme: Equatable { public var stopOnEveryMainThreadCheckerIssue: Bool public var language: String? public var region: String? + public var askForAppToLaunch: Bool? public var launchAutomaticallySubstyle: String? public var debugEnabled: Bool public var simulateLocation: SimulateLocation? @@ -124,6 +125,7 @@ public struct Scheme: Equatable { stopOnEveryMainThreadCheckerIssue: Bool = stopOnEveryMainThreadCheckerIssueDefault, language: String? = nil, region: String? = nil, + askForAppToLaunch: Bool? = nil, launchAutomaticallySubstyle: String? = nil, debugEnabled: Bool = debugEnabledDefault, simulateLocation: SimulateLocation? = nil @@ -137,6 +139,7 @@ public struct Scheme: Equatable { self.stopOnEveryMainThreadCheckerIssue = stopOnEveryMainThreadCheckerIssue self.language = language self.region = region + self.askForAppToLaunch = askForAppToLaunch self.launchAutomaticallySubstyle = launchAutomaticallySubstyle self.debugEnabled = debugEnabled self.simulateLocation = simulateLocation @@ -364,6 +367,10 @@ extension Scheme.Run: JSONObjectConvertible { } else if let string: String = jsonDictionary.json(atKeyPath: "launchAutomaticallySubstyle") { launchAutomaticallySubstyle = string } + + if let askLaunch: Bool = jsonDictionary.json(atKeyPath: "askForAppToLaunch") { + askForAppToLaunch = askLaunch + } } } @@ -377,6 +384,7 @@ extension Scheme.Run: JSONEncodable { "config": config, "language": language, "region": region, + "askForAppToLaunch": askForAppToLaunch, "launchAutomaticallySubstyle": launchAutomaticallySubstyle, ] diff --git a/Sources/XcodeGenKit/SchemeGenerator.swift b/Sources/XcodeGenKit/SchemeGenerator.swift index e247c33b..4e6164a9 100644 --- a/Sources/XcodeGenKit/SchemeGenerator.swift +++ b/Sources/XcodeGenKit/SchemeGenerator.swift @@ -233,6 +233,7 @@ public class SchemeGenerator { } locationScenarioReference = XCScheme.LocationScenarioReference(identifier: identifier, referenceType: referenceType.rawValue) } + let launchAction = XCScheme.LaunchAction( runnable: shouldExecuteOnLaunch ? runnables.launch : nil, buildConfiguration: scheme.run?.config ?? defaultDebugConfig.name, @@ -241,6 +242,7 @@ public class SchemeGenerator { macroExpansion: shouldExecuteOnLaunch ? nil : buildableReference, selectedDebuggerIdentifier: (scheme.run?.debugEnabled ?? Scheme.Run.debugEnabledDefault) ? XCScheme.defaultDebugger : "", selectedLauncherIdentifier: (scheme.run?.debugEnabled ?? Scheme.Run.debugEnabledDefault) ? XCScheme.defaultLauncher : "Xcode.IDEFoundation.Launcher.PosixSpawn", + askForAppToLaunch: scheme.run?.askForAppToLaunch, allowLocationSimulation: allowLocationSimulation, locationScenarioReference: locationScenarioReference, disableMainThreadChecker: scheme.run?.disableMainThreadChecker ?? Scheme.Run.disableMainThreadCheckerDefault, diff --git a/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift b/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift index a8aabe1c..07cfe748 100644 --- a/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift @@ -51,7 +51,7 @@ class SchemeGeneratorTests: XCTestCase { let scheme = Scheme( name: "MyScheme", build: Scheme.Build(targets: [buildTarget], preActions: [preAction]), - run: Scheme.Run(config: "Debug", launchAutomaticallySubstyle: "2", simulateLocation: simulateLocation) + run: Scheme.Run(config: "Debug", askForAppToLaunch: true, launchAutomaticallySubstyle: "2", simulateLocation: simulateLocation) ) let project = Project( name: "test", @@ -94,6 +94,7 @@ class SchemeGeneratorTests: XCTestCase { try expect(xcscheme.launchAction?.selectedDebuggerIdentifier) == XCScheme.defaultDebugger try expect(xcscheme.testAction?.selectedDebuggerIdentifier) == XCScheme.defaultDebugger + try expect(xcscheme.launchAction?.askForAppToLaunch) == true try expect(xcscheme.launchAction?.launchAutomaticallySubstyle) == "2" try expect(xcscheme.launchAction?.allowLocationSimulation) == true try expect(xcscheme.launchAction?.locationScenarioReference?.referenceType) == Scheme.SimulateLocation.ReferenceType.predefined.rawValue