I replied to this, but my reply seems to have disappeared... Here we go (again): (And now it's appeared. Apple, issues with the forums after your changes overnight?)
Aside from printing nothing (""), I think you're doing this in the wrong place.
I have this in my main app's WindowGroup. It just loads the PhoneView:
var body: some Scene {
WindowGroup {
PhoneView()
.environment(modelData)
// The difference is that I'm not continuing the Spotlight activity here, unlike you.
}
}
struct PhoneView: View {
var body: some View {
VStack {
// Blah blah blah
}
.onContinueUserActivity(CSSearchableItemActionType, perform: handleSpotlight)
}
private func handleSpotlight(userActivity: NSUserActivity) {
guard let uniqueIdentifier = userActivity.userInfo?[CSSearchableItemActivityIdentifier] as? String else { return }
if(!uniqueIdentifier.isEmpty) {
// Handle the Spotlight activity
}
}
}