WidgetKit

RSS for tag

Show relevant, glanceable content from your app on the iOS Home screen, iOS Lock screen, in macOS Notification Center, and as complications on Apple Watch.

WidgetKit Documentation

Posts under WidgetKit tag

136 Posts
Sort by:
Post not yet marked as solved
2 Replies
1.6k Views
Good morning, if I understood correctly, Live Activities will come on a later iOS 16 update and are not present on the current iOS 16 beta. I think that might explain the lack of documentation on the subject. What I'd like to understand is what could be the best path to take to make sure we're prepared to build a Lock Screen widget with Live Activities. Is a Home Screen widget a good starting point? Does anyone know? Can an Apple engineer shine some light into the topic? Thank you
Posted
by
Post not yet marked as solved
0 Replies
115 Views
I'm excited to already have a widget/complication running on watchOS using WidgetKit. It's a great framework! Next, I need to get some settings from my iOS app over to the watch to help configure the widget. Ideally, I'd like the user to be able to change settings on the iOS app, and have them reflected in the watch widget pretty soon after without having to do anything on the watch. (From early testing, updateApplicationContext is decent because it can still be sent even when the watch app isn't active, but unfortunately it doesn't seem to wake up to process this incoming data until the user manually opens the app on the watch again. But maybe I've missed something.) Anyway, what's the best way to do this configuration between phone and watch?
Posted
by
Post marked as solved
2 Replies
228 Views
I have a simple complication-only app called Roughly, which shows the approximate time in words, to the nearest five minutes, in a choice of languages. It's been on the store for several years, and it's getting creaky. This new guide to WidgetKit is making me nervous: https://developer.apple.com/documentation/widgetkit/converting-a-clockkit-app There's a line buried in there: watchOS 9 and later no longer shows families like CLKComplicationFamily.circularSmall, CLKComplicationFamily.modularSmall, or CLKComplicationFamily.modularLarge on watch faces. So... is that the end of all basic complications that haven't been made into Widgets? If so, it would be good to have more clarity on this — I do feel it's easy to miss when things are deprecated. Thanks for any info!
Posted
by
Post marked as solved
2 Replies
245 Views
Hi, I created a widget for our application. The application is manually signed for distribution. I created a new identifier and provisioning profile for distribution for the widget. The new identifier is our app identifier with ".widget" appended. After I added both the app and widget provisioning profiles to my export.plist for the xcodebuild step, the app builds without error. When I try to validate the app before upload, I get this error: Error: Invalid Signature. Code object is not signed at all. The file at path [MyApp.app/PlugIns/MyAppWidget.appex/fix_imports.sh] is not properly signed. Make sure you have signed your application with a distribution certificate, not an ad hoc certificate or a development certificate. The provisioning profiles in the export.plist are for distribution. Has anyone else encountered and fixed error? I'm stumped! Claire
Posted
by
Post not yet marked as solved
2 Replies
226 Views
Hello, I am trying out the new Watch Complications in WidgetKit and I am stuck on the widget '.accessoryCorner'. Unfortunately, I can't find a way to create a curved text as shown in the image in the upper left corner ('HON'). Using the '.widgetLabel' does insert a curved label in the second line, but the text above it in the first line remains horizontally arranged. Has anyone found a solution for this yet? Thanks for the help Thomas
Posted
by
Post not yet marked as solved
0 Replies
133 Views
I bought new iphone 11 and when i made the photo widget it says no contant available, i did leave it all night with the charger on but nothing changed, i sign out and re-log into apple id and removed the widget , restarted the phone but the situation is the same, what should i do??
Posted
by
Post not yet marked as solved
0 Replies
175 Views
Incompatible widget content The body of the widget entry's view contains the following unsupported types: PlatformViewRepresentableAdaptor. All I have in the body of my accessoryCircular widget is: ProgressView(value: 0.3, total: 1.0) Any way to fix this?
Posted
by
Post marked as solved
1 Replies
216 Views
I am developing an app with a widget available. Until recently the widget was being shown on both an iPhone and an iPad devices. Then I changed some logic in the widget, and now it only displays on the iPhone. I also use the Xcode simulators in the development, and the widget is available on both iPhone and iPad simulators, with same code. Summarizing the status for the widget. Simulators iPhone (13 Pro Max, iPhone 12) - OK iPad Pro (12.9" 5th Gen) - OK Devices iPhone (11) - OK iPad (Air 2) - Not available I can attach the Widget extension to the debugger for the simulators and the iPhone device. However the process in not there when I use the iPad device, so cannot attach the widget code to the debugger. Even if I attach the widget extension by name to the debugger, it is as if it is not running. I can run the widget extension directly on the iPad device (using an appropriate build scheme) and the details of the info displayed by the widget is the same as for the iPhone. So it is not running the widget on an iPad that is the problem. It seems like the widget extension is not embedded in the app code when the app is loaded on to an iPad device. Has anyone experienced anything similar? Not necessarily with a widget, it could be with another framework extension.
Posted
by
Post marked as solved
2 Replies
246 Views
I am trying to upload my app to AppStore using Xcode. The app uses widgets, and after archiving the app, I run the validation. It reports two errors. Invalid directory. The bundle Payload/……/…WidgetExtension.appex is not contained in a correctly named directory. It should be under "Plugins". CFBundleIdentifier Collision. There is more than one bundle with the CFBundleIdentifier value '…widget' under the iOS application. I suspect that the two are linked issues, and that whilst trying to debug the widget in a simulator I may have duplicated any entry somewhere in the settings, but I am not clear where to look, as widget appears in several places, to fix the issue - info.plist, Build settings, General tab, other? The widget also appears in the 'Products' list along with the app. I am not sure if the widget should be there, and if not how to remove it from the 'Products' list, but still make it available in the app.
Posted
by
Post not yet marked as solved
1 Replies
143 Views
Has anyone been successful creating a widget configuration that uses any of the "Measurement" type parameters? I'm running into crashes in the Widget/Home Screen when I try to do so. I am building a widget that provides functionality to 'nearby' points of interest. I just discovered that SiriIntents support specifying a Measurement type now --> Distance. When I have my configuration "nearbyDistance" parameter type set to the measurement type of Distance, adding the widget from the widget gallery crashes it after I hit the add button and it doesn't get added. This works: This crashes the Widget Preview and doesn't add the widget to the Home Screen: Right before I add my widget, things seem to be good: As soon as I tap Add Widget, this happens: I have created a feedback for this and attached some recordings and a sysdiagnose: FB10002319
Posted
by
Post not yet marked as solved
3 Replies
476 Views
We have a bit of a complicated build process and need to build the Widget outside of our main app and repackage since we are using a cross platform framework. I tried scripting out updating my Widget's Marketing Version but agvtool won't update the MARKETING_VERSION in the project.pbxproj file. Therefore, we end up getting these emails from Apple: ITMS-90473: CFBundleShortVersionString Mismatch - The CFBundleShortVersionString value ‘1.2.2’ of extension ‘MyiOSApp.app/PlugIns/widgetExtension.appex' does not match the CFBundleShortVersionString value ‘1.2.3' of its containing iOS application ‘MyiOSApp.app'. I run this and it says it's updating in the Widget plist (but not the project.pbxproj) so when I build with xcode via command line it doesn't update and when we submit to the App Store we get the above message from Apple: /usr/bin/agvtool new-marketing-version $(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" ../My.Crossplatform.App/My.Crossplatform.App.iOS/Info.plist) Setting CFBundleShortVersionString of project ios to:    1.2.3. Updating CFBundleShortVersionString in Info.plist(s)... Cannot find "ios.xcodeproj/../YES" Updated CFBundleShortVersionString in "ios.xcodeproj/../widget/Info.plist" to 1.2.3 I've had to resort to manually updating then submitting every time. What is the correct way to update the MARKETING_VERSION in the project.pbxproj file in a CI environment using bash?
Posted
by
Post not yet marked as solved
0 Replies
145 Views
Hi, my App has two kind of widgets. On some iOS 15.4 and 15.4.1 devices, one widget works perfectly fine and another can't load data even in the Widgets Gallery. But for most devices the two widgets work both fine!!! My 15.4.1 iPhones and iPad can't reproduce the problem. The problematic widget only display a redacted view: The widget should look like: Both of the widgets use Core Data to fetch data and shared UserDefaults to get user settings. The problematic widget is a task calendar, so it has some data but not very large. I've try to collect crash log using TestFlight, but there's no crash logs. I've implemented placeholder getSnapshot and getTimeline in the widget's IntentTimelineProvider. I'm not using unwrap optionals in SwiftUI. It's frustrating. My users love this widget but can't use it. Any idea why this problem happen?
Posted
by
Post not yet marked as solved
0 Replies
117 Views
much like the notes app, would be it be some way to lock apps on a home screen pages from moving around unintentionally to another home screen? i’ve had several occasions where my phone screen apps get moved around by having the device in awkward positions or holding it a funny way (i.e getting out of a car in a tight space, while holding your phone). i’m not sure whether this is or is not a feature yet, but, any insight would be appreciated!
Posted
by
Post not yet marked as solved
0 Replies
129 Views
I am building an app with the WidgetKit extension (created using File > New > Target > Widget Extension). When I run the app scheme on my Mac, I can see my local app and add the widget in the widget sidebar using "Edit Widgets." However, when I build the app using the iOS scheme on my iPhone, I cannot add the widget to my phone, as it does not appear in the widget selection window. The app works perfectly fine and launches. I am using an iPhone 13 pro on iOS 15.4.1. Is this a recent bug? A couple of months ago on a different project, this was working.
Posted
by
Post not yet marked as solved
0 Replies
133 Views
So I was watching the WWDC video [Add configuration and intelligence to you widget] (https://developer.apple.com/videos/play/wwdc2020/10194) and it seemed like there Xcode automatically generated the IntentHandler.swift file. But I can't find the IntentHandler.swift file in my Xcode. Of course, I added Widget as target checking add intent configuration, and also added intent parameters too. What I am doing wrong here? Or is that I Xcode doesn't automatically generate IntentHandler.swift file ? Thanks
Posted
by
Post not yet marked as solved
0 Replies
176 Views
Our app added a widget extension. but some of devices can't search widget in Widget Gallery. We found workaround. Delete app Reboot device Install app Why does this happen? What's a better solution? Is this iOS bug? If iOS bug, please let know bug report link to us.
Posted
by
Post not yet marked as solved
0 Replies
197 Views
Hi, I am working on a widget for my existing Mac app. The problem I am running into is that when I add a Link from the widget to the main app, the method 'openURLs' isn't called at all: - (void) application: (NSApplication *)application openURLs:(NSArray<NSURL *> *)urls  So I'm not able to direct the app on how to best handle the widget tap. I'm trying to work around that by trying to detect if a Link was selected. Something like this could work Link("Test", destination: URL(string: "https://duckduckgo.com")!) .environment(\.openURL, OpenURLAction { url in print("---> testing link actioned") return .systemAction }) When I add this to the main app, it works fine. But when I add something like this to the widget, the completion handler isn't called (supposedly). Can someone confirm if this was supposed to work inside a widget? Or is it only something that works from the main app?
Posted
by
Post not yet marked as solved
0 Replies
241 Views
I have a CoreData database, and I have attempted to migrate it to an app group to share it between my main app and a widget extension. The database seems that seems to be fetched by the app and the widget seem to be completely separate from each other. My CoreData code (persistence.swift) import CoreData struct PersistenceController {   static let shared = PersistenceController()   static var preview: PersistenceController = {     let result = PersistenceController(inMemory: true)     let viewContext = result.container.viewContext     let newUserData = Userdata(context: viewContext)     newUserData.hourly = 15.3     let newSession = Session(context: viewContext)     newSession.id = UUID()     newSession.start = Date()     newSession.end = Date()     do {       try viewContext.save()     } catch {       let nsError = error as NSError       fatalError("Unresolved error \(nsError), \(nsError.userInfo)")     }     return result   }()   let container: NSPersistentContainer   init(inMemory: Bool = false) {     container = NSPersistentContainer(name: "FManger")     let storeURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.omaribrahim-uchicago.FManger")!.appendingPathComponent("FManger.sqlite")     var defaultURL: URL?       if let storeDescription = container.persistentStoreDescriptions.first, let url = storeDescription.url {         defaultURL = FileManager.default.fileExists(atPath: url.path) ? url : nil       }     if defaultURL == nil {         container.persistentStoreDescriptions = [NSPersistentStoreDescription(url: storeURL)]       }     container.loadPersistentStores(completionHandler: { [unowned container] (storeDescription, error) in         if let error = error as NSError? {           fatalError("Unresolved error \(error), \(error.userInfo)")         }         if let url = defaultURL, url.absoluteString != storeURL.absoluteString {           let coordinator = container.persistentStoreCoordinator           if let oldStore = coordinator.persistentStore(for: url) {             do {               try coordinator.migratePersistentStore(oldStore, to: storeURL, options: nil, withType: NSSQLiteStoreType)             } catch {               print(error.localizedDescription)             }             // delete old store             let fileCoordinator = NSFileCoordinator(filePresenter: nil)             fileCoordinator.coordinate(writingItemAt: url, options: .forDeleting, error: nil, byAccessor: { url in               do {                 try FileManager.default.removeItem(at: url)               } catch {                 print(error.localizedDescription)               }             })           }         }       })   } } My Widget data constructor and main function import WidgetKit import SwiftUI import Intents struct Provider: IntentTimelineProvider {       func placeholder(in context: Context) -> SimpleEntry {     SimpleEntry(date: Date(), data: .previewData, error: false, configuration: ConfigurationIntent())   }   func getSnapshot(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (SimpleEntry) -> ()) {     let entry = SimpleEntry(date: Date(), data: .previewData, error: false, configuration: configuration)           completion(entry)   }   func getTimeline(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {     var entries: [SimpleEntry] = []     @FetchRequest(       sortDescriptors:[NSSortDescriptor(key: "start", ascending: false)],       animation: .default)     var sessions: FetchedResults<Session>           if (sessions.count > 0) {       let checkedIn = sessions[0].end != nil       let totalMinutes = totalMinutes(sessions: sessions)       var auxMinutes = 0.0       if (checkedIn) {         auxMinutes = timeBetween(fromDate: sessions[0].start!, toDate: Date())       }               let currentDate = Date()       for i in 0 ..< 5 {         let entryDate = Calendar.current.date(byAdding: .hour, value: i, to: currentDate)!                   let cSession = fromMinutes(minutes: (Double(i) * 60) + auxMinutes)                   let widgetData = SimpleEntry.PayData(currentSession: cSession,                            grossTotal: totalMinutes * 15.3 + cSession,                            paycheckDay: Date() + (7 * 24 * 60 * 60),                            checkedIn: checkedIn)                   let entry = SimpleEntry(date: entryDate,                     data: widgetData,                     error: false,                     configuration: configuration)                   entries.append(entry)       }     }     else {       let entry = SimpleEntry(date: Date(),                   data: .error,                   error: true,                   configuration: configuration)       entries.append(entry)     }     let timeline = Timeline(entries: entries, policy: .atEnd)     completion(timeline)   } } @main struct Widgets: Widget {   let kind: String = "Widgets"   let persistenceController = PersistenceController.shared   var body: some WidgetConfiguration {     IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: Provider()) { entry in       WidgetsEntryView(entry: entry)         .environment(\.managedObjectContext, persistenceController.container.viewContext)     }     .configurationDisplayName("Pay Tracker")     .description("Check your current shift's earning, total earnings, and the date of your next payment in a glance.")   } } I am pretty sure I did something wrong, but what is it?
Posted
by