From 14b2b3acebe5554bd33166d0a9db09f45a8698dc Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Sun, 21 Nov 2021 14:17:34 +0100 Subject: [PATCH] [CocoapodsPlugin] Support first-party caching for incremental installation --- cocoapods-plugin/README.md | 4 ++ .../cocoapods-xcremotecache/command/hooks.rb | 37 +++++++++++-------- .../cocoapods-xcremotecache/gem_version.rb | 2 +- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/cocoapods-plugin/README.md b/cocoapods-plugin/README.md index 73e717d..fe5d4e9 100644 --- a/cocoapods-plugin/README.md +++ b/cocoapods-plugin/README.md @@ -60,3 +60,7 @@ To fully uninstall the plugin, call: ```bash gem uninstall cocoapods-xcremotecache ``` + +## Limitations + +* When `generate_multiple_pod_projects` mode is enabled, only first-party targets are cached by XCRemoteCache (all dependencies are compiled locally). diff --git a/cocoapods-plugin/lib/cocoapods-xcremotecache/command/hooks.rb b/cocoapods-plugin/lib/cocoapods-xcremotecache/command/hooks.rb index f6ca1fc..6ceada9 100644 --- a/cocoapods-plugin/lib/cocoapods-xcremotecache/command/hooks.rb +++ b/cocoapods-plugin/lib/cocoapods-xcremotecache/command/hooks.rb @@ -363,6 +363,28 @@ module CocoapodsXCRemoteCacheModifier File.delete(xccc_location_absolute) if File.exist?(xccc_location_absolute) # Prepare XCRC + + # Pods projects can be generated only once (if incremental_installation is abled) + # Always integrate XCRemoteCache to all Pods, in case it will be needed later + unless installer_context.pods_project.nil? + # Attach XCRemoteCache to Pods targets + installer_context.pods_project.targets.each do |target| + next if target.name.start_with?("Pods-") + next if target.name.end_with?("Tests") + next if exclude_targets.include?(target.name) + enable_xcremotecache(target, 1, xcrc_location, xccc_location, mode, exclude_build_configurations, final_target) + end + + # Create .rcinfo into `Pods` directory as that .xcodeproj reads configuration from .xcodeproj location + pods_proj_directory = installer_context.sandbox_root + + # Manual .rcinfo generation (in YAML format) + save_rcinfo({'extra_configuration_file' => "#{user_proj_directory}/.rcinfo"}, pods_proj_directory) + + installer_context.pods_project.save() + end + + # Enabled/disable XCRemoteCache for the main (user) project begin prepare_result = YAML.load`#{xcrc_location_absolute}/xcprepare --configuration #{check_build_configuration} --platform #{check_platform}` unless prepare_result['result'] || mode != 'consumer' @@ -377,21 +399,6 @@ module CocoapodsXCRemoteCacheModifier next end - # Attach XCRemoteCache to Pods targets - installer_context.pods_project.targets.each do |target| - next if target.name.start_with?("Pods-") - next if target.name.end_with?("Tests") - next if exclude_targets.include?(target.name) - enable_xcremotecache(target, 1, xcrc_location, xccc_location, mode, exclude_build_configurations, final_target) - end - - # Create .rcinfo into `Pods` directory as that .xcodeproj reads configuration from .xcodeproj location - pods_proj_directory = installer_context.sandbox_root - - # Manual .rcinfo generation (in YAML format) - save_rcinfo({'extra_configuration_file' => "#{user_proj_directory}/.rcinfo"}, pods_proj_directory) - - installer_context.pods_project.save() # Attach XCRC to the app targets user_project.targets.each do |target| diff --git a/cocoapods-plugin/lib/cocoapods-xcremotecache/gem_version.rb b/cocoapods-plugin/lib/cocoapods-xcremotecache/gem_version.rb index 7002858..c9c5ef3 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.2" + VERSION = "0.0.3" end