I just updated my MacBook Pro to macOS Catalina 10.15, and tried to compile and run a C++ command line program, but I had a problem which didn’t exist on previous versions;
This is simply the code:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, World!\n";
return 0;
}
The code compiles and outputs the expected, but still the Xcode says:
fatal error: 'iostream' file not found
I tried changing the Build Settings/C++ Standard Library to libstdc++, but a warning says:
warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead
And the same iostream error still exists.
So, I restarted my laptop and everything seems to be fine right now, thanks for those who tried to help.
I have the same issue, the code compiles and runs fine but XCode keeps saying iostream is not found. It seems like the error appears randomly so a reboot is only a temporary solution.
In my case it won't even compile, after reading @Alan Birtles comment, I changed it to default and it works
来源:https://stackoverflow.com/questions/58364711/xcode-11-1-iostream-file-not-found