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.

No one can solve this problem?

Have you added capabilities for outgoing network connections? There isn't a reason this wouldn't work from Apple API standpoints, but more from your code. The only thing the debugger gives you is the ability to not have your process killed for taking too long to return. If those API calls are taking a long time to return it would explain why you aren't seeing the same when not running via the debugger.

Widget AppIntent perform network request
 
 
Q