I'm on macOS Sonoma 14.5 and I updated Xcode to version 14.4; the steps that worked for me are:
Open Finder.
Goto the below directory
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/
; You can also clickcommand+shift+G
, copy-paste the above directory, press return and this should take you to the directory.Create a new folder in the directory. Rename it with bits.
Now, open Xcode, click on File in the above menubar, select
>new >file
, click on macOS, select header file and create one named stdc++ and place it in your desired folder.Click here; this includes all the necessary header files, copy-paste all the contents to the stdc++ header file and save it.
Now, copy the header file and goto the directory in step 2, open bits folder and paste the header file there.
Exit any running IDE (i.e. VS Code).
That's it! You're all set. Now, open your desired IDE and Voilà! You can now include bits/stdc++.h in your c++ file. Hope this helped. :-)
Wow it works thanks bro
It is really helpful thx! I was able to include bits/stdc++ before but after a system update or something it did not work anymore. Took me quite long but could not fix it now it works again
Another alternate is to install
gcc
compiler. Now you can either useg++-14
to compile your code or simply create a symlink by running the commands:/opt/homebrew/bin
ln -s g++-14 g++
This will also allow you to use policy based data structure (if you aren't able to)
Can someone please link to blog to installing gcc on Xcode? Thanks!!
Alternative solution: Don't use Mac
Why?
Mac laptops are often faster, have longer battery life, better build quality, better speakers, better design, and better customer service than any other type of laptop.
I think you can make an argument though if you're talking about only operating system.
I'm just kidding. But in all seriousness you can get a better laptop with the same price. This is true about every apple product.
Now i do agree with the customer service, but other than that, there is nothing else.
Note that these are just my opinions, and i don't really mean to hate on anyone.