From 77103a3c363d8f5fc72123a1a912dc119dbcb18d Mon Sep 17 00:00:00 2001 From: toshi0383 Date: Wed, 28 Feb 2018 00:18:08 +0900 Subject: [PATCH 1/3] Fix shouldUseLaunchSchemeArgsEnv disabling logic --- Sources/XcodeGenKit/ProjectGenerator.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sources/XcodeGenKit/ProjectGenerator.swift b/Sources/XcodeGenKit/ProjectGenerator.swift index e5417010..f3aef8f7 100644 --- a/Sources/XcodeGenKit/ProjectGenerator.swift +++ b/Sources/XcodeGenKit/ProjectGenerator.swift @@ -94,13 +94,14 @@ public class ProjectGenerator { let launchVariables = scheme.run.flatMap { $0.environmentVariables.isEmpty ? nil : $0.environmentVariables } let profileVariables = scheme.profile.flatMap { $0.environmentVariables.isEmpty ? nil : $0.environmentVariables } + let testAction = XCScheme.TestAction( buildConfiguration: scheme.test?.config ?? defaultDebugConfig.name, macroExpansion: buildableReference, testables: testables, preActions: scheme.test?.preActions.map(getExecutionAction) ?? [], postActions: scheme.test?.postActions.map(getExecutionAction) ?? [], - shouldUseLaunchSchemeArgsEnv: scheme.test?.commandLineArguments.isEmpty ?? true, + shouldUseLaunchSchemeArgsEnv: testCommandLineArgs == nil && testVariables == nil, codeCoverageEnabled: scheme.test?.gatherCoverageData ?? false, commandlineArguments: testCommandLineArgs, environmentVariables: testVariables, @@ -121,7 +122,7 @@ public class ProjectGenerator { buildConfiguration: scheme.profile?.config ?? defaultReleaseConfig.name, preActions: scheme.profile?.preActions.map(getExecutionAction) ?? [], postActions: scheme.profile?.postActions.map(getExecutionAction) ?? [], - shouldUseLaunchSchemeArgsEnv: scheme.profile?.commandLineArguments.isEmpty ?? true, + shouldUseLaunchSchemeArgsEnv: profileCommandLineArgs == nil && profileVariables == nil, commandlineArguments: profileCommandLineArgs, environmentVariables: profileVariables ) From ead24e8ce3e37e9052e5dfe555d354988559d469 Mon Sep 17 00:00:00 2001 From: toshi0383 Date: Wed, 28 Feb 2018 00:23:50 +0900 Subject: [PATCH 2/3] Remove unnecessary diff --- Sources/XcodeGenKit/ProjectGenerator.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Sources/XcodeGenKit/ProjectGenerator.swift b/Sources/XcodeGenKit/ProjectGenerator.swift index f3aef8f7..64bb7f04 100644 --- a/Sources/XcodeGenKit/ProjectGenerator.swift +++ b/Sources/XcodeGenKit/ProjectGenerator.swift @@ -94,7 +94,6 @@ public class ProjectGenerator { let launchVariables = scheme.run.flatMap { $0.environmentVariables.isEmpty ? nil : $0.environmentVariables } let profileVariables = scheme.profile.flatMap { $0.environmentVariables.isEmpty ? nil : $0.environmentVariables } - let testAction = XCScheme.TestAction( buildConfiguration: scheme.test?.config ?? defaultDebugConfig.name, macroExpansion: buildableReference, From 0a37fd54e3d1784c460cf9146d264934600c4415 Mon Sep 17 00:00:00 2001 From: toshi0383 Date: Thu, 1 Mar 2018 07:53:27 +0900 Subject: [PATCH 3/3] fix and refactor into extensions --- Sources/ProjectSpec/Scheme.swift | 8 ++++++++ Sources/XcodeGenKit/ProjectGenerator.swift | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Sources/ProjectSpec/Scheme.swift b/Sources/ProjectSpec/Scheme.swift index 4600d38b..28c4a4ac 100644 --- a/Sources/ProjectSpec/Scheme.swift +++ b/Sources/ProjectSpec/Scheme.swift @@ -140,6 +140,10 @@ public struct Scheme: Equatable { lhs.postActions == rhs.postActions && lhs.environmentVariables == rhs.environmentVariables } + + public var shouldUseLaunchSchemeArgsEnv: Bool { + return commandLineArguments.isEmpty && environmentVariables.isEmpty + } } public struct Analyze: BuildAction { @@ -180,6 +184,10 @@ public struct Scheme: Equatable { lhs.postActions == rhs.postActions && lhs.environmentVariables == rhs.environmentVariables } + + public var shouldUseLaunchSchemeArgsEnv: Bool { + return commandLineArguments.isEmpty && environmentVariables.isEmpty + } } public struct Archive: BuildAction { diff --git a/Sources/XcodeGenKit/ProjectGenerator.swift b/Sources/XcodeGenKit/ProjectGenerator.swift index 64bb7f04..5586772b 100644 --- a/Sources/XcodeGenKit/ProjectGenerator.swift +++ b/Sources/XcodeGenKit/ProjectGenerator.swift @@ -100,7 +100,7 @@ public class ProjectGenerator { testables: testables, preActions: scheme.test?.preActions.map(getExecutionAction) ?? [], postActions: scheme.test?.postActions.map(getExecutionAction) ?? [], - shouldUseLaunchSchemeArgsEnv: testCommandLineArgs == nil && testVariables == nil, + shouldUseLaunchSchemeArgsEnv: scheme.test?.shouldUseLaunchSchemeArgsEnv ?? true, codeCoverageEnabled: scheme.test?.gatherCoverageData ?? false, commandlineArguments: testCommandLineArgs, environmentVariables: testVariables, @@ -121,7 +121,7 @@ public class ProjectGenerator { buildConfiguration: scheme.profile?.config ?? defaultReleaseConfig.name, preActions: scheme.profile?.preActions.map(getExecutionAction) ?? [], postActions: scheme.profile?.postActions.map(getExecutionAction) ?? [], - shouldUseLaunchSchemeArgsEnv: profileCommandLineArgs == nil && profileVariables == nil, + shouldUseLaunchSchemeArgsEnv: scheme.profile?.shouldUseLaunchSchemeArgsEnv ?? true, commandlineArguments: profileCommandLineArgs, environmentVariables: profileVariables )