diff --git a/Sources/XCRemoteCache/Commands/Prepare/Integrate/XcodeProjIntegrate.swift b/Sources/XCRemoteCache/Commands/Prepare/Integrate/XcodeProjIntegrate.swift index 7e7c27b3..95360ac5 100644 --- a/Sources/XCRemoteCache/Commands/Prepare/Integrate/XcodeProjIntegrate.swift +++ b/Sources/XCRemoteCache/Commands/Prepare/Integrate/XcodeProjIntegrate.swift @@ -227,11 +227,11 @@ struct XcodeProjIntegrate: Integrate { let previousRCPhases = target.buildPhases.filter(isRCPhase) target.buildPhases.removeAll(where: previousRCPhases.contains) - if target.buildPhases.map(\.buildPhase).contains(.sources) { + if let sourceIndex = target.buildPhases.map(\.buildPhase).firstIndex(of: .sources) { // add (pre|post)build phases only when a target has some compilation steps // otherwise they make no sense (nothing to store in an artifact) pbxproj.add(object: prebuildPhase) - target.buildPhases.insert(prebuildPhase, at: 0) + target.buildPhases.insert(prebuildPhase, at: sourceIndex) pbxproj.add(object: postbuildPhase) target.buildPhases.append(postbuildPhase) }