# Xcode build time improvement ideas

**URL:** <https://discuss.bitrise.io/t/xcode-build-time-improvement-ideas/2494>\
**Category:** Question & Answer\
**Tags:** xcode\
**Created:** [August 16, 2017, 9:06am UTC](https://discuss.bitrise.io/t/xcode-build-time-improvement-ideas/2494 "2017-08-16T09:06:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tamaspapik](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/tamaspapik/32/251_2.png) [@tamaspapik](https://discuss.bitrise.io/u/tamaspapik)\
**Post date:** [August 16, 2017, 9:06am UTC](https://discuss.bitrise.io/t/xcode-build-time-improvement-ideas/2494/1 "2017-08-16T09:06:29Z")

</div>

Hey all!

We’ve received couple of reports of building an xcode project takes too long. This obviously happens because you have a 100% clean environment in each build started, however there are multiple cache approaches you can try.

### Caching dependencies

Caching dependencies is an elemental way to save some time **in case** if bintray or any dependency host has service outages.

- [How to cache CocoaPods dependencies](http://discuss.bitrise.io/t/how-to-cache-cocoapods-dependencies/193)
- [How to cache Carthage dependencies](http://discuss.bitrise.io/t/how-to-cache-carthage-dependencies/197)
- [How to cache Xamarin dependencies](http://discuss.bitrise.io/t/how-to-cache-xamarin-dependencies/246)

### Caching build sources

This is where we need to join our power! 🚀 In some case caching DerivedData and/or temp folders are gives you the expected build time boost, but it won’t help most of the times.

To cache DerivedData the simplest way is to set `-derivedDataPath ~/dData` flag in the xcode steps additional flags inputs, then cache ~/dData folder.

For now this thread is open for collecting feedbacks if you have a long build time, and what did you tried already to speed it up and please attach a filtered build log or xcode part of the build log if you can.

Let’s see if someone have a good idea to try! 😉

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [August 16, 2017, 9:27am UTC](https://discuss.bitrise.io/t/xcode-build-time-improvement-ideas/2494/2 "2017-08-16T09:27:48Z")

</div>

A tip for Swift projects: enable **Whole Module Optimization** , that can improve the build time drastically. See:

> [@iOS Builds slow, any solution to speed it up?](http://discuss.bitrise.io/t/ios-builds-slow-any-solution-to-speed-it-up/61/30):
>
> Please consider adding the user-defined setting SWIFT\_WHOLE\_MODULE\_OPTIMIZATION=YES flag in XCode, this will speed up compilation time drastically. Don’t let the optimisation level fool you, because that one should stay on “None”, and not be changed to “-whole-module-optimization”. See this Hacker News thread [https://news.ycombinator.com/item?id=13214431](https://news.ycombinator.com/item?id=13214431), with Uber ([https://www.skilled.io/u/swiftsummit/swift-with-a-hundred-engineers](https://www.skilled.io/u/swiftsummit/swift-with-a-hundred-engineers)) and Zalando ([https://tech.zalando.com/blog/improving-swift-c…](https://tech.zalando.com/blog/improving-swift-compilation-times-from-12-to-2-minutes/)

---

<div class="post-metadata">

**Author:** ![tamaspapik](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/tamaspapik/32/251_2.png) [@tamaspapik](https://discuss.bitrise.io/u/tamaspapik)\
**Post date:** [October 9, 2017, 8:44am UTC](https://discuss.bitrise.io/t/xcode-build-time-improvement-ideas/2494/3 "2017-10-09T08:44:17Z")

</div>

> [@tamaspapik](#):
>
> To cache DerivedData the simplest way is to set -derivedDataPath ~/dData flag in the xcode steps additional flags inputs, then cache ~/dData folder.

If you use the above in pair with the new [Recursive Touch for Cache](https://github.com/bitrise-steplib/steps-recursive-touch) step then xcode cache will 100% work with any non-archive step! Just put Recursive Touch step right before your xcode-test or xcodebuild command.

Let’s try it 😉
