Elements and SwiftUI

We’ve received quite a few questions like this via private support channels over the past few weeks, so I wanted to go ahead and post this reply publicly for everybody to enjoy.

Not quite yet.

We’re looking into supporting SwiftUI, of course, but there are many things to consider as to why it will be a short while until we can.

For one, SwiftUI is early beta. Half of the Swift language features that drive it are still in review, and some are not even in in review yet, let alone finalized, and they will change both between now and Xcode 11 RTM, and probably, it looks like, change again between then and when they are made official language features.

In fact, Beta 5 of Xcode 11 just drastically changed SwiftUI, yesterday.

For another, and this applies to using any Swift-based Apple frameworks (eg Combine, RealityKit), Swift has just reached **ABI Stability&& (in 5.0) — and Swift Module Stability, while planned and announced for Swift 5.1 is (a) still in beta and (b) entirely undocumented. This means a lot of work, research and reverse engineering will go into this over the next few months before we can link to Swift frameworks (maybe, depending on what Apple ships when, in time with Xcode 11 release, but possibly not until after).

The thing to keep in mind is this: Apple’s developer platform, Cocoa, is a beautiful and well designed piece of technology, well documented, solid, and easy to work with both for developers and for tool chains such as ours. That’s the Objective-C runtime, and you can tell that it was created a good while ago by people who knew what they were doing,

On top of this/parallel to this Apple is constructing a whole another layer, the Swift Runtime and ABI, and it is not well designed or documented (neither well or, like, at all) and as not, frankly, the air of something designed by someone who did this before or knows what they are doing. :frowning:

That’s what we have to deal with right now, for Swift ABI interoperability.

You can also refer to these documentation topics for more information on what we’re doing to support Swift object model on macOS/iOS:

These will be updated over time, as things progress.



Is there any news regarding this ?

Short answer: no.

I saw in the latest release notes

  • 83417: Swift ABI arc
  • 83408: Swift ABI interop support (wip)
  • Preparative work for Swift ABI.

Does that mean your working on something at the moment ?

We’ve started working on the “Swift” object model for Island/Darwin, yes, which in the long run will include generating Swift ABI compatible types that Apple Swift can link to, and linking to Apple Swift-generated libraries and frameworks (which would include SwiftUI).

We’re not doing anything specifically for working with or integrating SwiftUI, nor will we, probably, before “SwiftUI 2.0”, which will most likely break everything. But the above, once done (which it’s nit close to being, yet ;), should let you use the SwiftUI APIs.