spotify / XCRemoteCache

Other
830 stars 53 forks source link

No build cache for CocoaPods dependencies and low cache hit rate #48

Closed imWildCat closed 2 years ago

imWildCat commented 2 years ago

Hello, I'm trying to build a minimal demo project for this issue: https://github.com/imWildCat/XCRemoteCacheSampleProject.

These two issues look similar, so I post them together:

  1. No cache for CocoaPods dependencies. In the demo project mentioned above, it only has one single zip cache for the main target:

    ➜  3b2554c3cf01d206230a060c398b3ead tree .
    .
    ├── 3b2554c3cf01d206230a060c398b3ead.json
    ├── XCRemoteCacheSampleProject
    ├── XCRemoteCacheSampleProject.app.dSYM
    │   └── Contents
    │       ├── Info.plist
    │       └── Resources
    │           └── DWARF
    │               └── XCRemoteCacheSampleProject
    ├── include
    │   └── x86_64
    │       └── XCRemoteCacheSampleProject
    │           └── XCRemoteCacheSampleProject-Swift.h
    └── swiftmodule
        └── x86_64
            ├── XCRemoteCacheSampleProject.swiftdoc
            ├── XCRemoteCacheSampleProject.swiftmodule
            └── XCRemoteCacheSampleProject.swiftsourceinfo
    
    9 directories, 8 files

    Is that possible to enable XCRemoteCache for CocoaPods dependencies? I tried --targets-include AppCenter,Kingfisher but it didn't seem to work.

  2. For our own project in consumer mode, only 9.2 MiB cache downloaded into the ~/Library/Caches/XCRemoteCache/ directory. However, on the HTTP cache server, the size is 334.9 MiB. How to debug this issue? I unzipped these 9.2 MiB cache files and found they are only small Swift targets. The build time in consumer mode is not recuded. I tried it on the same machine with producer and consumer modes respectively. The integration command is similar to the demo project: XCRC/xcprepare integrate --input XCRemoteCacheSampleProject.xcodeproj --final-consumer-target XCRemoteCacheSampleProject --mode consumer

imWildCat commented 2 years ago

For this project (https://github.com/Moises6669/FINAL-bullseye-XCremotecache) found on GitHub, it does not download build cache for CocoaPods dependencies either.

polac24 commented 2 years ago

Hi! You are using CocoaPods dependencies, so using a plugin seems to be a better solution. At the moment, integrating CocoaPods-based project manually (like you have in Makefile) was never tested. I uncommented your Pods snippet, added 3 targets to exclude_targets and it was working having 100% cache hit (I tested a consumer and a producer the same machine, though):

plugin 'cocoapods-xcremotecache'

xcremotecache({
  'cache_addresses' => ['http://localhost:8080/cache/sample'], 
  'primary_repo' => 'git@github.com:imWildCat/XCRemoteCacheSampleProject.git',
  'mode' => 'consumer/producer',
  'final_target' => 'XCRemoteCacheSampleProject',
  'primary_branch' => 'main',
  'exclude_targets' => ['CNIOBoringSSL', 'AppCenter', 'MicrosoftFluentUI-FluentUIResources-ios']
})

How to troubleshoot?

Check your logs: https://github.com/spotify/XCRemoteCache/blob/master/docs/FAQ.md#how-can-i-find-xcremotecache-logs

Sidenote

The CNIOBoringSSL is an interesting case: it uses an assembly file .S, which apparently is a valid input clang file, but XCRemoteCache is not aware of that. The fix to support CNIOBoringSSL should be straightforward (here).

polac24 commented 2 years ago

Update: .s support added in https://github.com/spotify/XCRemoteCache/releases/tag/v0.3.8