Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Ability to set executable to Ask to Launch #871

Merged
merged 5 commits into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions Sources/ProjectSpec/Scheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about defaulting to false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the key is by default non-existing instead of false

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this value were false, then the property would be nil. Is that what is intended?

askForAppToLaunch = askLaunch
}
}
}

Expand All @@ -377,6 +384,7 @@ extension Scheme.Run: JSONEncodable {
"config": config,
"language": language,
"region": region,
"askForAppToLaunch": askForAppToLaunch,
"launchAutomaticallySubstyle": launchAutomaticallySubstyle,
]

Expand Down
2 changes: 2 additions & 0 deletions Sources/XcodeGenKit/SchemeGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You would default here, using information from the rest of the target. If you have trouble with that, we can leave the existing behavior as the default for now.

allowLocationSimulation: allowLocationSimulation,
locationScenarioReference: locationScenarioReference,
disableMainThreadChecker: scheme.run?.disableMainThreadChecker ?? Scheme.Run.disableMainThreadCheckerDefault,
Expand Down
3 changes: 2 additions & 1 deletion Tests/XcodeGenKitTests/SchemeGeneratorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down