Force `xcodebuild archive` to use cache?

I already asked this question on StackOverflow (https://stackoverflow.com/questions/46211606/xcodebuild-archive-always-performs-a-clean-build)but figured that here would be a more appropriate place for xcodebuild related questions, especially since it has Apple Eng's visibility.


Every time I run

xcodebuild ...params... archive
it performs a clean build without reusing the cache from a previous build.


While I understand the motivation behind it, it has serious consequences on my CI build times because I generate an IPA for every push. Since my workspace has a

Pods
project (unlikely to change between commits) and an
App
project (changing all the time) I'm looking for a way to cache the
Pods
compilation phase somehow – which
xcodebuild archive
doesn't seem to allow.


Is there a way to force using the cache when archiving? Is there any other way to cache the archived version of

Pods
?

Replies

I don't think there is an option to disable this behavior. You can submit a bug report to request such an option, if you think your use-case is plausible.


One possible alternative would be to archive your projects individually, rather than from the workspace. Your app project would have to link against the Pods archive product, which you would have previously extracted to a permanent location.

Great suggestion. Filed a feature request on Bug Reporter, case 34485177. Still open to suggestions about undocumented flags / env vars that I wouldn't know about.

I too feel this is a really useful feature.


Ever since Apple decided to change how .IPA files are created for iOS (the need to create via an xarchive rather than the previous system which could convert from an .app file) means that, even if we wish to quickly create an IPA for team use, we have to wait an age for this to happen.


I appricate that, by default, you'd want to perform a full clean to remove any potential issues but our turnaround has gone for a couple of minutes to around 20mins each time the team want to quickly try something on an iOS device.

This one is not an Apple-provided solution, but I wrote a tool that implements Xcode archive builds caching. It's alpha and still in active development, but it works pretty good for our project. Sources are here - https://github.com/sweatco/xcode-archive-cache, and I wrote an article about tool's internals - https://dev.sweatco.in/speeding-up-xcode-archive-builds/. Hope it helps.