salubhayo
salubhayo

Reputation: 53

iOS: SwiftUI compatible with Storyboards

Can we develop an iOS application with both storyboards and SwiftUI. is there anything like bridging available like we do bridging codes from objective c to swift and vice versa.

Upvotes: 0

Views: 153

Answers (2)

Peter Lapisu
Peter Lapisu

Reputation: 21005

Step 1) subclass UIHostingController

class MySwiftUIViewUIController: UIHostingController<MySwiftUIView> {
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder, rootView: MySwiftUIView())
    }
} 

Step 2) In interface builder add a UIHostingController and set it's subclass

Upvotes: 0

Adam
Adam

Reputation: 5145

Interface Builder supports adding a UIHostingController to a storyboard, which is the UIKit controller that can have a SwiftUI subview, but there’s no integration beyond that. You’d have to write your own methods and classes to pass data and actions between them.

Upvotes: 2

Related Questions