diff --git a/Docs/ProjectSpec.md b/Docs/ProjectSpec.md index 4042dfb5..ebb3a3f2 100644 --- a/Docs/ProjectSpec.md +++ b/Docs/ProjectSpec.md @@ -373,7 +373,7 @@ targets: ### Build Script -Run script build phases added via **prebuildScripts** or **postBuildScripts**. They run before or after any other build phases respectively and in the order defined. Each script can contain: +Run script build phases added via **prebuildScripts**, **postCompileScripts**, or **postBuildScripts**. They run before any other build phases, after the Compile Sources build phase, or after any other build phases respectively and in the order defined. Each script can contain: - [x] **path**: **String** - a relative or absolute path to a shell script - [x] **script**: **String** - an inline shell script @@ -400,12 +400,15 @@ targets: outputFiles: - $(DERIVED_FILE_DIR)/file1 - $(DERIVED_FILE_DIR)/file2 - postbuildScripts: + postCompileScripts: - script: swiftlint name: Swiftlint - script: | command do othercommand + postbuildScripts: + - path: myscripts/my_final_script.sh + name: My Final Script ``` ### Build Rule diff --git a/Sources/ProjectSpec/Target.swift b/Sources/ProjectSpec/Target.swift index a38e5b13..c1a3330c 100644 --- a/Sources/ProjectSpec/Target.swift +++ b/Sources/ProjectSpec/Target.swift @@ -32,6 +32,7 @@ public struct Target: ProjectTarget { public var directlyEmbedCarthageDependencies: Bool? public var requiresObjCLinking: Bool? public var prebuildScripts: [BuildScript] + public var postCompileScripts: [BuildScript] public var postbuildScripts: [BuildScript] public var buildRules: [BuildRule] public var configFiles: [String: String] @@ -66,6 +67,7 @@ public struct Target: ProjectTarget { directlyEmbedCarthageDependencies: Bool? = nil, requiresObjCLinking: Bool? = nil, prebuildScripts: [BuildScript] = [], + postCompileScripts: [BuildScript] = [], postbuildScripts: [BuildScript] = [], buildRules: [BuildRule] = [], scheme: TargetScheme? = nil, @@ -84,6 +86,7 @@ public struct Target: ProjectTarget { self.directlyEmbedCarthageDependencies = directlyEmbedCarthageDependencies self.requiresObjCLinking = requiresObjCLinking self.prebuildScripts = prebuildScripts + self.postCompileScripts = postCompileScripts self.postbuildScripts = postbuildScripts self.buildRules = buildRules self.scheme = scheme @@ -209,6 +212,7 @@ extension Target: Equatable { lhs.sources == rhs.sources && lhs.dependencies == rhs.dependencies && lhs.prebuildScripts == rhs.prebuildScripts && + lhs.postCompileScripts == rhs.postCompileScripts && lhs.postbuildScripts == rhs.postbuildScripts && lhs.buildRules == rhs.buildRules && lhs.scheme == rhs.scheme && @@ -280,6 +284,7 @@ extension Target: NamedJSONDictionaryConvertible { requiresObjCLinking = jsonDictionary.json(atKeyPath: "requiresObjCLinking") prebuildScripts = jsonDictionary.json(atKeyPath: "prebuildScripts") ?? [] + postCompileScripts = jsonDictionary.json(atKeyPath: "postCompileScripts") ?? [] postbuildScripts = jsonDictionary.json(atKeyPath: "postbuildScripts") ?? [] buildRules = jsonDictionary.json(atKeyPath: "buildRules") ?? [] scheme = jsonDictionary.json(atKeyPath: "scheme") diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index de814fd0..380e8580 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -646,6 +646,8 @@ public class PBXProjGenerator { let sourcesBuildPhaseFiles = getBuildFilesForPhase(.sources) let sourcesBuildPhase = createObject(id: target.name, PBXSourcesBuildPhase(files: sourcesBuildPhaseFiles)) buildPhases.append(sourcesBuildPhase.reference) + + buildPhases += try target.postCompileScripts.map { try generateBuildScript(targetName: target.name, buildScript: $0) } let resourcesBuildPhaseFiles = getBuildFilesForPhase(.resources) + copyResourcesReferences if !resourcesBuildPhaseFiles.isEmpty {