/usr/include missing on macOS Catalina (with Xcode 11)

catalinadevelopmentxcode

Follow up to the same problem on Mojave.

After upgrading to macOS Catalina, none of the C headers can be found in /usr/include. The reason for this may be found in the Xcode 10 release notes (previous version):

The Command Line Tools package installs the macOS system headers inside the macOS SDK. Software that compiles with the installed tools will search for headers within the macOS SDK provided by either Xcode at:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk

or the Command Line Tools at:

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

[…]
As a workaround, an extra package is provided which will install the headers to the base system. In a future release, this package will no longer be provided. […]

(See the link to the question above for details on this suggested workaround.)

Apparently Apple made good on their threat with Xcode 11. How can one install the C headers to /usr/include on macOS Catalina using Xcode 11?

Context: The clang python binding search the header files in /usr/include per default. According to kkurian's answer and the comment I made (in response to this question), there are multiple ways to control this behaviour, if necessary.

Related question: Can't compile C program on a Mac after upgrade to Mojave.

Best Answer

Set the CPATH environment variable in your shell (e.g., put this in your .zshrc assuming you're using zsh):

export CPATH=`xcrun --show-sdk-path`/usr/include

And then try to build your project again.

UPDATE

The OP related to how to install the headers in /usr/include, not how to point clang to the headers wherever they may be.

MacOS System Integrity Protection prevents the creation of /usr/include, even by root. See this related answer.

If you disabled SIP (not recommended) then I imagine something like

sudo ln -s `xcrun --show-sdk-path`/usr/include /usr/include

will do the trick.