[SOLVED] Reusing swift package binaries across project configurations (to save disk space)?

Issue

This Content is from Stack Overflow. Question asked by Tomáš Kafka

I have an iOS project with multiple (around 10) configurations – apart from Debug and Release, there are more configurations which only differ in adding more compilation conditions (like ‘simulate free user’, ‘simulate paid user’, ‘update more often’).

Unfortunately, this causes the swift packages to be rebuilt for each configuration, and as eg. Realm’s derived data are about 3 GB, this takes up a lot of space (and build time when rebuilding a configuration I have’t needed for a while).

Is there a way to tell Xcode to reuse packages for DEBUG configuration for all other configurations containing DEBUG (eg. DEBUG FASTUPDATES)?

I think swift packages should not be getting my compilation conditions anyway, is that right?



Solution

Well… it’s hard for Xcode to detect that two build configurations, with different build settings, would result in the exact same binaries.

Having different user-defined settings values, as you have, can easily lead to different builds in any of the packages, and Xcode can’t know that unless it goes through every package and checks if the diff between the build settings results if a diff between the compiled binaries, which would be even slower than simply rebuilding the files.

Cocoapods had support for this, i.e. you could specify which build configuration from the Pods project matched the one from your project. You could try doing a similar setup, however, this would require a non-trivial amount of manual work.

The other alternative would be to extract those user-defined build settings into other forms: user defaults, settings pane, etc. But this also depends on the architecture of your project, and can also be time-consuming/risky.


This Question was asked in StackOverflow by Tomáš Kafka and Answered by Cristik It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?