Can't link metal-cpp to C++ framework in Swift Mac app

I have a very simple Mac app with just a MTKView in it which shows a single color. I want to move the rendering code to C++. For this I created a C++ framework target which interoperates with the Swift code - main project target. I am trying to link metal-cpp library to the C++ framework target using these instructions. Approach described in this article works with simple C++ Mac console apps. But in my mixed Swift/C++ project Xcode cannot find Foundation/Foundation.hpp (and probably other headers) to include into the C++ header.

I inserted metal-cpp folder into my project and added it to C++ target's header search paths, as written in the instructions.

Answered by gachapon in 807471022

Update, I found a project that's mixing C++ and Swift here and I was able to use metal-cpp in its C++ code, so this question is closed.

Update: I also got this message on the line  #include <Fuondation/Foundation.hpp>:

Did not find header 'Foundation.hpp' in framework 'Foundation' (loaded from '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/System/Library/Frameworks')

Update: my ultimate goal is to create a graphics engine with a metal view and some UI, so I am using C++ with metal-cpp for graphics and SwiftUI for buttons and stuff. But I just can't use metal-cpp with a C++ framework target the way I did with C++ console apps for Mac. Am I doing something wrong? Is there a way to point Xcode to use the .hpp files in metal-cpp and metal-cpp-extensions folders? I set the header search paths for the C++ framework target, but it doesn't work... Any help is much appreciated 🙏

Maybe I’ll just use ImGui, but still any help is appreciated.

Accepted Answer

Update, I found a project that's mixing C++ and Swift here and I was able to use metal-cpp in its C++ code, so this question is closed.

Can't link metal-cpp to C++ framework in Swift Mac app
 
 
Q