Check this article - https://www.tridhyatech.com/blog/make-animated-live-widgets-in-the-iphone-lock-screen-using-swiftui
The logic is in updating following two methods -
func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> ()) {
let entry = SimpleEntry(date: Date())
WidgetCenter.shared.reloadAllTimelines()
completion(entry)
}
func getTimeline(in context: Context, completion: @escaping (Timeline<SimpleEntry>) -> ()) {
var entries: [SimpleEntry] = []
let currentDate = Date()
for i in 0 ..< 60 {
let entryDate = Calendar.current.date(byAdding: .second, value: i, to: currentDate)!
let entry = SimpleEntry(date: entryDate)
entries.append(entry)
}
let reloadDate = Calendar.current.date(byAdding: .minute, value: 1, to: currentDate)!
let timeline = Timeline(entries: entries, policy: .after(reloadDate))
completion(timeline)
}
It shows how to animate an image. This logic works for 60 seconds too.
I have tested this in device. But don't know yet if it will be approved by apple.