watchOS is the operating system for Apple Watch.

watchOS Documentation

Posts under watchOS tag

416 Posts
Sort by:
Post marked as solved
4 Replies
1.2k Views
Hello, So I made a VERY simple watch app that basically tracks drinks for a project. I was going to go with complications, but they seem to be outdated. Lo and behold Widgetkit! I set up a VERY simple widget that shows the drink count in my app, and it works AMAZINGLY well in Xcode using the WidgetCenter.shared.reloadAllTimelines() function. However, on actual hardware, the widget will only update to the new drink count if I lock and unlock the watch. It does update overtime in accordance to the widget timeline, but I'd rather it update while the user is in app (no update budget used) and in real time, so the user doesn't see their drink count from 2 minutes ago after they've already added a drink. Keep in mind this is a WatchOS app, there is no iOS app it's attached to. Is there anyway I can refresh or re-render the widget like how the Lock/unlock watch does? Anyone else having this issue? I see a few options, but they involve creating an iOS app with background enabled.. I'd like to keep this simple and a watchOS app. Thank you
Posted
by
Wk7
Post not yet marked as solved
2 Replies
1.4k 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
Post marked as solved
4 Replies
792 Views
Hello all, I would like to enable Dev Mode on an Apple Watch Series 5. Of course everything is updated, the watch as well as Xcode and the Mac system. When I enable Dev Mode, I am prompted to restart the watch. Then after the restart, Dev Mode is no longer enabled. It is so frustrating... I've been trying to solve the problem for hours, but I have no clue. Does anyone have any ideas?
Posted
by
Post not yet marked as solved
2 Replies
1.5k Views
According to SpeakerBox sample code, the Watch App should register for receiving the PushKit notifications like so: let pushRegistry = PKPushRegistry(queue: DispatchQueue.main) pushRegistry.delegate = self pushRegistry.desiredPushTypes = [.voIP] This would then cause a delegate method to be called with a token: func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) { } That, however, never happens. I've already have the required entitlement and this exact same logic works fine on the main iOS app, however, in the companion watchOS app, it does nothing. What am I missing here? Also, since this is not a standalone watchOS app, it doesn't really make sense that it would have its own pushKit token. Isn't there a way to notify the watch about an incoming call using the same pushKit token received on the phone? Thanks in advance,
Posted
by
Post not yet marked as solved
1 Replies
707 Views
Hi, I’m looking at using MusicKit in my watchOS app however I don’t seem to have any method of being able to play the audio though the recommended use of MPMusicPlayerController since it isn’t available on watchOS. This method works fine for iOS and iPadOS but not watchOS which seems bizarre considering we have full access to MusicKit but no way to actually play any audio. I’m trying to build an app that includes Apple Music through MusicKit but don’t have any way to actually play the audio. Is there a technical reason for this and if so is there any other way to play audio from MusicKit on watchOS. The docs for MPMusicPlayerController can be found here: https://developer.apple.com/documentation/mediaplayer/mpmusicplayercontroller
Posted
by
Post not yet marked as solved
5 Replies
2.0k Views
This questions appears many times here but there has not been a proper response. Assume that the watch is in developer mode. That the phone and the watch are already unlocked. The issuer persists. Perhaps someone at Apple can explain the life cycle for this connection and provide a fool proof way of running the code with the watch connected to Xcode through the iphone. Help here will improve productivity dramatically. Thank you
Posted
by
Post not yet marked as solved
1 Replies
810 Views
I’m working on an independent watchOS app which is primarily designed to to collect and periodically send location updates to a server. The UI features a toggle that allows the user to turn this capability on or off at their discretion. The typical use case scenario would be for the user to turn the toggle on in the morning, put the app in the background and then go about their day. Given the limitations and restrictions regarding background execution on watchOS, in an ideal situation, I would be able to upload the stored location updates about every 15-20 minutes. With an active complication on the watch face, it’s my understanding that this should be possible. I’ve implemented background app refresh and indeed, I do see this reliably being triggered every 15-20 minutes or so. In my handle(_:) method, I process the WKApplicationRefreshBackgroundTask like this: func handle(_ backgroundTasks: Set<WKRefreshBackgroundTask>) { backgroundTasks.forEach { task in switch task { case let appRefreshBackgroundTask as WKApplicationRefreshBackgroundTask: // start background URL session to upload data; watchOS will perform the request in a separate process so that it will continue to run even if our app gets // terminated; when the system is done transferring data, it will call this method again and backgroundTasks will contain an instance of // WKURLSessionRefreshBackgroundTask which will be processed below startBackgroundURLSessionUploadTask() scheduleNextBackgroundAppRefresh() appRefreshBackgroundTask.setTaskCompletedWithSnapshot(false) case let urlSessionTask as WKURLSessionRefreshBackgroundTask: // add urlSessionTask to the pendingURLSessionRefreshBackgroundTasks array so we keep a reference to it; when the system completes the upload and // informs us via a URL session delegate method callback, then we will retrieve urlSessionTask from the pendingURLSessionRefreshBackgroundTasks array // and call .setTaskCompletedWithSnapshot(_:) on it pendingURLSessionRefreshBackgroundTasks.append(urlSessionTask) // create another background URL session using the background task’s sessionIdentifier and specify our extension as the session’s delegate; using the same // identifier to create a second URL session allows the system to connect the session to the upload that it performed for us in another process let configuration = URLSessionConfiguration.background(withIdentifier: urlSessionTask.sessionIdentifier) let _ = URLSession(configuration: configuration, delegate: self, delegateQueue: nil) default: task.setTaskCompletedWithSnapshot(false) } } } And here is how I'm creating and starting the background URL session upload task: func startBackgroundURLSessionUploadTask() { // 1. check to see that we have locations to report; otherwise, just return // 2. serialize the locations into a temporary file // 3. create the background upload task let configuration = URLSessionConfiguration.background(withIdentifier: Constants.backgroundUploadIdentifier) configuration.isDiscretionary = false configuration.sessionSendsLaunchEvents = true let backgroundUrlSession = URLSession(configuration: configuration, delegate: self, delegateQueue: nil) let request: URLRequest = createURLRequest() // this is a POST request let backgroundUrlSessionUploadTask = backgroundUrlSession.uploadTask(with: request, fromFile: tempFileUrl) backgroundUrlSessionUploadTask.countOfBytesClientExpectsToSend = Int64(serializedData.count) // on average, this is ~1.5 KB backgroundUrlSessionUploadTask.countOfBytesClientExpectsToReceive = Int64(50) // approximate size of server response backgroundUrlSessionUploadTask.resume() } Note that I'm not setting the .earliestBeginDate property on the backgroundUrlSessionUploadTask because I'd like the upload to start as soon as possible without any delay. Also, this same class (my WatchKit application delegate) conforms to URLSessionTaskDelegate and I have implemented urlSession(_:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:) and urlSession(_:task:didCompleteWithError:). In my testing (on an actual Apple Watch Ultra running watchOS 9.3.1), I've observed that when the system performs the background app refresh, I always receive a callback to myhandle(_:) method. But when I start the background URL session upload task (in startBackgroundURLSessionUploadTask()), I was expecting that when the upload completes, I'd receive another call to myhandle(_:) method with an instance of WKURLSessionRefreshBackgroundTask but this doesn't seem to happen consistently. Sometimes I do see it but other times, I don't and when I don't, the data doesn't seem to be getting uploaded. On a side note, most of the time, startBackgroundURLSessionUploadTask() gets called as a result of my code handling a background app refresh task. But when the user turns off the toggle in the UI and I stop the location updates, I need to report any stored locations at that time and so I call startBackgroundURLSessionUploadTask() to do that. In that specific case, the upload seems to work 100% of the time but I definitely don't see a callback to my handle(_:) method when this occurs. Am I wrong in expecting that I should always be getting a callback to handle(_:) when a background URL session upload task completes? If so, under what circumstances should this occur? Thanks very much!
Posted
by
Post not yet marked as solved
2 Replies
1k Views
Hello everyone, I am writing to inquire about a strange behavior that I encountered while using StoreKit 2 on watchOS 9.1 and Xcode 14.2. Specifically, when using the Transaction.currentEntitlements method, it returns refunded non-consumable purchases alongside valid ones. Additionally, I have observed that Transaction.updates does not notify me of refunded purchases or cancelled subscriptions while testing on my local environment with Xcode. When implementing the same code with an iOS app, it works as expected, indicating that this may be a watchOS-specific issue. This behavior is unexpected, and I am unsure if this issue also occurs in a production environment. Can anyone please help me with this issue? Thank you in advance.
Posted
by
Post not yet marked as solved
1 Replies
599 Views
I'm using the new watchOS 9 HKWorkoutActivity in my interval training app (Intervals Pro) for each interval. It's a great addition since all the intervals now show in the Apple Fitness app, however, if the workout has lots of activities then saving the workout is painfully slow. For example, on my Apple Watch Ultra I saved a workout with 63 activities and it took more than 1 minute. Here's a code snippet: try await builder.endCollection(at: workoutEndDate) try await builder.addMetadata(metadata) try await builder.finishWorkout() // This is SLOW Is anyone else having the same issue? To demonstrate the issue you can look at a Test Flight build of Intervals Pro: https://testflight.apple.com/join/Nn7iSOzY Tap on the More tab in the iPhone app and then the Apple Watch Settings. On that screen you'll see a switch to either enable or disable workout activities. To demonstrate the issue, edit a timer to continue until manually stopped by changing the Number of Cycles to "Until Stopped". Then start the timer on the watch. Let it run for a period of time to create more than 50 intervals, for example, then stop the timer. Swipe to the leftmost screen on the watch, tap pause, then tap end. At that point you'll see how slow the workout saved. Next, you can go back to the iPhone app, disable using workout activities and repeat the test. The workout will save quickly in this case. I've filed a feedback.
Posted
by
Post not yet marked as solved
1 Replies
967 Views
We're currently trying to develop an Apple Watch companion app for our iOS app using the new WatchOS 9 which has the VoIP call capabilities. Is there a way to mirror VoIP notifications similarly to push notifications between the WatchOS app and iOS app? Essentially we'd like to be able to send a VoIP notification to the iOS app and have the answer/decline call screen show up in both the iPhone and Apple Watch. Currently when we send a VoIP notification to the iOS app, the Apple Watch does not receive anything. Push notifications and local notifications work just fine.
Posted
by
Post not yet marked as solved
4 Replies
686 Views
On Xcode 14.3 I am unable to download symbols for watchOS 8.7.1, which is preventing me from developing on my Apple Watch 3 device. The detailed error message is: DVTDownloadable: Download Failed. Downloadable: https://download.developer.apple.com/Developer_Tools/watchOS_19U67/Watch3_1_19U67.dmg. Error Domain=DataGatheringNSURLSessionDelegate Code=1 "Failed with HTTP status 403: forbidden" UserInfo={NSLocalizedDescription=Failed with HTTP status 403: forbidden} The link https://download.developer.apple.com/Developer_Tools/watchOS_19U67/Watch3_1_19U67.dmg doesn't work for me in Safari either.
Posted
by
Post marked as solved
2 Replies
519 Views
Here's what happens: I install the app by updating the iOS companion app (debugging does not seem to work on Xcode 14) I launch the app, the spinner around the app icon is shown The app crashes and closes The crash reports are empty I have an app that runs back to watchOS 6, in an update in November I introduced something that now causes a crash on watchOS 6. That was also the first update I uploaded with the watchOS 9 SDK. It took me a while to get hold of an Apple Watch Series 2, since the issue is not reproducible in the watchOS simulator. I guess that some library is loaded that should not be loaded. I verified all linked frameworks and all those which are not available on watchOS 6, are marked as weak. Here's the crash report that I can get on the connected iPhone: {"bug_type":"109","os_version":"Watch OS 6.3 (17U208)","build_version":"1","timestamp":"2023-05-05 03:48:22.00 +0200","app_name":"... WatchKit Extension","bundleID":"xyz.redacted....","incident_id":"65713574-8B62-460F-B888-5883BE6E722E","name":"... WatchKit Extension","is_first_party":0,"app_version":"3.0","share_with_app_devs":1,"slice_uuid":"d19f4d3c-f36f-342a-a5df-55697c51b6c7","adam_id":0} Incident Identifier: 65713574-8B62-460F-B888-5883BE6E722E CrashReporter Key: a35b48fb320eafcf397ca73c04d9c4c855507a00 Hardware Model: Watch2,4 Process: ... WatchKit Extension [894] Path: /private/var/containers/Bundle/Application/2E5E3894-A93C-412C-A518-7B3C73B42E61/... WatchKit App.app/PlugIns/... WatchKit Extension.appex/... WatchKit Extension Identifier: xyz.redacted.....watchkitapp.watchkitextension Version: 1 (3.0) Code Type: ARM (Native) Role: Foreground Parent Process: launchd [1] Coalition: xyz.redacted.....watchkitapp.watchkitextension [438] Date/Time: 2023-05-05 03:48:22.0871 +0200 Launch Time: 2023-05-05 03:48:21.0000 +0200 OS Version: Watch OS 6.3 (17U208) Release Type: User Baseband Version: n/a Report Version: 104 Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x89248914 Termination Signal: Segmentation fault: 11 Termination Reason: Namespace SIGNAL, Code 0xb Terminating Process: exc handler [894] Highlighted by Thread: 0 Backtrace not available Unknown thread crashed with ARM Thread State (32-bit): r0: 0x62070f70 r1: 0x20ac4f70 r2: 0x82b13dc1 r3: 0x00000000 r4: 0x62070f70 r5: 0x0015c000 r6: 0x27ca7224 r7: 0x27ca6288 r8: 0x890ec914 r9: 0x01810034 r10: 0x27ca6390 r11: 0x0180efe0 ip: 0x0180ef98 sp: 0x27ca6250 lr: 0x01b8b385 pc: 0x01b8b386 cpsr: 0x00000030 Binary images description not available Error Formulating Crash Report: Failed to create CSSymbolicatorRef - corpse still valid ¯\_(ツ)_/¯ EOF Best, Alex
Posted
by
Post marked as solved
2 Replies
2.2k Views
I have a watch complication that used to work just fine and now all of a sudden in my latest build it's showing only dashes. The watch app is there, if I tap on the complication then the watch app opens correctly, if I edit the watch face and select the complication I can see my placeholder (and it's fine) but when I select that complication, the sample watch face shows dashes. The only major change I've made is to make the watch app a single-target without an extension delegate as per Apple's recommended settings. I don't think this is the problem as the simulator shows the complication. It's only on the Watch Series 4 that I'm testing on that I can't see my complication. It was working only last week and I have not touched the complication code at all, so I'm stumped as to what's wrong. I can't find any help on line, apparently no one has ever seen the complication just have dashes. When I debug the watch app and ask for how many complications there are, it comes back with zero even though I've put them on the watch face. It seems like watchOS9 is just not respecting the complication any longer but I can't figure out why. Please note that I'm not using WidgetKit complications as the corner complication doesn't flow the text in an arc like ClockKit does, so I'm still using the old complications. But none of the code is getting called as none of my breakpoints are firing. I've rebooted the watch about 10 times and the problem persists. Any ideas why all of a sudden this has fallen over and gone boom?
Posted
by
Post not yet marked as solved
2 Replies
671 Views
I need to install the GoogleSignIn for my iOS application, and I did so. The issue is that the watchOS app inside the project stops working because of build failures that are caused by the GoogleSignIn package. I cannot figure how to fix it, because inside the project settings, that package appears in the list of Frameworks for the iOS target, and is not present into the list of Frameworks for the watchOS target, as you can see in the first image below.
Posted
by
Post not yet marked as solved
3 Replies
1.1k Views
I'm working on an independent watchOS app and I'm testing on the Apple Watch Ultra simulator as well as a couple of real Apple Watch Ultra devices (both have active cellular subscriptions on AT&T, are within 3 feet of their paired iPhones and connected to WiFi, as well). My app has an application delegate which implements the applicationDidFinishLaunching() method and in that method, I register with APNs for remote notifications. When I receive the token in didRegisterForRemoteNotifications(withDeviceToken:), I send the token on to the server that is going to send notifications to the app. When I test this code in the Apple Watch Ultra simulator, it works 100% of the time. When I test the same code on a real Apple Watch Ultra, about 70% of the time, I get the following error message in the Xcode debug console: 2023-05-12 08:32:30.779560-0400 Watch App Prototype[569:586139] PDTask <5110B87C-28D7-48C9-9C68-121C7728FF68>.<2> finished with error [9] Error Domain=NSPOSIXErrorDomain Code=9 "Bad file descriptor" UserInfo={_kCFStreamErrorCodeKey=9, _kCFStreamErrorDomainKey=1, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataPDTask <5110B87C-28D7-48C9-9C68-121C7728FF68>.<2>", "LocalDataTask <5110B87C-28D7-48C9-9C68-121C7728FF68>.<2>" ), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataPDTask <5110B87C-28D7-48C9-9C68-121C7728FF68>.<2>} 2023-05-12 08:32:30.780401-0400 Watch App Prototype[569:586139] Task <5110B87C-28D7-48C9-9C68-121C7728FF68>.<2> finished with error [9] Error Domain=NSPOSIXErrorDomain Code=9 "Bad file descriptor" UserInfo={_kCFStreamErrorCodeKey=9, _kCFStreamErrorDomainKey=1, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask <5110B87C-28D7-48C9-9C68-121C7728FF68>.<2>", "LocalDataPDTask <5110B87C-28D7-48C9-9C68-121C7728FF68>.<2>", "LocalDataTask <5110B87C-28D7-48C9-9C68-121C7728FF68>.<2>" ), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <5110B87C-28D7-48C9-9C68-121C7728FF68>.<2>} The operation couldn’t be completed. Bad file descriptor I ran across a post from someone else about the same problem on StackOverflow. I'm not sure what to make of this error but here's the code that I'm using to send the URL request: func perform(_ urlRequest: URLRequest) async throws -> Data { let (data, response) = try await urlSession.data(for: urlRequest) guard let httpResponse = response as? HTTPURLResponse else { throw NetworkError.serverSideError(response: nil) } guard (200...299).contains(httpResponse.statusCode) else { throw NetworkError.serverSideError(response: httpResponse) } return data } For what it's worth, urlSession is the shared URLSession instance. Again, this error never occurs in the simulator but it happens on both of the Apple Watch Ultra devices and I would say it occurs about 70% of the time. Can anyone help me understand this error message?
Posted
by
Post not yet marked as solved
4 Replies
1.2k Views
Hi to all, I'm new to WatchOS development and trying to install the default Xcode 'Hello World' app on my Apple Watch Ultra. I've enabled Developer Mode on my iPhone and did the same on my Apple Watch. After enabling Developer Mode on the watch it asks me to restart the watch. After a restart it asks me again if I want to enable Developer Mode. Of course! I don't succeed in installing the app on my watch because Xcode is "waiting for first unlock" of my watch. When I look in Settings > Privacy > Developer Mode the toggle switch is disabled. I can enable the switch but the watch asks me to restart and this is the loop I'm in. Anybody suggestions for 'permanently enabling' Developer Mode on my Apple Watch? Thanks in advance!
Posted
by
Post marked as solved
1 Replies
1k Views
This is probably a silly question, but I couldn't find the answer to it in the forums or in the documentation, though I may be missing something. I currently have an app with a deployment target of iOS 16 and a watchOS app (not independent) with a deployment target of watchOS 7. I understand what happens when I change the deployment target on the iOS app (e.g., users with iOS/iPadOS versions less than 16 will just never see the updates in the App Store). But what happens if I change the deployment target of the watchOS dependent app to something like watchOS 8? Will users who have iOS 16 and watchOS 7 (iOS meets deployment target/watchOS does not) get the app update, and it'll just uninstall the watchOS app automatically? Will they just not see the update? Does the old version of the Watch app somehow stay on their watch while the iOS app gets updated?
Posted
by