My whole code base is in UIKit. I want to build my action extension module using swiftUI.
As I can add NSExtensionPrincipalClass as the initial entry point to the extension UI. How can I set the initial entry point to a swiftUI content view.
struct ActionExtensionInitialView: View {
var body: some View {
Text("Hello, World!")
}
}
Your principal class can look like the following (tested & worked with Xcode 11.2)
class ActionViewController: UIHostingController<AnyView> {
// override designated initialiser
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
let contentView = ActionExtensionInitialView() // << SwiftUI root view
super.init(rootView: AnyView(contentView))
}
@objc required dynamic init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
backup
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With