Watch Complications

RSS for tag

Display timely and relevant information about your app on the Apple Watch face using Complications.

Complications Documentation

Posts under Watch Complications tag

54 Posts
Sort by:
Post not yet marked as solved
1 Replies
268 Views
TLDR; Can I have a widget without a Timeline? My previous watch app had a complication. Simply so it can be added to the watch face for a quick launch of the app. However now seeing that method is deprecated in favour of widgets. Can I add a widget without the need for all the Timeline as all I want is a button on the watch face to launch into my app. No data is updated over time so no need for all the extra timeline code.
Posted
by RyanTCB.
Last updated
.
Post not yet marked as solved
0 Replies
85 Views
I'm building complications using WidgetKit and SwiftUI. The complications work, but the previews don't appear right away when applying the .watchface. How can I ensure the complication previews show up immediately when a user adds the watch face? Any guidance is appreciated.
Posted Last updated
.
Post not yet marked as solved
1 Replies
494 Views
Hey there, I'm implementing Watch Complications in an existing project, and I'm having the problem that transferCurrentComplicationUserInfo(_:) works exactly as transferUserInfo(_:) is described in the documentation, but not as it should. That is, when the WatchApp is opened, func session(_ session: WCSession, didReceiveUserInfo userInfo: [String: Any] = [:]) receives the data sent by transferCurrentComplicationUserInfo(_:). If not, the data is queued until the Watch App is opened again. In other words, transferCurrentComplicationUserInfo(_:) never wakes up the ExtensionDelegate when the Watch App is not running. Has anyone experienced the same thing and know how to fix it? More details: Testing on iPhone 11 (iOS 17.1.2) and Apple Watch SE (WatchOS 10.2) I made sure that the quota of 50 is not exhausted when I test. The WatchApp is still dual-target (I want to avoid having to migrate to single-target and SwiftUI lifecycle) Watch App code: class ExtensionDelegate: NSObject, WKExtensionDelegate, WCSessionDelegate { let session = WCSession.default override init() { super.init() if WCSession.isSupported() { session.delegate = self session.activate() } } func session(_ session: WCSession, didReceiveUserInfo userInfo: [String: Any] = [:]) { WatchWidgetSessionHandler.shared.processComplicationUserInfo(userInfo) } } IOS App code: class WatchAppDataManager: NSObject, WCSessionDelegate { override init() { super.init() let session = WCSession.default session.delegate = self session.activate() } func sendDataToWidget(for kinds: [WatchWidgetKind]) async { guard WCSession.default.activationState == .activated, WCSession.default.isComplicationEnabled else { return } let widgetsData = dataProvider.getData(for: kinds) if !widgetsData.isEmpty { WCSession.default.transferCurrentComplicationUserInfo(widgetsData) } } }
Posted Last updated
.
Post not yet marked as solved
8 Replies
796 Views
Hello! I'm working on the watchOS app that provides user with multiple fancy complication sets. There are about 50 widgets in our WidgetBundle now. With this amount we reached memory limit and the app crashes: Thread 1: EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded) (limit=15 MB) I inspected complicationExtension.appex content and find out that most volume is occupied by the executable: Localized strings (12 langs) altogether - 165 KB Assets.car - 1.1 MB Imported fonts TTF files altogether - 866 KB complicationsExtension executable file - 8.2 MB Why it takes so much space and how can it be made smaller?
Posted
by kelin.
Last updated
.
Post not yet marked as solved
2 Replies
387 Views
We have an IOS app and its watch extension. The watch extension having complications as well created with clockKit Also we are providing a watch face with our custom complications for the user. Everything working fine watch series 6 and above Now we have an issue reported by a customer in watch series 3 (the watch Os version in 8.8), in which the watch face is not able to add as it showing the error "Watch Face Unavailable" So when we tried to create a another watch face for watch series 3, the complication list on the watch extension as well as the watch app of iPhone are not listing our app name Because of this issue we can't create a custom watch face for the watch series 3 with our complications So why the watch app in iPhone is not listing our watch app name in the list of complications Please update if anyone having similar issues
Posted Last updated
.
Post not yet marked as solved
2 Replies
1.3k Views
I’ve created a single-target watchOS app in Xcode 14, but I can’t seem to get ClockKit complications working. I’ve added a CLKComplicationDataSource class to my watch target, and in the Info pane for my target I have set the CLKComplicationPrincipalClass key to MODULE-NAME.ComplicationController I haven’t yet added Complication placeholder images to my Assets.xcassets, but as far as I am aware, that shouldn’t be a problem while I am still testing. However, when I run it on a watchOS simulator, the complications never show up on the watch complications list when adding a complication. All of the tutorials I can find for ClockKit complications reference older two-target WatchKit apps. Do the newer single target apps no longer support ClockKit? If so, how can I make a two-target WatchKit app with Xcode 14? Unfortunately I cannot use WidgetKit for my complications because I need to support watchOS 7 at least, and WidgetKit only supports watchOS 9+ Thanks for your help
Posted
by AlwardK.
Last updated
.
Post not yet marked as solved
0 Replies
301 Views
I'm in process of reimplementing my app in SwiftUI and WidgetKit. So far so good, I really like that I can finally use SwiftUI views for widgets. However, I'm having issues with AccessoryInline widget on Utility watch face. My old UtilitarianLarge complication displays in full color, but AccessoryInline widget displays only in gray - it's not even widgetAccentable on Utility watch face. I receive widgetRenderingMode from the Environment, and it shows fullColor. However, no matter how I try to apply color to the image or text, both stay gray. This widget family is not documented well (as many of things in WatchOS), and Google/ChatGPT/Bing produced zero usable results. It looks like it's a bug in WIdgetKit. If it's supposed to be displayed in Accented mode only, it should report as such in widgetRenderingMode (and support WidgetAccentable). Otherwise it should display in full color, just like the old complication.
Posted
by Eugr.
Last updated
.
Post not yet marked as solved
0 Replies
565 Views
When connecting my iphone (14pro with iOS 17.2.1) with a paired apple watch (series 9 with OS 10.3), it is not showing up on the devices/simulators list in xcode 15.1. Beyond unpairing/repairing the watch, restarting either iphone or watch, connecting/disconnecting the iphone from the computer or deleting xcode and re-installing xcode, any other suggestions? Under the WatchApp field it shows "no eligible device connected", however, under the console the Apple Watch does appear. I have tried just about everything and can't get the watch to appear in Xcode. I am running all this on a MacBook Pro with Sonoma. Thanks for any assistance!
Posted
by jarns.
Last updated
.
Post not yet marked as solved
2 Replies
618 Views
I can't get the simplest Widget to work. I simply want to present the app's icon. It does what it's supposed to do in the simulator but on the actual device it only says "Please adopt containerBackground API" at the place where the Widget would have shown otherwise. I found out that I am supposed to add .containerBackground(Color.clear, for: .widget) for no reason at all to make this work. However, when I do that, I just get a gray circle where the app icon was supposed to show. The png files should be fine because again on the simulator it works so I have no idea what I am doing wrong. If someone can tell me what I'm doing wrong or if someone can share their Widget class that would be awesome - I literally only want to show my app's icon on the Watch face but I already fail at that, no idea why they made WidgetKit impossible to work with. import SwiftUI import WidgetKit struct IconEntry: TimelineEntry { let date = Date() let icon: Image } struct IconProvider: TimelineProvider { func placeholder(in context: Context) -> IconEntry { return IconEntry(icon: getImageForContext(context, color: false)) } func getSnapshot(in context: Context, completion: @escaping (IconEntry) -> ()) { let entry = IconEntry(icon: getImageForContext(context, color: false)) completion(entry) } func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> ()) { let entry = IconEntry(icon: getImageForContext(context, color: false)) let timeline = Timeline(entries: [entry], policy: .never) completion(timeline) } } struct IconWidget: Widget { let kind: String = "IconWidget" var body: some WidgetConfiguration { StaticConfiguration(kind: kind, provider: IconProvider()) { entry in IconView() .containerBackground(Color.clear, for: .widget) } .supportedFamilies([.accessoryCircular, .accessoryCorner, .accessoryRectangular]) .description(Text("Show the app's icon on a watch face.")) } } struct InlineWidget: Widget { var body: some WidgetConfiguration { StaticConfiguration(kind: "Inline", provider: IconProvider()) { entry in Text("App Title") .containerBackground(Color.clear, for: .widget) } .configurationDisplayName("App Title") .description("Description") .supportedFamilies([.accessoryInline]) } } func getImageForContext(_ context: TimelineProviderContext, color: Bool) -> Image { var fileNameToUse = "iconColor.png" if(!color) { fileNameToUse = "iconAlpha.png" } let displaySize = context.displaySize if(displaySize.width == 0 || displaySize.height == 0) { return Image(uiImage: .init()) } let uiImage = UIImage(imageLiteralResourceName: fileNameToUse).resizeImage(width: displaySize.width, height: displaySize.height) let image = Image(uiImage: uiImage) return image } struct IconView: View { @Environment(\.widgetRenderingMode) var widgetRenderingMode var body: some View { imageFor(widgetRenderingMode) .resizable() .onAppear { print("ICON VIEW \(widgetRenderingMode == .fullColor ? "COLOR" : "ALPHA")") } .containerBackground(Color.clear, for: .widget) } } private func imageFor(_ widgetRenderingMode: WidgetRenderingMode) -> Image { switch widgetRenderingMode { case .fullColor: return Image(uiImage: UIImage(imageLiteralResourceName: "iconColor.png")) default: return Image(uiImage: UIImage(imageLiteralResourceName: "iconAlpha.png")) } } @main struct IconBundle: WidgetBundle { @WidgetBundleBuilder var body: some Widget { IconWidget() InlineWidget() } } extension UIImage { func resizeImage(width: CGFloat, height: CGFloat) -> UIImage { let edgeLength = min(width, height) let newSize = CGSize(width: edgeLength, height: edgeLength) UIGraphicsBeginImageContextWithOptions(newSize, false, 0.0) self.draw(in: CGRect(x: 0, y: 0, width: newSize.width, height: newSize.height)) if let resizedImage = UIGraphicsGetImageFromCurrentImageContext() { UIGraphicsEndImageContext() return resizedImage } else { return UIImage() } } }
Posted
by Watcher03.
Last updated
.
Post not yet marked as solved
1 Replies
554 Views
The modular ultra watchface ignores the font type I set in my complication. Happens in simulator and on device (see screenshots). I set the font via: .font(.system(size: CGFloat(self.fontSize), weight: self.fontWeight, design: .monospaced)) Can you please help? Is this as designed or a bug? I really a monospaced font in that place. Thanks! Correct: Wrong:
Posted Last updated
.
Post not yet marked as solved
0 Replies
471 Views
I'm seeing problems with the new Apple Watch Modular Ultra Watch face... This is all using the latest WatchOS 10.1 and with WidgetKit complications. (Have also tested with the new WatchOS 10.2 beta in the simulator) The Graphic Circular (accessoryCircular) complications space the numbers differently sometimes causing maximum and minimum numbers to look like one long number (see small circular complications in screenshot) The exact same complication in the accessoryRectangular on the Modular Ultra face clips text when it doesn't on any other watch face I've filed feedback FB13344580 Hopefully the screenshots show the issue well.
Posted Last updated
.
Post not yet marked as solved
2 Replies
463 Views
I am trying to add Widget Complications to an existing Apple Watch app. I added the WatchOS widgets extension and followed instructions to create static, non-updating complications to merely launch the app from the watch home screen. Here is my code in the widget extension: import WidgetKit import SwiftUI struct Provider: TimelineProvider { func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> Void) { } func getTimeline(in context: Context, completion: @escaping (Timeline<SimpleEntry>) -> Void) { } func placeholder(in context: Context) -> SimpleEntry { SimpleEntry(date: Date()) } func snapshot(in context: Context) async -> SimpleEntry { SimpleEntry(date: Date()) } } struct SimpleEntry: TimelineEntry { let date: Date } struct TrapScores_WidgetsEntryView : View { @Environment(\.widgetFamily) var widgetFamily var entry: Provider.Entry var body: some View { switch widgetFamily { case .accessoryCorner: ComplicationCorner() case .accessoryCircular: ComplicationCircular() case .accessoryRectangular: Text("TrapScores") case .accessoryInline: Text("TrapScores") @unknown default: //mandatory as there are more widget families as in lockscreen widgets etc Text("AppIcon") } } } @main struct TrapScores_Widgets: Widget { let kind: String = "TrapScores_Complications" var body: some WidgetConfiguration { StaticConfiguration(kind: kind, provider: Provider()) { entry in TrapScores_WidgetsEntryView(entry: entry) .containerBackground(.fill.secondary, for: .widget) } .configurationDisplayName("TrapScores") .description("This will launch TrapScores App") .supportedFamilies([.accessoryCorner, .accessoryCircular]) } } struct ComplicationCircular: View { var body: some View { Image("Graphic Circular") .widgetAccentable(true) .unredacted() } } struct ComplicationCorner: View { var body: some View { Image("Graphic Circular") .widgetAccentable(true) .unredacted() } } #Preview(as: .accessoryCircular) { TrapScores_Widgets() } timeline: { SimpleEntry(date: .now) } The complications appear fine in the preview: The complication can be added to the watch face, but no graphic comes with it and it is a blank circle: Any suggestions on what I'm doing wrong?
Posted
by WilburDD.
Last updated
.
Post marked as solved
2 Replies
735 Views
2 years ago using Xcode 13, I created a phone app with a companion Watch app and it worked fine. This past month using Xcode 15, I created a new phone and companion app and everything is working with the following exception. From Xcode, my new app installs on the phone and watch, but my Watch app doesn't show up in the list of apps you can use as a launch complication on one of your watch faces. The app does show up in the launch screen for apps installed on the watch, so I assume the watch icon is generated properly. I started out using a single 1024x1024 app icon so I thought maybe I needed to create all variations of the icon before I'd see them as a complication option. I created all variations and loaded them in the Appicon asset. Still no luck. the one major difference between my Xcode 13 and Xcode 15 projects is the 15 project includes one watch app, where the 13 project includes the watch app and a WatchKit extension. my understanding is Xcode 14 and 15 don't use WatchKit Extension. So... what do I need to do to be able to add my Xcode 15 watch app icon to a watch face so I can launch the app from there?
Posted
by Weecabin.
Last updated
.
Post not yet marked as solved
1 Replies
519 Views
I'm developing my app for WatchOS 10 with Xcode 15.0.1. I'm trying to make a complication with WidgetKit (SwiftUI) to make it easier the user to launch the app. I'm using a simple and small image 50x50px to test it first. But when I try to add to the Watch Face, it show a gray circle like there is nothing there. But when i'm editing the Watch Face it show the image :/, like the image bellow: And another problem is when is Accent mode, it fills the image with a gray color, as the image above shows it. I tryed to add monochrome png image with the alpha-channel, but even that didn't worked too. And my code is simpler has that: var body: some View { Image("Cat") } Someone is facing this same problem? Has any possible solution.
Posted
by targon.
Last updated
.
Post not yet marked as solved
3 Replies
1.7k Views
I’m trying to create complications für the Watch using the new WidgetKit. While the complications do show up fine in the preview in Xcode and also in the Simulator, on a real device the complications do never shown anything. The complications are listed and can be selected in the watch face settings, but the preview is always black, and when added to a watch face, it shows nothing. I can tap on this „nothing“ and the App launches, so the complication is actually there. But it doesn’t show anything. This is also true for the Watch App on the iPhone, which lets me add the complications to a watch face, but it also shows nothing. But in the Simulator everything works as expected, the complications show their content just fine. So it looks like the code is fine. The iPhone runs the iOS 16.1, and the watch runs watchOS 9.1 (right now the latest public releases) Does anyone having the same issue and maybe a solution or a hint, what exactly I should check?
Posted Last updated
.
Post not yet marked as solved
2 Replies
466 Views
Just finalising some work on my app update, and it seems that when you go to select an item to show in a complication, when you select your app in the list, the subsequent list only shows 15 of your items. If a user of my app has transferred 20 items to their Watch, they can't select five of them to be shown in a complication. Is that right? If that's a hard limit then I need to be able to separate them out into bunches of 15 items, or maybe have them display under A-E, F-J etc. Does this have to be done as a separate Widget in the WidgetBundle? And how do I do that? Given that I currently have one widget in that bundle that should show everything (20 items), how would I split it out to show an "A-E" widget with those items beginning with A...E? Do I have to have an A-E widget with its own set of data?
Posted
by darkpaw.
Last updated
.
Post not yet marked as solved
1 Replies
456 Views
I'm trying to find the best way to reload my Widgets and Complications. My App tries to show the current status vehicles. It gets the data using an API. And you don't know when this status changes. So I need to know when it makes sense to reload the widgets and complications. Here is a quote from the documentation: A widget’s budget applies to a 24-hour period. WidgetKit tunes the 24-hour window to the user’s daily usage pattern, which means the daily budget doesn’t necessarily reset at exactly midnight. For a widget the user frequently views, a daily budget typically includes from 40 to 70 refreshes. This rate roughly translates to widget reloads every 15 to 60 minutes, but it’s common for these intervals to vary due to the many factors involved. This is by far the worst "definition" if ever seen :( There is a 24 period, but you don't know when it starts and you don't know how much max refreshes you have and you also don't know how many refreshes you have left. How should someone develop a good solution with such a "definition"? So, I would like to know how you handle this? Perhaps a Apple engineer could light me up here :)
Posted
by Urkman.
Last updated
.
Post not yet marked as solved
2 Replies
1.1k Views
Hello, I try to add a couple of Complications to my App. Most of the Complications needs to be Configurable, so I use an IntentConfiguration for them. I use this recommendations function to create my complications.     func recommendations() -> [IntentRecommendation<ConfigurationIntent>] {         var recommendations = [IntentRecommendation<ConfigurationIntent>]()        for vehicle in vehicleStatusList {             let intent = ConfigurationIntent() intent.vehicleItem = VehicleItem(identifier: vehicle.id, display: vehicle.name)             recommendations.append(IntentRecommendation(intent:  intent, description: vehicle.name))         }         return recommendations     } But with this I get the result from the screenshot... How can I change this to get a better User Experience? When I click one item in the List, I get a correct Complication. But it would be nice to have a change to name them correctly... The first in the List is a StaticConfiguration...
Posted
by Urkman.
Last updated
.
Post not yet marked as solved
0 Replies
486 Views
Prior to watchOS10, I marked a view that I want to hide sensitive information when not being worn by using .privacySensitive() This had been working just fine. Comes watchOS10, this doesn't work anymore. Even with this simple code Text("TEST Privacy") .containerBackground(for: .widget) { Color.black } .privacySensitive() The text view is displayed even when not being worn. Has anyone experienced this? It seems like a bug to me. Any workaround? Thank you.
Posted
by Boonyawat.
Last updated
.