Post marked as Apple Recommended
My app, Class Clock, currently offers a Today Widget that displays a circular timer similar to the timer in iOS 13 and a few labels to show the user how much time is left in class. With the new WidgetKit, I understand the widget's timeline is only updated every so often. However, if the circular timer needs to load every minute, how can this be achieved? Could I perhaps tell the timeline that Class A is from 10 - 11 and the widget then animates between 10 and 11 on its own without calling a new timeline every minute? Ideally, the circular progress indicator would continue to animate its SwiftUI Circle trim percentage every second or minute.
Post not yet marked as solved
I'm trying to add a widget to my SwiftUI Application. I've made a Widget Extension in my App. Upon running the target in the simulator, this error appears in the console:
ClipperWidgetExtension[7343:594354] Fatal error: PlatformViewRepresentableAdaptor<ListRepresentable<SystemListDataSource<Never>, SelectionManagerBox<Never>>>: file /Library/Caches/com.apple.xbs/Sources/Chrono_Sim/Chrono-63.5/WidgetKit/SPI/WidgetViewArchive.swift, line 254
The line that Xcode brings my attention to is this:
completion(Timeline(entries: [SimpleEntry()], policy: .never))
The whole code for my timeline provider and entry:
struct Provider: TimelineProvider {
public typealias Entry = SimpleEntry
public func snapshot(with context: Context, completion: @escaping (SimpleEntry) -> ()) {
let entry = SimpleEntry()
completion(entry)
}
public func timeline(with context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
completion(Timeline(entries: [SimpleEntry()], policy: .never))
}
}
struct SimpleEntry: TimelineEntry {
var date: Date = Date()
}
Any help would be appreciated :)
Post not yet marked as solved
I'm trying to create an iOS 14 WidgetKit widget. It's compiling, but when I try to run it, on either simulator or device, I get the error below:
Any suggestions on how to debug this?
Details
SendProcessControlEvent:toPid: encountered an error: Error Domain=com.apple.dt.deviceprocesscontrolservice Code=8
"Failed to show Widget 'com.myapp.dev.WidgetKitExtension'
error: Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1
"Failed to get descriptors for extensionBundleID (com.myapp.dev.WidgetKitExtension)"
UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (com.myapp.dev.WidgetKitExtension)}."
UserInfo={NSLocalizedDescription=Failed to show Widget 'com.myapp.dev.WidgetKitExtension'
error: Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (com.myapp.dev.WidgetKitExtension)"
UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (com.myapp.dev.WidgetKitExtension)}.,
NSUnderlyingError=0x7fc0b0d12540 {Error Domain=SBAvocadoDebuggingControllerErrorDomain
Code=1 "Failed to get descriptors for extensionBundleID (com.myapp.dev.WidgetKitExtension)"
UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (com.myapp.dev.WidgetKitExtension)}}}
Domain: DTXMessage
Code: 1-
System Information
macOS Version 10.15.5 (Build 19F101)
Xcode 12.0 (17177)
Post not yet marked as solved
Any insights on how to incorporate CloudKit (or CoreData) in the WidgetKit extension? Where in the WidgetKit api do I make the asynchronous call to load the data to be available for the TimelineProvider?
Is there a problem with an app having more than one widget extension?
I previously had two 'Today View' extensions that I'm replacing but after installing the app on device with two widget extensions, I'm only seeing the second one in the widget picker.
I see that there's WidgetBundle but my two widgets have very different datasets so the timeline stuff won't mesh.
Post not yet marked as solved
Hey,
Is it possible to only offer a certain amount of widget functionality to users who have purchased an in-app purchase or are ongoing subscribers?
Thanks!
Post not yet marked as solved
Hi there
While developing a new widget with WidgetKit, my app crashes almost immediately every time I launch the extension with the error "[NSXPCDistantObject _nsxpingHost:]: unrecognized selector sent to instance"
Does anyone else have this problem? Is this due to the Xcode beta?
Thanks!
Post not yet marked as solved
Hi,
I am developing an app with CoreData + CloudKit and wanted my Widget to fetch data from CloudKit to display. Everything is working on iOS / watchOS, but on WidgetKit the result from my fetch is always empty.
I already configured the CloudKit capability on the Widget extension, then I am creating a new NSPersistentCloudKitContainer the and on
public func timeline(with context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
I am trying to
let cardsFetch = NSFetchRequest<Card>(entityName: "Card")
do {
let cards = try persistentContainer.viewContext.fetch(cardsFetch)
the result is always 0 and the same fetch on iOS returns the data.
Is this supposed to work?
Let me start by saying, it wouldn't surprise me if all of the following is user error. 🙃
I'm trying to write a Widget using WidgetKit, where the widget extension itself is querying the HealthKit database. The host app definitely has HealthKit authorization, but I'm not clear how to do the same for the extension.
I did add the requisite Info.plist entry in the widget extension, which cleared my first error. However, when I do my normal prompt for auth — the same one I use in my main app — I see this in the console:
2020-07-10 14:13:39.035757-0400 BodyWidgetExtension[988:337871] [auth] FAILED prompting authorization request to share (
), read (
HKQuantityTypeIdentifierStepCount
)
This leads me to think this isn't my fault, but, perhaps I've missed the plot.
Any pointers/experience from anyone that's done this before?
Thank you!
In the OC project, iOS14 WidgetKit target was added, but consistent error
Cannot find type "ConfigurationIntent" in scope,
type 'Provider' does not conform to protocol 'IntentTimelineProvider'
What is strange is that after adding a new OC project, the compilation is successful,
Tool: Xcode12-beta & Simulator
How to get access to old projects?
While working through Part II the Widget code-along from WWDC, I thought I would add a separate preview for each size, just as an exercise for myself.
static var previews: some View {
Group {
EmojiRangerWidgetEntryView(entry: SimpleEntry(date: Date(), configuration: ConfigurationIntent(), character: .panda))
.previewContext(WidgetPreviewContext(family: .systemSmall))
EmojiRangerWidgetEntryView(entry: SimpleEntry(date: Date(), configuration: ConfigurationIntent(), character: .panda)) .previewContext(WidgetPreviewContext(family: .systemMedium))
}
}
}
This works, giving me two previews of the correct size. Unfortunately, the smaller preview is trying to layout the medium's view within its given space.
I'm assuming that this is because the @Environment for the widgetFamily wasn't configured correctly, so I thought I'd add it like this:
.environment(\.widgetFamily, .systemSmall)
I was guessing that something like this might be possible, because I have seen a similar situation where a preview is created for a dark mode like this:
.environment(\.colorScheme, .dark)
Alas, my attempt to set the widgetFamily environment doesn't work. It gives me a this error:
Key path value type 'WritableKeyPath<EnvironmentValues, WidgetFamily>' cannot be converted to contextual type 'KeyPath<EnvironmentValues, WidgetFamily>'
Am I close? Is there some way to inject the widget family environment, or is there a bug that fails to bind the WidgetPreviewContext(family: .systemSmall) that I'm already passing?
Post not yet marked as solved
I want a widget to use the same custom fonts that the containing app uses. I do not want multiple copies of the font files in the app bundle. I put the font files into a framework shared by the app and the widget extension. I have code to register the fonts from the framework bundle using CTFontManagerRegisterGraphicsFont. That works from the app, but it does not work from the widget extension because it requires UIKit. (At least I think that's why it doesn't seem to work from my widget extension.)
Widgets cannot run UIKit code. Is there a way to programmatically register the fonts in a widget? If not is there a way I can make a UIAppFonts Info.plist entry point to a framework?
Post not yet marked as solved
Have been working on a SwiftUI widget for WidgetKit, and, after updating to beta 3, at some point, started getting this error:
Cannot preview in this file—"widget.appex" is an unsupported extension
The details say: UnknownAppExtensionError: "(widget).appex" is an unsupported extension. Previews cannot be hosted in the app extension "widget.appex"
Has anyone seen this before? The widget had been previewing fine, and it builds and runs to simulator just fine.
I have noticed a strange problem today. I have uploaded a build of my app to TestFlight for internal testing using Xcode 12 beta 3. The app has widgets and if I run the app locally from Xcode widgets are working on device.
However, when I install a beta from TestFlight the widgets are not suggested by iOS and I can see in the logs that the widgets are actually crashing (something is going on with WidgetKit in the crash logs).
This has started only with beta 3, I have previously used TestFlight with widgets in beta 1 and beta 2.
Does anyone else have this problem? My feedback number is FB8122742.
Hi,
I've been working on a Widget Extension which works great locally (when installed via Xcode) but it crashes when distributed via TestFlight. Most of the crashes occur at WidgetExtensionContext.getDescriptors(completion:)
Here's the crash log:
0	 WidgetKit										 0x00000001e556952c closure #1 in WidgetExtensionContext.getDescriptors(completion:) + 208 (WidgetExtensionContext.swift:85)
1	 WidgetKit										 0x00000001e55694ac closure #1 in WidgetExtensionContext.getDescriptors(completion:) + 80 (WidgetExtensionContext.swift:85)
2	 WidgetKit										 0x00000001e55688dc thunk for @escaping @callee_guaranteed () -> () + 28 (<compiler-generated>:0)
3	 libdispatch.dylib						 0x00000001a4aac410 _dispatch_call_block_and_release + 32 (init.c:1454)
4	 libdispatch.dylib						 0x00000001a4aadf08 _dispatch_client_callout + 20 (object.m:559)
5	 libdispatch.dylib						 0x00000001a4abb480 _dispatch_main_queue_callback_4CF + 836 (inline_internal.h:2548)
6	 CoreFoundation								 0x00000001a4d8e634 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 16 (CFRunLoop.c:1790)
7	 CoreFoundation								 0x00000001a4d88c34 __CFRunLoopRun + 1940 (CFRunLoop.c:3118)
8	 CoreFoundation								 0x00000001a4d88090 CFRunLoopRunSpecific + 564 (CFRunLoop.c:3242)
9	 Foundation										 0x00000001a5124310 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 232 (NSRunLoop.m:374)
10	Foundation										 0x00000001a5156d68 -[NSRunLoop(NSRunLoop) run] + 92 (NSRunLoop.m:399)
11	libxpc.dylib									 0x00000001a4a0a6ac _xpc_objc_main + 688 (main.m:265)
12	libxpc.dylib									 0x00000001a4a0c984 xpc_main + 180 (init.c:1198)
13	Foundation										 0x00000001a5159068 -[NSXPCListener resume] + 316 (NSXPCListener.m:448)
14	PlugInKit										 0x00000001b44658a0 -[PKService run] + 424 (PKService.m:186)
15	PlugInKit										 0x00000001b44654e0 +[PKService main] + 576 (PKService.m:115)
16	PlugInKit										 0x00000001b4465cac +[PKService _defaultRun:arguments:] + 24 (PKService.m:233)
17	ExtensionKit									 0x00000001e77f7d8c EXExtensionMain + 84 (EXExtensionMain.m:23)
18	Foundation										 0x00000001a52a02b8 NSExtensionMain + 200 (NSExtensionMain.m:13)
19	libdyld.dylib								 0x00000001a4c13f08 start + 4
I've seen multiple reports about the 3rd party widgets not appearing for TestFlight builds in the PB3, but I am not sure if this is related.
What can I do to solve this? Thank you!
Post not yet marked as solved
The iOS 14 battery widget has blur.
But if you implement them yourself in WidgetKit, you'll get 🚫 on a yellow background.
How should I implement it?
struct VisualEffectView: UIViewRepresentable {
var effect: UIVisualEffect?
func makeUIView(context: UIViewRepresentableContext<Self>) -> UIVisualEffectView { UIVisualEffectView() }
func updateUIView(_ uiView: UIVisualEffectView, context: UIViewRepresentableContext<Self>) { uiView.effect = effect }
}
struct BackgroundSunView : View {
var body: some View {
VisualEffectView(effect: UIBlurEffect(style: .dark))
.edgesIgnoringSafeArea(.all)
}
}
struct WidgetKitEntryView : View {
var body: some View {
ZStack {
BackgroundSunView()
VStack {
Text("Hello")
}
}
}
}
When I develop My WidgetKit Extension,I set some breakpoints for my code In the App Target And Extension Target ,It don't work,Who can help me solve this problem? Thank you!
Post not yet marked as solved
The clock widget is capable to show world time but some timezones are shown in dark and some in bright coloured clocks. My guess is that if its night time in that timezone it turns dark and when its daytime it turns light however even at 9AM in Canada or 8 AM in Chicago it shows dark.
Any reasons?
Post not yet marked as solved
I am trying to display the default implementation of the widget in the xcode 12 beta 3 and beta 4, if I create a new project, the widget is displayed successfully, but in the project of our company, after a successful build, the simulator starts and after nothing happens. I don't see any difference in the codebase of the widget classes.
Also the preview doesn't work for me, I get the following error:
RemoteHumanReadableError
ProcessError: Failed to launch widget extension: The operation couldn’t be completed. (Foundation._GenericObjCError error 0.)
But if I create a project from scratch, then the preview works well.
Post not yet marked as solved
we have only analog widget when are you guys going to add Digital clock widget? And why dont you add some cool digital clock faces for iwatch?
phone gets hot sometimes i am on ios 14 beta 4.
there are issues with correct time and weather information. When are you going to fix that?