Xcode precompiled header problem

Hi,

We are using Precompiled Headers in all our projects. (Project files are generated with Premake and support Windows, Linux, Emscripten (web), and MacOS.)

I am having a problem with one project in particular which contains a mix of C and C++ files. We explicitly disable precompiled headers for C files because past experience has proven it's impossible to use C++ precompiled headers in C sources, and vice versa.

At least that's the theory. In Xcode it doesn't seem possible to enable/disable precompiled headers on a per file basis. (At least that's my conclusion so far.)

Is this actually true? Is it not possible to configure individual build settings for single source files? Specifically, is it not possible to use precompiled headers for C++ files and not for C files within a single project?

Cheers, James

A quick glance at the clang documentation on precompiled headers (https://clang.llvm.org/docs/PCHInternals.html) suggests that a precompiled file for C++ should be automatically ignored for C compilations, but…

You can specify build settings on a per-source file basis by going to the Build Phases tab of your project and expanding the Compile Sources phase. Select the source files you care about, then double-click (one of the selected rows) under the Compiler Flags column header. The, enter the compiler options you want for those files.

Please note that Xcode build settings don't specify inclusion of a PCH directly. Instead, you specify a "prefix file", which you can choose to precompile. You might to use a combination of "prefix" and "precompiled" settings to get the selectivity you want.

Xcode precompiled header problem
 
 
Q