On Jan 17, 2006, at 10:32 AM, Steve Baxter wrote: I have a set of about 80 projects - a shared framework, 2 applications and about 77 modules. These projects all use the same prefix file.
The problem is that Xcode precompiles a prefix file for each of my projects. This is very slow, and at 40MB/project is going to cause me trouble with disk space on my laptop machine. How can I get Xcode to share precompiled headers across multiple projects?
On another note, Xcode seems to rebuild the precompiled header if I look at the settings for a project (look but don't change). Firstly surely it should be smart enough not to recompile this unless it really has to, secondly why is looking at settings for a project or target causing the project.pbxproj to get touched?
This is a really big problem as it can take over 30 minutes to rebuild the larger projects from scratch!
The two main tools you use to make this happen are shared .xcconfig files and the Preprocessor Macros Not Used In Precomiled Headers build setting.
When deciding whether to reuse an existing shared precomp or generate a new one, Xcode considers all build settings that can affect the generation of the headers. So to maximize the probability of sharing headers, you should share as many build settings as possible among your similar targets. The best way to do this is to factor out your settings into a CommonSettings.xcconfig file and set the "Based On:" setting in your targets to use this common file.
To tell which settings are differing and making Xcode create separate precomps, follow these steps:
1) Open /Developer/Applications/Utilities/FileMerge.app 2) In the Finder, Go to Folder /Library/Caches/com.Apple.Xcode.<your UID>/SharedPrecompiledHeaders 3) Find two folders with similar names (based on your prefix file) that you expected would be shared. 4) In Outline view, turn down the folders so you see the <prefixname>.gch.hash-criteria files inside those folders 5) Drag those files, one at a time, to the "Left" and "Right" wells in FileMerge's Open dialog
You'll see a comparison of what criteria caused Xcode to generate separate precompiled header files. If you can consolidate or eliminate those flags, Xcode will reuse the precompiled header.
If the flags are -D flags (preprocessor macros), you can try moving those "Preprocessor Macros" to the "Preprocessor Macros Not Used in Precompiled Headers" build setting, and they won't be considered in the hash criteria. Note that this is at your own risk: if one of your precompiled headers actually uses that flag, and it's different at build time, your results will be inaccurate.
Chris |