Custom Clang and Xcode

I’m using a (slightly) modified version of Clang to be used within Xcode. I integrate it using the “CC” flag in Xcode. All my modifications are turned off by default, but may be switched on by a set of custom flags.

If I don’t set any of these, everything is fine. However, if I enable one of my custom warnings, these warnings show up when building the project/target, but Xcode’s autocompletion stops working. Could it be that Xcode is confused because it works with different versions of Clang?

Not all of my custom flags break the autocomplete function. E.g., I have this option in

def export_stats : Flag<["-"], “export-stats”>,

Setting it doesn’t break anything, but the following does:


def Wunsafe_api_usage : Flag<["-"], “Wunsafe-api-usage”>,


def warn_unsafe_api_usage : Warning<
InGroup<DiagGroup<“unsafe-api-usage”>>, DefaultIgnore;

Did I get something wrong, or do I just have to live with it because Xcode is not prepared for this type of modification?


I’ll start off by saying of course this is not supported. :wink:

I have two guesses, though:

  • Warnings are automatically added to the -W group; you should not put a new flag into for a new warning.
  • Warnings are probably also used when uniquing PCHs, so it’s possible (but not likely) that Xcode is trying to use an incompatible PCH during indexing. I doubt this is it, but if it is, turning off PCH support in the build settings might make completion come back.


Hi Sebastian,

You will need to replace both clang and libclang.dylib in the XcodeDefault toolchain. Overriding CC simply isn’t going to work.


Took me a while to get the libclang build right and test it, but thanks, this indeed works.

I also followed Jordan’s guesses, but they didn’t solve the problem. I’ve removed the entries for warnings anyway.

Thanks a lot for your help!