I want to open the popup view controller or sheet to invite user in share play. But I got an error to achieve.
struct ContentView: View {
@State private var showDialog = false
private let activityManager = GroupActivityManager()
var body: some View {
VStack {
Button(action: {
Task {
let outcome = await activityManager.startSharing()
if outcome == .needsDialog {
showDialog = true
}
}
}, label: {
Label(title: {
Text("Start SharePlay")
}, icon: {
Image(systemName: "shareplay")
})
})
.buttonStyle(.borderedProminent)
}
> .sheet(isPresented: $showDialog, content: {
GroupActivityShareSheet {
DemoAppActivity()
}
})
.padding()
}
}
Using below code to open the sheet
struct GroupActivityShareSheet<Activity: GroupActivity>: UIViewControllerRepresentable {
let preparationHandler: () async throws -> Activity
func makeUIViewController(context: Context) -> UIViewController {
GroupActivitySharingController(preparationHandler: preparationHandler)
}
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {}
}
Got the below error while open the popup
> `Cannot run query `<_EXQuery: 0x6000021a2620>`
Failed to lookup mobile extension with query <_EXQuery: 0x6000021a2620> on <_GroupActivities_UIKit.PeoplePickerController: 0x600002c62480>
Failed to fetch config for hostViewController <_GroupActivities_UIKit.PeoplePickerController: 0x600002c62480>
Failed to build remote hostViewController for <_GroupActivities_UIKit.GroupActivitySharingController: 0x105f6f530>
Failed to fetch extensionViewController
Calling -viewDidAppear: directly on a view controller is not supported, and may result in out-of-order callbacks and other inconsistent behavior. Use the -beginAppearanceTransition:animated: and -endAppearanceTransition APIs on UIViewController to manually drive appearance callbacks instead. Make a symbolic breakpoint at UIViewControllerAlertForAppearanceCallbackMisuse to catch this in the debugger. View controller: <_GroupActivities_UIKit.GroupActivitySharingController: 0x105f6f53`