I'm creating an iOS app with SwiftUI and everything works great on all platforms including OSX except for the UIActivityViewController. The controller works as expected on iOS but just displays a blank window on OSX that I can't even close. I'm passing simple text to the controller to share via email or printer.
Here is the controller struct;
struct ActivityViewController: UIViewControllerRepresentable {
var activityItems: [Any]
var applicationActivities: [UIActivity]? = nil
func makeUIViewController(context: UIViewControllerRepresentableContext) -> UIActivityViewController {
let controller = UIActivityViewController(activityItems: activityItems, applicationActivities: applicationActivities)
return controller
}
func updateUIViewController(_ uiViewController: UIActivityViewController, context: UIViewControllerRepresentableContext) {}
}
And I present it like this;
.sheet(isPresented: $bShare, onDismiss: {
print("Dismiss")
}, content: {
Text("It's Fun to Share")
ActivityViewController(activityItems: ["place holder"])
})