Post not yet marked as solved
I'm currently working with complication using widgetkit for watchOS.
When I select complication from Watch app in iPhone, The complication does not show content. In complication gallery, untitled complication is selecting. But when I select complication from watch, it's OK.
This bug occurs in both real device and simulator. But it happen in some pair.
Example:
watch ultra (os 10.4) pair with iPhone 14 pro (os 17.0): NG
watch ultra (os 10.4) pair with iPhone 14 pro (os 16.1): NG
watch ultra (os 10.0) pair with iPhone 14 pro (os 17.0): OK
I tried create simple project to check this bug. But this bug still occurs
This is sample project: Github
Post not yet marked as solved
Is there a bug in this beta version that causes complications show placeholders only. This problem does not exist for watchOS 1.4
Post not yet marked as solved
如何自定义开发表盘模版,不是表盘组件,比如设置背景图片,调整各个表盘组件的位置
Post not yet marked as solved
手表系统: 10.2
表现:从手机Watch App上看,表盘组件部分都显示关闭;从手表上看,表盘组件不展示
Post not yet marked as solved
I recently raised this post explaining how I couldn't seem to get watchOS 9 complications to work, and I've figured out a partial fix.
The original post details the issues with complications - and some are still valid - but this fix applies to both my complications and Home Screen / Lock Screen widgets.
I was following the various WWDC 2020/2022 videos and the Emoji Rangers sample code, adding bits here and there, and assuming they were completely valid. Sadly, this bit of code in the widget's dynamic intents IntentTimelineProvider getTimeline really just banjaxed everything:
// Create entries for one day, 15 minutes apart
let currentDate = Date()
for minuteOffset in stride(from: 0, to: 60 * 60 * 24, by: 15) {
let entryDate = Calendar.current.date(byAdding: .minute, value: minuteOffset, to: currentDate)!
entries.append(EventEntry(date: entryDate, event: event))
}
If I remove that, and generate a different timeline with specific dates and times (for example: now, in 10 mins, in 2 hours, in a day, etc.) the complications appear correctly, as do Home Screen and Lock Screen widgets.
The outstanding issues with complications are:
The previews all use the same data, but getSnapshot() is supposed to return the data specific to that event from the configuration, i.e. if let theId = configuration.event?.identifier. "Christmas" is correct, but "Gallery Opening" is using Christmas's data.
Once I've selected the event I want to use in a complication the edit screen shows it as totally blank, not even a placeholder:
I hope this little fix works for you guys. And, if you know how to fix the above issues, let me know.
(iOS 16.1 beta 1, Xcode 14.1 beta 1)
Post not yet marked as solved
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.
Post not yet marked as solved
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.
Post not yet marked as solved
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)
}
}
}
Post not yet marked as solved
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?
Post not yet marked as solved
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
Post not yet marked as solved
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
Post not yet marked as solved
How to develop Complications for Watch 8.0 and earlier in Xcode 15
Post not yet marked as solved
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.
Post not yet marked as solved
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!
Post not yet marked as solved
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()
}
}
}
Post not yet marked as solved
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:
Post not yet marked as solved
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.
Post not yet marked as solved
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?
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?
Post not yet marked as solved
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.