NSUserActivity is no longer responding to setSuggestedInvocationPhrase?

Is anybody else seeing problems with NSUserActivity and the Intents extension after upgrading to Xcode 11.4 and/or iOS 13.4? I have a project that was working the last time I built it, but that was prior to the 11.4 release. Today, when trying to build it I find that a debug build seems to work fine when attached to a debugger. But if I launch the app directly from Springboard I will get a crash and an unrecognized selector error message in the console as soon as I call setSuggestedInvocationPhrase.


I made a simple test case for my Feedback Assistant report. here's the core function that exhibits the problem.


import SwiftUI
import Intents

struct ContentView: View {
    var body: some View {
        if testForSelector() {
            return Text("You can call setSuggestedInvocationPhrase")
        } else {
            return Text("setSuggestedInvocationPhrase will crash if you call it.")
        }
    }
}

extension ContentView {
    func testForSelector() -> Bool {
        let activity = NSUserActivity(activityType: "Testing Activity")
       
        return activity.responds(to: #selector(setter: INIntent.suggestedInvocationPhrase))
    }
}


I'm guessing that I've done something super-weird to cause this, but it *looks* very straightforward. Hoping somebody else has seen something similar.


If you do see something similar I submitted a Feedback Assistant at FB7645803.

Replies

In case anybody else runs into this problem: Apple got back to me on the Feedback Assistant report. I wasn't explicitly linking Intents.framework to the target and it was causing this problem. I'm not sure why it worked in older environments, or why it still worked when the debugger was attached, but clearly linking Intents.framework is the proper thing to do anyway.