Xcode 11.1: iostream’ file not found

I’m compiling from the command line, and none of the answers listed here (or elsewhere) worked for me.

What does seem to work (so far) is to add the following to .profile or whatever script your terminal uses to start up: (zsh, csh, bash, etc.)

export C_INCLUDE_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include
export CPLUS_INCLUDE_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include

You will probably have to change MacOSX10.15.sdk whenever you upgrade your operating system.

C_INCLUDE_PATH and CPLUS_INCLUDE_PATH are options for the clang toolchain rather than MacOS environment, so hopefully this solution will work long-term, unlike xcode-select --install (which won’t fix the include directories on an upgrade) or ln -s ... /usr/include (which is now forbidden by System Integrity Protection).

Leave a Comment