Widget AppIntent perform network request

I had write a widget after iOS 17+, It had a Toggle to perform a appintent . When switch the toggle, the appintent will perfrom , just like

` func perfrom() async throws -> some IntentResult {

// first
let first = try await getFristValue()
 
let second = try await getSecondValue(by: first)

let third = try awiat getThirdValue(by: second)

return .result()

} ` and I found, it will work when I am debugging connect with Xcode. But, when I don't connect xcode, it will not work.

How can I fixed it ?

Can you provide more information, like what isn't working? What does your App Intent and toggle do?

I also encountered the same problem

struct IncrementIntent: AppIntent {
    static var title: LocalizedStringResource = "Increment Count"
    
    func perform() async throws -> some IntentResult {
        Counter.incrementCount()
        return .result()
    }
}

I used URLSession to initiate a network request in Counter.incrementCount().it will work when I am debugging connect with Xcode. But, when I don't connect xcode, it will not work.

Widget AppIntent perform network request
 
 
Q