Running Swift Code from Juce Project?

Hi all,

I’ve written some some code in Swift using the Accessibility framework and want to use this in one of my Juce projects. Googling around I could only find advice how to use c++ code in Swift projects but not the other way around.

In my case, I simply want to call a swift function from c++ and returning a simple boolean.

Thanks
Stefan

You can’t call Swift from C++ (that I’m aware of) but you can from Objective-C++. So instead of adding a .cpp file to your project, and a .mm

Then you’ll need to follow the steps here: https://developer.apple.com/documentation/swift/imported_c_and_objective-c_apis/importing_swift_into_objective-c

If you keep your header pure C++ then normal C++ can use your function / class. Keep all the Objective-C++ that interfaces to the Swift in the .mm file.

You will need to be outside of what Projucer can do, so you’ll need to maintain your project yourself.

Thanks G-Mon,

I‘ll have a look at this.

cheers,
Stefan