Post

Replies

Boosts

Views

Activity

Reply to Live Activity fails to start with "unsupportedTarget" error on iOS 18 beta
Hi, the live activity function should look something like: func startLiveActivity() { let attributes = TimerAttributes(/*…*/) let contentState = TimerAttributes.ContentState(/*…*/) Task { @MainActor in do { let activity = try Activity<TimerAttributes>.request( attributes: attributes, content: ActivityContent(state: contentState, staleDate: staleDate), pushType: nil ) self.activity = activity } catch { print("Failed to start Live Activity: \(error)") } } } My TimerAttributes - this is your attributes for Live Activity, defined as: struct TimerAttributes: ActivityAttributes { public struct ContentState: Codable, Hashable { /* content state variables */ } /* other variables here */ } so when ever you call your start, you have to call your Live Activity start function. I place it in a Live Activity Manager.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’25
Reply to Using App Intents in Live Activity to Pause a Timer
The solution is found. To use buttons in LA or Dynamic Island, it shouldn’t be AppIntent, it should be LiveActivityIntent. struct PauseIntent: LiveActivityIntent { // followed by the rest of the code } either load the user defaults data that is linked with App Group or use SwiftData/CoreData, inject model container, and save the updated state there. Then update the live activity, the LA or Dynamic Island will show the updated ContentState. When returning to the app, reload the data from the data store and rebuild the necessary view models.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’25