0

I am building an iOS app in Swift using Swift UI. This app needs to call C++ code available through a static lib. So, I've setup my Swift code to call an Objective C bridging layer that in turn calls the C++ code. It mostly works ok i.e. I am able to make calls to my own C++ library.

Except I am not able to include a number of standard C++ headers (like cstdint) in any of my header files that are imported into the Bridging header. A few relevant things I checked in this investigation:

  • I am able to import stdint.h (older version of the header?) just fine, but if I include cstdint, the preprocessing of the bridging header fails, saying that it cannot find cstdint.
  • I am able to import cstdint in my .mm files without issue.
  • Apple Clang - Language C++ > C++ Language dialect is set to "GNU++17 [-std=gnu++17].
  • Apple Clang - Language C > C language dialect is "gnu11".
  • Build options > Compiler for C/C++/Objective C is set to Default compiler (Apple Clang).

Any clues as to what I must update in my project build settings, or any flags I need to pass in?

IM42
  • 138
  • 10

1 Answers1

0

TIL (from elsewhere), that my Objective C shim header file for the C++ code, cannot include C++ headers like cstdint because there is no C++ parsing in the swift compiler. Including stdint.h worked because that is a C header.

IM42
  • 138
  • 10