C++ compatibility on iOS < 5

Today after many months doing ObjC only on iOS I wanted to revive an old project of mine written in ObjC++. To my surprise it didn’t compile anymore. I got the following error:

clang: error: invalid deployment target for -stdlib=libc++ (requires iOS 5.0 or later)

Apple had introduced libc++ with newer Xcode versions which is the C++11 standard library. That’s of course nice and great, but unfortunately it’s only available for iOS5 and higher. (see https://developer.apple.com/library/mac/#releasenotes/DeveloperTools/RN-Xcode/_index.html).

To make my project build again I had to switch to the old GNU C++ standard library. How to do that? Go to your project’s Build Settings, in the search field type libc. Then switch from libc++ to libstdc++ and your project should work again.

Share this: