Rollo62 539 Posted June 8, 2021 (edited) Hi there, it seems that Apple moves more and more from Objective-C to Swift, especially for the new APIs, like RealityKit 2 https://developer.apple.com/documentation/realitykit. That would mean Delphi / Firemonkey needs a way to bind with Swift, if no Objective-C might be available. Has someone maybe checked about such Swift binding, and what pitfalls may be there ? I would expect that Swift can handle more features, that cannot really converted to Delphi, but thats just my assumption. Who could give more light to this ? Edit: I had an older post in the german DP, see here, as a kind of cross-post to this topic. Edited June 8, 2021 by Rollo62 Share this post Link to post
Dalija Prasnikar 1404 Posted June 9, 2021 16 hours ago, Rollo62 said: That would mean Delphi / Firemonkey needs a way to bind with Swift, if no Objective-C might be available. There is QP report for that https://quality.embarcadero.com/browse/RSP-22944 When will importing Swift frameworks be available, the is only that Embarcadero can tell. 16 hours ago, Rollo62 said: Has someone maybe checked about such Swift binding, and what pitfalls may be there ? From what I can see, such Swift framework would have to be compiled in interop mode and Expose its API. Delphi is capable of importing Objective-C framework, so it is possible that @objc mode would suffice. If not there is unofficial @cdecl support, for Swift side. https://forums.swift.org/t/best-way-to-call-a-swift-function-from-c/9829 This is not something I had need to explore, so this is all the information I can give. 1 Share this post Link to post
Dalija Prasnikar 1404 Posted June 9, 2021 (edited) If the Swift framework does not support any explicit interop, it could be possibly wrapped and consumed through Objective-C library that can then be imported in Delphi https://developer.apple.com/documentation/swift/imported_c_and_objective-c_apis/importing_swift_into_objective-c If you need support for Swift frameworks now, this sounds like most viable option. Edited June 9, 2021 by Dalija Prasnikar Share this post Link to post
Rollo62 539 Posted June 9, 2021 @Dalija Prasnikar Thanks, that is not so bad news than I expected. We better all vote for RSP-22944 then, to keep things moving. Share this post Link to post
Chris Pim 34 Posted July 29, 2021 I’ve been exploring this for my Delphi app which needs to support WidgetKit (iOS 13-style) Home Screen widgets. Getting the widget built and working with my app was easy enough but I’m struggling to force it to update when data changes as the WidgetKit API is swift only. I’ve tried creating a native Obj-C static library which contains the bridging headers to call the swift code, and tried a swift static library with the @objc tags to expose the correct headers but Delphi just won’t see the exposed classes. If I pull the libraries above into native ObjC apps they both work fine but Delphi can’t seem to see the classes exposed, even though they link into the app using the fake loader method. I feel like I’m so tantalisingly close to getting this working so I’ll keep digging and post here if I get it working. 1 Share this post Link to post
eXxport 0 Posted May 12, 2022 I'm having the same problem. Did you manage to make it work? Share this post Link to post
Navid Madani 1 Posted February 28 Looking at Swift 5.9 release notes, there is talk of bidirectional C++ interoperability. Has anyone tried it? https://www.swift.org/documentation/cxx-interop/ Share this post Link to post