From 86c762b0704d6329fd51b7eb401fabe08179ab98 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Mon, 6 Jun 2022 17:49:44 -0400 Subject: [PATCH 1/2] Add postbuild right after compilation for integrate --- .../Commands/Prepare/Integrate/XcodeProjIntegrate.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/XCRemoteCache/Commands/Prepare/Integrate/XcodeProjIntegrate.swift b/Sources/XCRemoteCache/Commands/Prepare/Integrate/XcodeProjIntegrate.swift index 95360ac5..9713d1ff 100644 --- a/Sources/XCRemoteCache/Commands/Prepare/Integrate/XcodeProjIntegrate.swift +++ b/Sources/XCRemoteCache/Commands/Prepare/Integrate/XcodeProjIntegrate.swift @@ -230,10 +230,12 @@ struct XcodeProjIntegrate: Integrate { 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) + // add postbuild right after compilation as custom build steps may depend on files generated by + // the xcpostbuild (e.g. to copy -Swift.h.md5) + pbxproj.add(object: postbuildPhase) + target.buildPhases.insert(postbuildPhase, at: sourceIndex + 1) pbxproj.add(object: prebuildPhase) target.buildPhases.insert(prebuildPhase, at: sourceIndex) - pbxproj.add(object: postbuildPhase) - target.buildPhases.append(postbuildPhase) } } From a3cd6bea07416ab80c851a43bf6be5a262457f00 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Mon, 6 Jun 2022 17:53:11 -0400 Subject: [PATCH 2/2] Add postbuild right after compilation for CocoaPods --- .../lib/cocoapods-xcremotecache/command/hooks.rb | 5 +++++ cocoapods-plugin/lib/cocoapods-xcremotecache/gem_version.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cocoapods-plugin/lib/cocoapods-xcremotecache/command/hooks.rb b/cocoapods-plugin/lib/cocoapods-xcremotecache/command/hooks.rb index f155579d..34f5fb0b 100644 --- a/cocoapods-plugin/lib/cocoapods-xcremotecache/command/hooks.rb +++ b/cocoapods-plugin/lib/cocoapods-xcremotecache/command/hooks.rb @@ -181,6 +181,11 @@ def self.enable_xcremotecache(target, repo_distance, xc_location, xc_cc_path, mo "$(TARGET_BUILD_DIR)/$(MODULES_FOLDER_PATH)/$(PRODUCT_MODULE_NAME).swiftmodule/$(XCRC_PLATFORM_PREFERRED_ARCH)-$(LLVM_TARGET_TRIPLE_VENDOR)-$(SWIFT_PLATFORM_TARGET_PREFIX)$(LLVM_TARGET_TRIPLE_SUFFIX).swiftmodule.md5" ] postbuild_script.dependency_file = "$(TARGET_TEMP_DIR)/postbuild.d" + # Move postbuild (last element) to the position after compile sources phase (to make it real 'postbuild') + if !existing_postbuild_script + compile_phase_index = target.build_phases.index(target.source_build_phase) + target.build_phases.insert(compile_phase_index + 1, target.build_phases.delete(postbuild_script)) + end # Mark a sha as ready for a given platform and configuration when building the final_target if (mode == 'producer' || mode == 'producer-fast') && target.name == final_target diff --git a/cocoapods-plugin/lib/cocoapods-xcremotecache/gem_version.rb b/cocoapods-plugin/lib/cocoapods-xcremotecache/gem_version.rb index bcfe6fe8..d1a041b9 100644 --- a/cocoapods-plugin/lib/cocoapods-xcremotecache/gem_version.rb +++ b/cocoapods-plugin/lib/cocoapods-xcremotecache/gem_version.rb @@ -13,5 +13,5 @@ # limitations under the License. module CocoapodsXcremotecache - VERSION = "0.0.12" + VERSION = "0.0.13" end