Is there a way to migrate WidgetKit extensions made using dual-target watchOS apps to single-target apps? When you create a widget extension with a dual-target app, the bundle identifier includes the extra extension domain (com.company.app.watchkitapp.watchkitextension.widgets). When Xcode 15 migrates a dual-target to single-target, it removes “.watchkitextension” from both the watchOS app bundle identifier and the widget extension bundle identifier. watchOS seems to handle migrating the main app just fine, but any complications created with the dual-target do not get migrated and are just blank until the user re-configures, which would be a huge bummer to have to ship. If I try to manually set the bundle identifier back to include “.watchkitextension”, the OS rejects the installation because of the extraneous dot after the parent app’s prefix.
WatchKit
RSS for tagBuild apps that leverage watchOS features like background tasks, extended runtime sessions, and access to the Digital Crown using WatchKit.
Posts under WatchKit tag
132 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I currently own an Apple Watch SE2 device.
However, when I try to debug from the watch to the actual device, the connection loss issue occurs all too often.
Once the connection is lost, it continues to try to connect in the Disconnected list on the Xcode "Devices and Simulators" screen and is in a loading state.
Very often, even when the connection is established and you are trying to start debugging, it drops out.
Xcode cannot debug properly on the actual device.
I later found out that the Apple Watch SE2 does not support 5.0 Hz Wi-Fi, only 2.5 Hz.
I think that might be the cause.
Is this phenomenon less likely to occur if you debug on an actual device such as a regular Apple Watch 7/8/9 or Ultra model?
In fact, if debugging is difficult with the Apple Watch SE model, I am wondering whether I should purchase an additional Apple Watch.
Or is there another way to improve this issue?
It would be nice if the Apple Watch could be debugged by connecting it to a Mac with an actual cable like the iPhone.
I am wondering if there is a way to disable and enable network debugging in Xcode.
In the past, debugging the watch using only Bluetooth with the iPhone in Xcode seemed to be more stable.
Except for the Watch, the iPad doesn't have any major issues with Wi-Fi debugging on the iPhone.
Hi,
I am new to MAC development and not sure if this is possible at all, but I would like to test how my app reacts to NSWorkspaceWillSleepNotification and NSWorkspaceDidWakeNotification events. So I want to setup googletest which will:
initialize my own stuff
from another thread send an event to my tested code that will make it "think" system will go to sleep
perform "OnSleep" logic
after some time, from another thread, mimic wake event
detect in tested code I am awaken and check if my code works ok
Additionally, if there are multiple handlers registered to sleep/wake events - did they all get executed (I guess - yes) and in which order (in order of registration)?
Many thanks in advance
There's another thread on here with similar Q but seems to have no resolution. So starting my own.
The basics
Xcode 15.3.0 beta 3
iOS 17.4
The WatchOS 10.4
I have an iPhone app with a companion watch app. In Xcode if I set the scheme to my iOS app it installs on my phone but the companion watch app does not auto install on my watch. Automatic App Install is turned on in Watch app on iPhone. To run the app on watchOS I have to run it directly from the watch scheme on Xcode. If I delete the app from the watch then go into the iOS watch app on the iOS device to install on my watch I receive an error "This app could not be installed at this time"
Is there a known cause solution?
I am developing issuer non-UI extension. In function status i have to return remotePassEntriesAvailable (boolean) and to do that i have to activate WCSession from that Extension to get the remoteSecureElementPasses which are already added to the remote wallet (watch).
I have implemented WCSessionDelegate inside the non-UI extension but i can not enable the WCSession. I always get:
Error: WCSession has not been activated
I saw a comment in this post -> WCSession is not available from iOS extensions, only from the main iOS app.
To the point... If the WCSession is not available from iOS extensions how can I properly set remoteSecureElementPasses and implement function remotePassEntries if i can't connect to the watch to see which cards are already enrolled?
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
watchOS 10.4 Beta2 (21T5196d) broke its browser component! You can send youtube.com to your Apple Watch via iMessage, and then open it! Everything worked fine in the official version of watchOS 10.3; you couldn't watch videos because the Apple Watch's WebView doesn't have a video component, but you could at least browse web pages normally.
However, in watchOS 10.4, WebView is completely broken, and you can't even view the homepage recommendations or try searching for content properly — web pages refresh automatically within seconds and keep crashing repeatedly. Please revert everything back to the state of watchOS 10.3!
The minimal demonstration link to reproduce this bug:
https://ling-bucket.oss-cn-beijing.aliyuncs.com/apple/minimalVideo.MOV
My watch APP needs to keep Bluetooth connected with peripherals whether it is in the foreground or background, but the results of my test show that the connection in the background is very unstable, sometimes you can keep the Bluetooth on for a day, but sometimes it will be disconnected 50 times a day, and every time it is disconnected, I will immediately initiate a reconnection, it is certain that there is no problem with the peripheral Bluetooth, because I have another iOS device that has been stably connected to the peripheral, I want to know what causes this instability, and if there is any solution, if someone can provide relevant advice, I will be very grateful
How to develop Complications for Watch 8.0 and earlier in Xcode 15
I have paired two iWatch,the app in the second one can not have a reachable session with iPhone app
Xcode 15
iPhone 13 pro 17.1.2
iWatch S9 10.1
iWatch S9 10.1.1
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?
Errors:
''Invalid info.plist key. The key 'NSHealthShareUsageDescription''
''Invalid info.plist key. The key 'NSHealthUpdateUsageDescription''
The app works fine when I just run it on hardware without deployment, but as soon as I try to distribute it, this shows up.
The keys above are both defined and described in my App and extensions lists, so what's wrong?
I have a Watch companion app. The SwiftUI previews fail to build for the watch app. The errors indicate it is trying to build Swift package targets that are meant for iOS only, not the watch. The watch does not include these dependencies so it is perplexing it will try to build them.
Digging into the scheme for the watch app, it includes the iOS target as you can see the screenshot. This seems to be the default when you create a new watch target. If I uncheck the boxes for the iOS target, previews will build fine. But I think this means that each time I build my Watch target, it will not simultaneously build my iOS target. I'm not sure of the impact of that.
Is this a known limitation with Previews? Is there another workaround?
I am making an application that plays music and vibrates at regular intervals.
When you put your arm down, the following situation occurs.
Music stops (volume goes to 0?)
Vibration stops
How can I make it so that it does not stop even if I put my arm down?
Supplementation
In the WatchOS settings, "Always on" is enabled.
I use AVAudioPlayer for sound playback.
when i select target as "All builds" i am getting list of simulators .
but when i select target as "SCPNative" i am not getting list of simulators.
Deployment target is 7.0 whereas sdk is 10.2.
I am trying to add a watch target in my existing project using XCode 15.1 but I am not able to see any watch simulators for this to run my watch app. I created a small sample project separately where I can see watch simulators reflecting in the run destination. Can somebody please help me to locate which property or setting I need to check which is disabling XCode to show watch simulators? I have downloaded the watch simulator.
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!
Hi folks!
We are developing a WatchOS companion app which records Accelerometer data. We call CMSensorRecorder.recordAccelerometer(forDuration: _) and retrieve the data by calling CMSensorRecorder.accelerometerData(from: _, to: _). So far so good. But the issue arises when we have a data for say 2 hours. We get the accelerometer data in the SwiftUI Task or using GCD's background queue. The data we get is in the loop, enumerating the CMSensorDataList. The loop goes on when the app is active. But as soon as the Watch app goes to inactive state, say applicationWillResignActive is called, the loop is suspended. I know this is the default behaviour of the OS. But this makes our data parsing so slow that sometimes it takes an hour or so to get 2 hours data. This is making our app not user friendly. Is there a way we can keep our app alive as soon as the data is being processed? Or is there another way for faster data processing that we can send the raw data to phone using WCSession so that the data gets there as soon as recording stops?
Thanks
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()
}
}
}
Hi,
I'm trying to build an app for WatchOS and want to add a translucent capsule with a background blur to blur my text behind it. I tried asking ChatGPT, but it couldn't give me a sufficient answer. I would appreciate it if someone could suggest how I could create that background blur.
Thanks!