Packing UIKit’s ViewController in SwiftUI
Let’s say if we have any UIViewController to be used on any SwiftUI based app we have to follow below steps
Extend the protocol
UIViewControllerRepresentable
Implement makeUIViewController and updateUIViewController
However writing a wrapper provides easier way to use it inline for any of the viewControllers.
Here two closures one each for the requirement of UIViewControllerRepresentable.
@autoclsore which will enable us to keep the conventions of UIViewControllerRepresentable
and create our views lazily without requiring any additional syntax during calling.
When accessing a ViewController there might be some cases where accessing Context
might be required , so let’s added some convenience initializers with just ViewController
and without Context
Here’s the usage of it, let’s say u have EntryViewController
References : https://gist.github.com/badrinathvm/aa88ec0b66b99d4acb85f7069ae40625
Happy Coding..!!