Missing headers after an OSX Update? Try this!

I recently opened my Macbook to start working on a few personal projects, and suddenly I noticed that all of my projects were failing to compile. I was pretty surprised – I’m not one to leave my master branch in a broken state!

I finally paid attention to the problem the compiler was complaining about: all of the system headers were missing! Sure enough, I went searching the filesystem and found that the compiler wasn’t crazy and that the files had been removed. After some investigation, I discovered that my Macbook had auto-updated OSX and Xcode the previous night. Aha!

If you ever end up in a situation where you suddenly discover that your system headers are missing, try reinstalling the Xcode command line tools:

xcode-select --install

Now, this method stopped working for me at some point in 2019. It seems that OS X is migrating away from providing a /usr/include at all, instead expecting you to specify the XCode SDK for compilation. Luckily, XCode still ships with an installer that will populate /usr/include with the proper headers. You need to run:

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

At some point this package will be deprecated, so get to work on updating your OS X projects.

Share Your Thoughts

This site uses Akismet to reduce spam. Learn how your comment data is processed.