How to setup precompiled headers in Xcode for C++?

Does this setup seem correct to get precompiled headers? When I look at the file compile times they're way too long, like it's not using the pch.

App.pch file, I set #include "MyConfig.h"

Then in Build Settings: GCC_PREFIX_HEADER = pathto/App.pch GCC_PRECOMPILE_PREFIX_HEADER = YES

Force include of a header. This avoids needing to include the header first in every file.
-include MyConfig.h

or should it be? -include App.pch

I don't see anything in the build output that indicates that the pch was compiled and used. And the build timings aren't any faster. -ftime-trace shows the same header file being parsed as used again and again, adding up to a large overall time.

Also how do CPP_PREFIX_HEADER and GCC_PREFIX_HEADER differ? This is a C++ project, so I tried setting both. But I don't see any output lines with my App.pch file. I even renamed it to AppPrefix.pch, and still don't see that text in the output.

Even putting garbage into the .pch file still succeeds on the build. This is latest Xcode on an M1. Is Xcode just ignoring these directives?

So I renamed the file to AppPrefix.h, designated that as the both GCC_/CPP_PREFIX_HEADER. Removed all explicit includes of AppPrefix.h in the sources. And that file is getting prepended onto every compile. It's just not being precompiled. I can see the same files parsed over and over. Is it that stl type template headers must be re-parsed regardless of the pch setting?

Seems like on arm64 builds all Xcode does is prepend the file to each file, and doesn't bother to do the precompile. Does clang not support pch. I even renamed the file to AppPrefix.pch which still works, but with no precompile.

Okay, I tracked this down. The project setting for "Precompile prefix header" was being overridden with "No" by both targets. Now the build takes 11s to parse instead of 78s. So precompiled headers are still a huge win.

How to setup precompiled headers in Xcode for C++?
 
 
Q