Search code examples
c++iosxcodeobjective-c++

c++ header file not found when compiling ios project in xcode


When I built an iOS project, I got an error "'tuple' file not found". Seems xcode is not trying to look for c++ header files.

The error message is: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.0.sdk/usr/include/simd/vector_make.h:5310:10: 'tuple' file not found

In vector_make.h, tuple is included:

#include <tuple>

This is originated from AVFoundation.h included by a c++ file "tdav_apple.mm":

#if TDAV_UNDER_APPLE
#if TDAV_UNDER_IPHONE || TDAV_UNDER_IPHONE_SIMULATOR
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>
#endif

How can I fix it? Thanks for your help!


Solution

  • I'd check and make sure your language version is at least C++11, since that's when tuple was introduced.

    Snap of relevant build setting row

    Failing that I'd verify the .mm file is properly tagged as C++ in the project file (select the file, then open the right hand side "File inspector" thing.)

    Detail of file inspector