amfcosta
amfcosta

Reputation: 1061

Using ccache with Xcode 4

Is there any way to use ccache with Xcode 4, to improve C++ build time?

Using environment variables I've set CC and CXX to ccache, but the build fails since ccache does not recognise some of the parameters that Xcode 4 outputs.

Upvotes: 6

Views: 2500

Answers (2)

Joel Rosdahl
Joel Rosdahl

Reputation: 904

Ccache has Clang support from version 3.2 and newer.

See here for a possible solution on how to use ccache in Xcode: https://pspdfkit.com/blog/2015/ccache-for-fun-and-profit/

Upvotes: 3

Craig Scott
Craig Scott

Reputation: 10167

This answer shows a technique where ccache can be used with Xcode by setting the CC and CXX user-defined variables in the Xcode project. That particular answer was using CMake to create the Xcode project files, but the same principle applies to manually created Xcode projects. The CC and CXX variables act like overrides to the compiler used, so diverting them to a wrapper script which invokes ccache with the compiler you want achieves the desired functionality. Note that I've only tested it with Xcode 7, but I'd expect earlier versions probably work too. This article by Peter Steinberger also covers essentially the functionality you want without using CMake, but it uses the same technique of setting CC and CXX Xcode project variables.

Upvotes: 0

Related Questions