spotify / XCRemoteCache

Other
833 stars 52 forks source link

[CocoaPodsPlugin] Support first-party caching for incremental install #19

Closed polac24 closed 2 years ago

polac24 commented 2 years ago

When Podfile has enabled incremental_installation, e.g.

install! 'cocoapods',
         :generate_multiple_pod_projects => true
         :incremental_installation => true

CocoaPods plugin was failing as pods_project is nil (see here). To fix that, this PR optimistically integrates XCRemoteCache to all targets in the Pods project (adding pre/postbuild scripts,CC, SWIFT_EXEC etc) on a first Pods project generation as the plugin will not have a chance to integrate/deintegrate it in consecutive invocations (cocoapods intentionally leaves Pods project intact to not generate it without need). There will be just a tiny performance penalty if no artifacts are ready and XCRemoteCache is disabled - xcprebuild will quit early when a global .rc/arc.rc doesn't exist and fallback to the local compilation.

By the way, I revealed that generate_multiple_pod_projects mode is not fully supported (for now). Such setup changes a way the Pods project is configured and each pod has a separate .xcodeproj. To support it, manually modifying each .xcodeproj to integrate XCRemoteCache (build steps build settings etc.), would be required, but so far CocoaPods Plugins interface does not provide a nice API for that (link).

Standard

Screenshot 2021-11-21 at 19 18 52

generate_multiple_pod_projects

Screenshot 2021-11-21 at 19 17 39

Fixes #18