5

I know how to include and build objective-c sources in my QtApplication. Generally MyQtApplication.pro file includes objective-c source .mm files like this which does the trick and its quite easy.

# MyQtApplication.pro
ios {
    CONFIG  += objective_c
    OBJECTIVE_SOURCES += SomeObjectiveCSource.mm
    HEADERS           += SomeObjectiveCSource.hpp
}

Question:
Is there way to include .swift files as well? And hence include, build and call Swift code from C++ classes in a QtApplication? Does Qt officially support it now? Is there a concrete example I can look into?

I did look into this discussion. But I am looking for a concrete example.

Or, calling an API in .swift file from a .mm file which acts as a bridge inside my Qt Application? I am looking for concrete example if this is possible.

TheWaterProgrammer
  • 7,055
  • 12
  • 70
  • 159
  • this might help https://forum.qt.io/topic/82200/qt5-swift-dance-together-super-its-run-many-thanks – Mohmmad S Mar 19 '19 at 10:09
  • 1
    There's no bridging between C++ and Swift, in either direction. You can bridge to ObjC(++), and from there to C++. I have no experience with QT, so I can't help on that part of the question. – Avi Mar 19 '19 at 10:09
  • 1
    Yes, we can bridge ObjC++ to swift I believe. But that will take some extra trickery in the Qt project file so that Qt compiles and bundles the swift code into my app binary. That extra integration piece is what I am looking for in this question. And of course with a concrete example. – TheWaterProgrammer Mar 19 '19 at 11:30

0 Answers0