Use the Bitrise Cache system to cache Xcode derived data and use it in the next build

Hi,
in order to speed up the build time, I would like to use the cache to store derived data.
I managed to set everything up.

  1. set a specific folder to use as derived data folder
  2. build
  3. push out derived data folder (using push cache step)

then the second time

  1. pull the cache
  2. set the same specific folder as derived data
  3. build

the problem is that the second time, the process is not faster since xcodebuild rebuild again (almost) everything.

But it seems that everything should work, and actually some of the steps the second time are skipped (because it’s using the information included in the derived data).

I tested the same configuration on my local machine and the second time nothing get builds (as expected) and the build is much faster.

Is that because every time we use a different virtual machine?

Thanks,

Francesco

Can you please copy paste the Xcode step and your cache push step from Bitrise.yml? That way we can check all the configs you set for these steps.

I am using fastlane

scan(
workspace: “MyWorkspace.xcworkspace”,
scheme: “MyScheme”,
clean: false,
skip_build: true,
build_for_testing: true,
derived_data_path: “./local_derived_data/iphone7”,
devices: [“iPhone 7”],
buildlog_path: “fastlane/test_output/log/build_iphone7”
)
scan(
workspace: “MyWorkspace.xcworkspace”,
scheme: “MyScheme”,
clean: false,
skip_build: true,
test_without_building: true,
derived_data_path: “./local_derived_data/iphone7”,
devices: [“iPhone 7”],
buildlog_path: “fastlane/test_output/log/test_iphone7”,
output_directory: “fastlane/test_output/iphone7”,
)

this is the push step configuration:

  • cache-push:
    is_always_run: true
    inputs:
    - cache_paths: “./local_derived_data”
    - ignore_check_on_paths: ‘’

Did you test with the same git commit? (So that no file changed between the builds)

yes, same commit, from the build log, the only different I see from a “fresh build” and, one with the previous derived data is:

  • Write auxiliary files step is skipped

the point is, if I run fastlane twice on my local machine the files are not compiled a second time

1 Like

We’ll soon work on caching, will check this too and reply here once we found the right config/balance for DerivedData (which changes in every build).

ok thanks. looking forward to it

1 Like

Hello,

Is there any update on this?

You can configure it manually (the whole cache can be configured manually) if you want to, but no automatic caching for DerivedData yet (mainly because it can cause tons of issues if there are files from a previous, completely unrelated build -
e.g. if the previous cache contained files from a different Xcode/Swift version).

@tamaspapik any update on this?

Hey guys!
Do you have any update on this issue? Building seems to be faster with caching derived data folder (https://medium.com/@bitrise/60-faster-builds-force-xcode-to-use-caching-on-bitrise-af8979ca39a6), but I see the same result as mentioned before.

Thanks

Hey!

No update on this AFAIK. Keeping xcode cache files while it has to work in a continuously changing environment(new vm instance per build started) still causes unlimited edge-cases.

Hey!

Any news on this?

We’ve been trying to make it work, but without any success for now. The issue is 3 years old so maybe Xcode’s build system has changed for the better in the meantime.

Thanks!