From df20befa616d9b0b2d42e4cc389360e085a8a8f9 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Thu, 25 Jan 2018 15:58:35 -0800 Subject: [PATCH] Pass scheme execution actions down to xcproj --- Sources/ProjectSpec/Scheme.swift | 6 ++++++ Sources/XcodeGenKit/ProjectGenerator.swift | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Sources/ProjectSpec/Scheme.swift b/Sources/ProjectSpec/Scheme.swift index 3cee65fc..c6f0841c 100644 --- a/Sources/ProjectSpec/Scheme.swift +++ b/Sources/ProjectSpec/Scheme.swift @@ -209,6 +209,12 @@ protocol BuildAction: Equatable { var config: String { get } } +extension XCScheme.ExecutionAction { + public convenience init(_ executionAction: Scheme.ExecutionAction) { + self.init(scriptText: executionAction.script, title: executionAction.name) + } +} + extension Scheme.ExecutionAction: JSONObjectConvertible { public init(jsonDictionary: JSONDictionary) throws { diff --git a/Sources/XcodeGenKit/ProjectGenerator.swift b/Sources/XcodeGenKit/ProjectGenerator.swift index 8a684047..c78bf8f9 100644 --- a/Sources/XcodeGenKit/ProjectGenerator.swift +++ b/Sources/XcodeGenKit/ProjectGenerator.swift @@ -66,6 +66,8 @@ public class ProjectGenerator { let buildAction = XCScheme.BuildAction( buildActionEntries: buildActionEntries, + preActions: scheme.build.preActions.map(XCScheme.ExecutionAction.init), + postActions: scheme.build.postActions.map(XCScheme.ExecutionAction.init), parallelizeBuild: true, buildImplicitDependencies: true ) @@ -82,6 +84,8 @@ public class ProjectGenerator { buildConfiguration: scheme.test?.config ?? defaultDebugConfig.name, macroExpansion: buildableReference, testables: testables, + preActions: scheme.test?.preActions.map(XCScheme.ExecutionAction.init) ?? [], + postActions: scheme.test?.postActions.map(XCScheme.ExecutionAction.init) ?? [], shouldUseLaunchSchemeArgsEnv: scheme.test?.commandLineArguments.isEmpty ?? true, codeCoverageEnabled: scheme.test?.gatherCoverageData ?? false, commandlineArguments: testCommandLineArgs @@ -90,12 +94,16 @@ public class ProjectGenerator { let launchAction = XCScheme.LaunchAction( buildableProductRunnable: productRunable, buildConfiguration: scheme.run?.config ?? defaultDebugConfig.name, + preActions: scheme.run?.preActions.map(XCScheme.ExecutionAction.init) ?? [], + postActions: scheme.run?.postActions.map(XCScheme.ExecutionAction.init) ?? [], commandlineArguments: launchCommandLineArgs ) let profileAction = XCScheme.ProfileAction( buildableProductRunnable: productRunable, buildConfiguration: scheme.profile?.config ?? defaultReleaseConfig.name, + preActions: scheme.profile?.preActions.map(XCScheme.ExecutionAction.init) ?? [], + postActions: scheme.profile?.postActions.map(XCScheme.ExecutionAction.init) ?? [], shouldUseLaunchSchemeArgsEnv: scheme.profile?.commandLineArguments.isEmpty ?? true, commandlineArguments: profileCommandLineArgs ) @@ -104,7 +112,9 @@ public class ProjectGenerator { let archiveAction = XCScheme.ArchiveAction( buildConfiguration: scheme.archive?.config ?? defaultReleaseConfig.name, - revealArchiveInOrganizer: true + revealArchiveInOrganizer: true, + preActions: scheme.archive?.preActions.map(XCScheme.ExecutionAction.init) ?? [], + postActions: scheme.archive?.postActions.map(XCScheme.ExecutionAction.init) ?? [] ) return XCScheme(