# Running Swift Code from Juce Project?

**URL:** <https://forum.juce.com/t/running-swift-code-from-juce-project/37721>\
**Category:** MacOSX and iOS\
**Created:** [February 22, 2020, 9:26am UTC](https://forum.juce.com/t/running-swift-code-from-juce-project/37721 "2020-02-22T09:26:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![StefanS](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@StefanS](https://forum.juce.com/u/StefanS)\
**Post date:** [February 22, 2020, 9:26am UTC](https://forum.juce.com/t/running-swift-code-from-juce-project/37721/1 "2020-02-22T09:26:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![RolandMR](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rolandmr/32/641_2.png) [@RolandMR](https://forum.juce.com/u/RolandMR)\
**Post date:** [February 22, 2020, 5:12pm UTC](https://forum.juce.com/t/running-swift-code-from-juce-project/37721/2 "2020-02-22T17:12:50Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![StefanS](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@StefanS](https://forum.juce.com/u/StefanS)\
**Post date:** [February 22, 2020, 5:32pm UTC](https://forum.juce.com/t/running-swift-code-from-juce-project/37721/3 "2020-02-22T17:32:16Z")

</div>

Thanks G-Mon,

I‘ll have a look at this.

cheers,  
Stefan

---

<div class="post-metadata">

**Author:** ![jimketcham](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@jimketcham](https://forum.juce.com/u/jimketcham)\
**Post date:** [February 27, 2022, 10:08pm UTC](https://forum.juce.com/t/running-swift-code-from-juce-project/37721/4 "2022-02-27T22:08:22Z")

</div>

Hi, see [Call swift code from objc code in … | Apple Developer Forums](https://developer.apple.com/forums/thread/129282) re. calling Swift from CPP.
