Rewriting Remotion in SwiftUI
It took a while — August 2022 — before we felt that we were targeting a new enough version of macOS that we could feasibly start using SwiftUI in our code base. Since then we haven’t looked back: Development is faster, the app is more stable, and new teammates are ramping up faster thanks to the simpler code base.
We now think: If you are a macOS or iOS developer who hasn’t yet taken the plunge yet, now is a great time to start writing a new app using almost exclusively SwiftUI, and use its friends Combine and concurrency for the data flow.
[…]
While SwiftUI is all you’ll need for a basic Mac or iOS application, there are still quite a few gaps that will require you to partially make use of classic Cocoa views. In our code base, for example, we need some access to NSEvents, text input, and tweaking the first responder that just aren’t possible with pure SwiftUI. Fortunately Apple has provided bridges — the
NSHostingView
andNSHostingController
for embedding SwiftUI in a Cocoa view, andNSViewRepresentable
andNSViewControllerRepresentable
for embedding a Cocoa view in a SwiftUI view. A really powerful technique we can’t neglect to mention is combining these two together, as described in this SwiftUI Lab article.
Previously:
- Rewriting SoundCloud in SwiftUI
- SwiftUI Notes Before WWDC 2023
- Converting the Streaks Apple Watch App to SwiftUI
- Rewriting the Uber App in Swift