diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index c7b0d40c..a1a596f0 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -698,6 +698,26 @@ public class PBXProjGenerator { buildPhases += copyFilesBuildPhasesFiles .filter { $0.key.phaseOrder == .postCompile } .map { generateCopyFiles(targetName: target.name, copyFiles: $0, buildPhaseFiles: $1) } + + if !carthageFrameworksToEmbed.isEmpty { + let inputPaths = carthageFrameworksToEmbed + .map { "$(SRCROOT)/\(carthageBuildPath)/\(target.platform)/\($0)\($0.contains(".") ? "" : ".framework")" } + let outputPaths = carthageFrameworksToEmbed + .map { "$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/\($0)\($0.contains(".") ? "" : ".framework")" } + let carthageExecutable = project.options.carthageExecutablePath ?? "carthage" + let carthageScript = createObject( + id: "Carthage" + target.name, + PBXShellScriptBuildPhase( + files: [], + name: "Carthage", + inputPaths: inputPaths, + outputPaths: outputPaths, + shellPath: "/bin/sh", + shellScript: "\(carthageExecutable) copy-frameworks\n" + ) + ) + buildPhases.append(carthageScript.reference) + } if !targetFrameworkBuildFiles.isEmpty { @@ -754,27 +774,6 @@ public class PBXProjGenerator { buildPhases.append(copyFilesPhase.reference) } - if !carthageFrameworksToEmbed.isEmpty { - - let inputPaths = carthageFrameworksToEmbed - .map { "$(SRCROOT)/\(carthageBuildPath)/\(target.platform)/\($0)\($0.contains(".") ? "" : ".framework")" } - let outputPaths = carthageFrameworksToEmbed - .map { "$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/\($0)\($0.contains(".") ? "" : ".framework")" } - let carthageExecutable = project.options.carthageExecutablePath ?? "carthage" - let carthageScript = createObject( - id: "Carthage" + target.name, - PBXShellScriptBuildPhase( - files: [], - name: "Carthage", - inputPaths: inputPaths, - outputPaths: outputPaths, - shellPath: "/bin/sh", - shellScript: "\(carthageExecutable) copy-frameworks\n" - ) - ) - buildPhases.append(carthageScript.reference) - } - let buildRules = target.buildRules.map { buildRule in createObject( id: "\(target.name)-\(buildRule.action)-\(buildRule.fileType)", diff --git a/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj b/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj index 7804b3e4..714481c8 100644 --- a/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj +++ b/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj @@ -880,9 +880,9 @@ buildPhases = ( SBP_32467107793 /* Sources */, RBP_32467107793 /* Resources */, + SSBP_5954948530 /* Carthage */, FBP_32467107793 /* Frameworks */, CFBP_4684049960 /* Embed App Extensions */, - SSBP_5954948530 /* Carthage */, ); buildRules = ( ); @@ -1095,10 +1095,10 @@ SBP_82523211050 /* Sources */, RBP_82523211050 /* Resources */, CFBP_7191905390 /* CopyFiles */, + SSBP_8106229290 /* Carthage */, FBP_82523211050 /* Frameworks */, CFBP_6493932244 /* Embed Frameworks */, CFBP_2836118931 /* Embed Watch Content */, - SSBP_8106229290 /* Carthage */, SSBP_5106020372 /* Strip Unused Architectures from Frameworks */, SSBP_8706434794 /* MyScript */, );