Post

Replies

Boosts

Views

Activity

Reply to Timeline refresh issue for widget on ios 18.2
By the way, code like the following. It runs directly, and it does work on iOS18.2. But not if it's a timeline refresh triggered by Button or Toggle. func timeline( for configuration: DynamicIntentWidgetPersonIntent, in context: Context ) async -> Timeline<Entry> { var entries: [Entry] = [] let currentDate = Date.now let entry = Entry(date: currentDate,person: person(for: configuration),type: .F2) entries.append(entry) let entry2 = Entry(date: currentDate.adding(.second, value: 3), type: .F1) entries.append(entry2) return .init(entries: entries, policy: .never) }
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’24
Reply to Timeline refresh issue for widget on ios 18.2
Thank you very much for your reply. I think the default is F1. The func timeline function does not enter the criteria for if FriendGlobalType.type ==.f2, so there is only one entry. Every time I click the Button, the state changes to F2. At this point, the func timeline will generate two entries. One is F2. The other is the status change to F1 after 3 seconds. The init method and FriendGlobalType are for logging state. Because my request here is to trigger the network request after clicking Button on F1, await the network request, refresh the UI to F2. And then back to F1 in three seconds. I simplified the code and did not attach the network request code. This logic actually works on iOS17. But I don't know why ios 18.2 doesn't work. Is there a better design?
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’24
Reply to Timeline refresh issue for widget on ios 18.2
Thank you for your reply, there is a problem with the previous code date. I've put up part of my project code, and my project has a lot of different views, so I use FriendType to differentiate, and I use a global FriendGlobalType to keep track of which FriendType I'm currently in. For simplicity's sake, I've only used two types so far. Question: Why does the view2 corresponding to F2 flash by on iOS18.2 and show view1 corresponding to F1 without a delay of 3 seconds? Everything works on iOS17. struct Entry: TimelineEntry { var date: Date = .now var person: Person? var type: FriendType = .F1 init(date: Date, person: Person? = nil, type: FriendType) { self.date = date self.person = person self.type = type FriendGlobalType.type = type } } extension DynamicIntentWidget { struct EntryView: View { let entry: Entry var body: some View { VStack { switch entry.type { case .F1: Button(intent: FriendIntent()) { Text("Click") } case .F2: Text("F2") } } .containerBackground(.clear, for: .widget) } } } enum FriendType: String, AppEnum { case F1 case F2 static var typeDisplayRepresentation = TypeDisplayRepresentation(name: "FriendType") static let caseDisplayRepresentations: [Self: DisplayRepresentation] = [ .F1: DisplayRepresentation(title: "F1"), .F2: DisplayRepresentation(title: "F2"), ] } struct FriendGlobalType { static var type: FriendType = .F1 } struct FriendIntent: AppIntent { static var title: LocalizedStringResource = "FriendIntent" func perform() async throws -> some IntentResult { FriendGlobalType.type = .F2 return .result() } } func timeline( for configuration: DynamicIntentWidgetPersonIntent, in context: Context ) async -> Timeline<Entry> { var entries: [Entry] = [] let currentDate = Date.now let entry = Entry(date: currentDate,person: person(for: configuration),type: FriendGlobalType.type) entries.append(entry) if FriendGlobalType.type == .F2 { let entry2 = Entry(date: currentDate.adding(.second, value: 3), type: .F1) entries.append(entry2) } return .init(entries: entries, policy: .never) }
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’24
Reply to Timeline refresh issue for widget on ios 18.2
var isAudibleArming = false struct SoundAlarmIntent: AppIntent { static var title: LocalizedStringResource = "SoundAlarmIntent" func perform() async throws -> some IntentResult { isAudibleArming = true return .result() } } func timeline( for configuration: DynamicIntentWidgetPersonIntent, in context: Context ) async -> Timeline<Entry> { var entries: [Entry] = [] let currentDate = Date() let entry = Entry(person: person(for: configuration)) entries.append(entry) if isAudibleArming { let entry2 = Entry(person: Person(name: "Friend4", dateOfBirth: currentDate.adding(.second, value: 6))) entries.append(entry2) } return .init(entries: entries, policy: .never) } Maybe it's clearer this way。Can you help me? Thank you
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’24
Reply to Can the same widget in an Xcode project support multiple targets?
I found that when creating a new Widget, there is an option: Embed in Application. However, after the new creation was completed, I wanted this widget to support other apps simultaneously, but I couldn't find the editing entry.
Replies
Boosts
Views
Activity
1w
Reply to The identity used to sign the executable is no longer valid
May I ask how you solved this problem? Thank you. I also encountered this problem. The first run always reports the above error. Only after running it again can it work normally.
Replies
Boosts
Views
Activity
Nov ’25
Reply to Code Signing Issue with Apple Developer Account (IXUserPresentableErrorDomain, Code: 14)
Has there been any progress on this issue at present? How did you solve it?
Replies
Boosts
Views
Activity
Nov ’25
Reply to Can't Widgetkit use lottie to implement the isOn state of toggle?
Added: Xcode Console: The body of the Widget entries' view contains the following unsupported types: PlatformViewRepresentableAdaptor< LottieView> , PlatformViewRepresentableAdaptor< LottieView>
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’25
Reply to Timeline refresh issue for widget on ios 18.2
I've figured out why, because of this static global variable, FriendGlobalType. I'm going to use UserDefaults to record the states, and then I'm going to get the states. It's not quite clear why you can't use static global variables this way. But at least it worked out. Thank you very much!
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to Timeline refresh issue for widget on ios 18.2
By the way, code like the following. It runs directly, and it does work on iOS18.2. But not if it's a timeline refresh triggered by Button or Toggle. func timeline( for configuration: DynamicIntentWidgetPersonIntent, in context: Context ) async -> Timeline<Entry> { var entries: [Entry] = [] let currentDate = Date.now let entry = Entry(date: currentDate,person: person(for: configuration),type: .F2) entries.append(entry) let entry2 = Entry(date: currentDate.adding(.second, value: 3), type: .F1) entries.append(entry2) return .init(entries: entries, policy: .never) }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to Timeline refresh issue for widget on ios 18.2
Thank you very much for your reply. I think the default is F1. The func timeline function does not enter the criteria for if FriendGlobalType.type ==.f2, so there is only one entry. Every time I click the Button, the state changes to F2. At this point, the func timeline will generate two entries. One is F2. The other is the status change to F1 after 3 seconds. The init method and FriendGlobalType are for logging state. Because my request here is to trigger the network request after clicking Button on F1, await the network request, refresh the UI to F2. And then back to F1 in three seconds. I simplified the code and did not attach the network request code. This logic actually works on iOS17. But I don't know why ios 18.2 doesn't work. Is there a better design?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to Timeline refresh issue for widget on ios 18.2
Thank you for your reply, there is a problem with the previous code date. I've put up part of my project code, and my project has a lot of different views, so I use FriendType to differentiate, and I use a global FriendGlobalType to keep track of which FriendType I'm currently in. For simplicity's sake, I've only used two types so far. Question: Why does the view2 corresponding to F2 flash by on iOS18.2 and show view1 corresponding to F1 without a delay of 3 seconds? Everything works on iOS17. struct Entry: TimelineEntry { var date: Date = .now var person: Person? var type: FriendType = .F1 init(date: Date, person: Person? = nil, type: FriendType) { self.date = date self.person = person self.type = type FriendGlobalType.type = type } } extension DynamicIntentWidget { struct EntryView: View { let entry: Entry var body: some View { VStack { switch entry.type { case .F1: Button(intent: FriendIntent()) { Text("Click") } case .F2: Text("F2") } } .containerBackground(.clear, for: .widget) } } } enum FriendType: String, AppEnum { case F1 case F2 static var typeDisplayRepresentation = TypeDisplayRepresentation(name: "FriendType") static let caseDisplayRepresentations: [Self: DisplayRepresentation] = [ .F1: DisplayRepresentation(title: "F1"), .F2: DisplayRepresentation(title: "F2"), ] } struct FriendGlobalType { static var type: FriendType = .F1 } struct FriendIntent: AppIntent { static var title: LocalizedStringResource = "FriendIntent" func perform() async throws -> some IntentResult { FriendGlobalType.type = .F2 return .result() } } func timeline( for configuration: DynamicIntentWidgetPersonIntent, in context: Context ) async -> Timeline<Entry> { var entries: [Entry] = [] let currentDate = Date.now let entry = Entry(date: currentDate,person: person(for: configuration),type: FriendGlobalType.type) entries.append(entry) if FriendGlobalType.type == .F2 { let entry2 = Entry(date: currentDate.adding(.second, value: 3), type: .F1) entries.append(entry2) } return .init(entries: entries, policy: .never) }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to Timeline refresh issue for widget on ios 18.2
var isAudibleArming = false struct SoundAlarmIntent: AppIntent { static var title: LocalizedStringResource = "SoundAlarmIntent" func perform() async throws -> some IntentResult { isAudibleArming = true return .result() } } func timeline( for configuration: DynamicIntentWidgetPersonIntent, in context: Context ) async -> Timeline<Entry> { var entries: [Entry] = [] let currentDate = Date() let entry = Entry(person: person(for: configuration)) entries.append(entry) if isAudibleArming { let entry2 = Entry(person: Person(name: "Friend4", dateOfBirth: currentDate.adding(.second, value: 6))) entries.append(entry2) } return .init(entries: entries, policy: .never) } Maybe it's clearer this way。Can you help me? Thank you
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’24