WatchKit

RSS for tag

Build 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

Xcode 16 Beta 3 Watch App - No Simulator Runtime Version Even though Simulator is installed.
Today I installed Xcode 16 Beta 3. I have the watchOS 11 simulator installed on my Mac. When building my watch app with Xcode Beta 3 I am getting the following error. /Applications/Xcode-16-beta-3.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Library/Application Support/MessagesApplicationStub/MessagesApplicationStub.xcassets: No simulator runtime version from [<DVTBuildVersion 21F79>] available to use with iphonesimulator SDK version <DVTBuildVersion 22A5307d> I have no idea what those assets are for but they aren't part of my project. I tried generating a new standalone watch app project using Xcode 16 Beta 3 and I am getting the same error message so this isn't something particular to my original watch project. Any help on how to fix this issue is appreciated.
1
0
176
1w
Prevent Apple Watch Screen from Turning Off in Power Saving Mode During Specific App Use
Hello, I am developing an application for the Apple Watch that requires the screen to remain active even when the wrist is moved into a down position. The core functionality of my app involves providing continuous visual and auditory guidance, and it's critical that the screen stays on without going into power-saving mode while the app is in use. Specifically, I am looking for a way to: 1.Disable the screen's power-saving mode when the wrist is moved down. 2.Ensure the screen remains active as long as the app is in the foreground. I understand that certain power management features are built into watchOS for battery conservation, but I would need this behavior to be overridden only while the application is running (the app would not be in the foreground for extended periods of time). Is there an approved method or best practice within Apple's guidelines to achieve either of these functionalities? Thank you for your assistance.
1
0
112
1w
Preventing Apple Watch Screen from Turning Off in Wrist Down Position
Hello, I am developing an application for the Apple Watch that requires the screen to remain active even when the wrist is moved into a down position. The core functionality of my app involves providing continuous visual and auditory guidance, and it's critical that the screen stays on without going into power-saving mode while the app is in use. Specifically, I am looking for a way to: 1.Disable the screen's power-saving mode when the wrist is moved down. 2.Ensure the screen remains active as long as the app is in the foreground. I understand that certain power management features are built into watchOS for battery conservation, but I would need this behavior to be overridden only while the application is running (the app would not be in the foreground for extended periods of time). Is there an approved method or best practice within Apple's guidelines to achieve either of these functionalities? Thank you for your assistance.
1
0
139
1w
WatchConnectivity Session becomes unreachable but shouldn't
So for context I am building an app where the Apple Watch establishes a WatchConnectivity session with the parent iPhone app and streams audio data from the watch Mic to the iPhone for processing on Deepgram to perform STT. This works very well, unless I tilt my wrist and the display goes to sleep. What I find strange is that due to the mic being in use on my watch, the app is still showing on the always on display and is still trying to send the audio data to my phone in the background (which is perfect!) but the iPhone does not seem to be responding. So my watch code is: private func sendData(_ data: Data) { let dict: [String: Any] = ["audioData": data] session.sendMessage(dict, replyHandler: nil, errorHandler: { error in print("Failed to send data: \(error.localizedDescription)") }) } and my Xcode logs Failed to send data: WatchConnectivity session on paired device is not reachable. So the watch is still running the process but because session.isReachable is false the audio data is not sent which it should be! Is there any way to keep the connection established and data sharing when the display dims?
0
0
146
1w
Extract metadata from a .watchface
Hello, fellow developers! How would you approach .watchface file to extract it's metadata? I need to know in which version of the app the face was created, to prompt the user to update the app if necessary. Looking at binary I suppose that a .watchface file consists of a PNG previews and JSON metadata and it all packed in one file somehow. Probably archived with gzip.
0
0
115
1w
Workout session active but "Return to app" option not displayed in menu
I have an iOS app, with a watch counterpart, used to enter scores for a match. The watch app starts a match (and a workout session) when it receives a notification from the mobile app, after the user started a match on their phone. Basically the watch app is just a more convenient way of inputing scores, so the user wouldn't have to reach for and unlock their phone every time - therefore the need for the watch app to always be displayed. The flow follows these steps: the user is prompted for workout session access when first launching the app; after they accept, I start the workout; the delegate method workoutSession(didChangeTo) returns the expected values; the app remains active, even when the user lowers their wrist; when I go to the clock, the app's icon is displayed in a circle at the top (bringing the app back to foreground on tap). The only problem is that the "Return to app" option in the "Return to Clock" settings menu is missing, what do I need to do in order to display it? Here's an example of what it looks like for the Strava app: and how it looks for mine.
0
1
202
2w
Ultra Action Button showing on screen
When I initiate WKExtendedRuntimeSession with a background mode of "Underwater Depth" I get an orange indicator showing the Action button on the screen that stays showing all the time and then animates when you press the action button. I believe this started with a recent WatchOS update, because it never happened before. Does anyone know how to hide it? Or keep it and be able to detect the Action button presses within my app (if possible)?
1
0
194
4w
7014 - Payload could not be delivered.
Hi All, can anyone help me to the below issue? i used the WatchConnectivity to send data from iphone to watch app. Now i tried to run them on emulator (watch series 5, and iphone 15 pro) I have an error when i tried to send message data from iphone app (react-native) to watch app: { "code": "EWCERRORDOMAIN7014", "domain": "WCErrorDomain", "message": "Payload could not be delivered.", "nativeStackIOS": [ "0 releasev2 0x0000000101979c90 RCTJSErrorFromCodeMessageAndNSError + 112", "1 releasev2 0x0000000101979bd0 RCTJSErrorFromNSError + 256", "2 releasev2 0x000000010190c2b4 __41-[RCTModuleMethod processMethodSignature]_block_invoke_4.110 + 148", "3 releasev2 0x000000010185003d __35-[RNWatch sendMessage:reply:error:]_block_invoke.116 + 77", "4 WatchConnectivity 0x000000011428b176 __70-[WCSession _onqueue_notifyOfMessageError:messageID:withErrorHandler:]_block_invoke + 206", "5 Foundation 0x0000000119095004 NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK + 7", "6 Foundation 0x0000000119094f02 -[NSBlockOperation main] + 94", "7 Foundation 0x0000000119097ef2 NSOPERATION_IS_INVOKING_MAIN + 17", "8 Foundation 0x00000001190940aa -[NSOperation start] + 730", "9 Foundation 0x0000000119098744 NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION + 17", "10 Foundation 0x0000000119098385 __NSOQSchedule_f + 182", "11 libdispatch.dylib 0x000000011434ca90 _dispatch_call_block_and_release + 12", "12 libdispatch.dylib 0x000000011434dd3a _dispatch_client_callout + 8", "13 libdispatch.dylib 0x000000011435126a _dispatch_continuation_pop + 874", "14 libdispatch.dylib 0x00000001143502b0 _dispatch_async_redirect_invoke + 994", "15 libdispatch.dylib 0x000000011436041e _dispatch_root_queue_drain + 372", "16 libdispatch.dylib 0x0000000114360e88 _dispatch_worker_thread2 + 244", "17 libsystem_pthread.dylib 0x0000000116800c0f _pthread_wqthread + 257", "18 libsystem_pthread.dylib 0x00000001167ffbbf start_wqthread + 15" ], "userInfo": { "NSLocalizedDescription": "Payload could not be delivered." } } Here is the class connector shared data on watch target: class SharedDataConnecter: NSObject, ObservableObject { var session: WCSession init(session: WCSession = .default){ self.session = session super.init() if WCSession.isSupported(){ session.delegate = self session.activate() } } } extension SharedDataConnecter: WCSessionDelegate{ func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) { print("Active State: ", activationState.rawValue) print("Error: ", error) } func session(_ session: WCSession, didReceiveMessage message: [String : Any], replyHandler: @escaping ([String : Any]) -> Void) { print("AAAA message from app: ", message) } }
0
0
252
Jun ’24
How to use CMHighFrequencyHeartRateData to read the Heart rate data from CoreMotion framework
Hello, As per Apple Documentation Link for CoreMotion framework we can read high frequency heart rate using CMHighFrequencyHeartRateData but there is No way to set the type like heartRate and have a updateHandler to provide the heart rate data. But for Accelerometer data, CoreMotion framework can provide startAccelerometerUpdates(to:, withHandler:) and user can set update interval like accelerometerUpdateInterval using CMMotionManager. But There is no solution available for heartRate. If any solution is available to read heartRate using CMHighFrequencyHeartRateData it will be helpful for me. I know we can read the Heart Rate Data using HealthKit framework using HKAnchoredObjectQuery but the heart rate data is not consistent and startDate & endDate for heart rate data is also not consistent. We want heart rate very frequent like every second. Any help can be appreciated. Thanks in advance
1
0
226
Jun ’24
HKObserverQuery not working in background
I'm developing a single target watchOS app that obtains HealthKit information. I have the "Background Delivery" option checked under "Signing & Capabilities" for the watch target. The app does HKObserverQueries in the foreground that work as I would expect. But when I click the Digital Crown to return to clock face, the HKObserverQuery activity stops. I'm using Xcode 15.4, on Mac 14.5 and a Apple Watch Series 4 running 10.5.
2
0
244
Jun ’24
Complication works on watch, but not visible in watch app on phone
I have an iPhone app, and added watch support, including a simple launcher complication. I can add the complication using the edit UI on the watch, but the complication is not visible using the watch app on the iPhone. When I add my complication on the watch and then open the watch app on the iPhone, the complication slot shows as "Off". What could I be doing wrong?
2
0
269
Jun ’24
How to display "Return to app" option in the "Return to Clock" watch menu?
I have a sports iOS app with a paired watch app, that uses location to update some UI elements. I technically need the location only when the watch app is in foreground, but since another requirement is to stop the clock from replacing the app, I decided to add background location checks. I followed the steps from the documentation (adding Background Modes to the watch extension target, setting allowsBackgroundLocationUpdates to true): the location update works fine when I go to the clock, the app's icon is displayed in a circle at the top (bringing the app back to foreground on tap). The only problem is that the "Return to app" option in the "Return to Clock" settings menu is missing, what do I need to do in order to display it? Here's an example of what it looks like for the Strava app: and how it looks for mine.
2
0
345
2w
Several SwiftUI Stepper on watchOS
I'm showing several Steppers in a SwiftUI view on watchOS. When the user taps the steppers & turns the digital crown it's possible to select multiple of the steppers (green "focus" border) appears. I've tried to make the steppers mutually exclusive by using the following snippet, but it didn't work. `@FocusState private var value: StepperType?` [...] var body: some View { Form { ForEach(StepperType.allCases, id: \.self) { stepperCase in Stepper... .focused($value, equals: stepperCase) } } } Any ideas how I can prevent multiple Steppers from being "focused" by the crown at the same time?
0
0
247
May ’24
Watch app wont install after download with Business Manager
We created an app for iphone which includes a Watch app. The app works well during debugging, and also in TestFlight the Watch app installs nicely and does what it is supposed to do. However, when we make the app available through the Apple Business Manager (the app is for internal use by a company) the Iphone app downloads without problems, but the app for the Apple Watch does not work. When I go to the Watch app on my Iphone (where you can manage the apps on your Watch and so on) my app is listed, but when I press install I see a loader for a few seconds, then it stops but nothing else happens. So the code seems to be good, but after I download the app with a code through the Business Manager, then I cannot install the Watch version of the app.
0
0
201
May ’24
File transfer to watch fails after OS update
When transferring files from iPhone to Watch, if you run the app and try to transfer after updating the OS, the transfer may not be possible. (or transmission seems to be too slow) Just completely close the app, restart it, and try again. Does anyone know the cause or solution to this problem? It happened after the last 17.5 update and today after the 17.5.1 update. The app doesn't crash or anything, and it doesn't happen often, so I didn't send any feedback or anything, but it's strange.
3
0
392
3w
Getting 561015905 while trying to initiate recording when the app is in background
I'm trying to start and stop recording when my app is in background periodically. I implemented it using Timer and DispatchQueue. However whenever I am trying to initiate the recording I get this error. This issue does not exist in foreground. Here is the current state of my app and configuration. I have added "Background Modes" capability in the Signing & Capability and I also checked Audio and Self Care. Here is my Info.plist: <plist version="1.0"> <dict> <key>UIBackgroundModes</key> <array> <string>audio</string> </array> <key>WKBackgroundModes</key> <array> <string>self-care</string> </array> </dict> </plist> I also used the AVAudioSession with .record category and activated it. Here is the code snippet: func startPeriodicMonitoring() { let session = AVAudioSession.sharedInstance() do { try session.setCategory(AVAudioSession.Category.record, mode: .default, options: [.mixWithOthers]) try session.setActive(true, options: []) print("Session Activated") print(session) // Start recording. measurementTimer = Timer.scheduledTimer(withTimeInterval: measurementInterval, repeats: true) { _ in self.startMonitoring() DispatchQueue.main.asyncAfter(deadline: .now() + self.recordingDuration) { self.stopMonitoring() } } measurementTimer?.fire() // Start immediately } catch let error { print("Unable to set up the audio session: \(error.localizedDescription)") } } Any thoughts on this? I have tried most of the ways but the issue is still there.
3
0
313
May ’24
Does WatchOS kill apps when in extreme temperatures?
I have noticed that my Apple Watch app seems to randomly quit from time to time. It's not crashing and I have not been able to reproduce it in a controlled setting, but have noticed that it seems to only happen when I'm in very high or low temperatures. For instance, I was skiing recently and my app was supposed to stay running the whole time, but often when I would raise my wrist it would be back on the home screen and my app wasn't running. This also happened when I was on the beach on a very hot day. But when I'm testing it at home I can keep it running for hours and it never crashes, which leads me to believe it may have to do with the temperature. Does the OS kill apps when it's running in very high or low temperatures? If so, is there anything I can do to prevent this from occurring? Would doing less things in my app possibly prevent this? For instance, I have a timer, and use a bunch of sensors, would turning those off at times and using less of the display make a difference or does the OS not care what the apps are actually doing? If not, any other ideas? Thanks
1
0
344
Jun ’24
Is it possible to change bundle id of Watch kit app?
Long story short, I had my App and Watch app already uploaded to the app store. However, I needed to add a WatchConnectivity to have App to Watch communication. At the beginning My app bundle id was: com.x My watch bundle id was: com.x.watchkitapp However, while developing Watch Connectivity, I noticed that my Apps are not connected unless I changed it to com.x.watchkitapp -> com.x.watch However after changing it I cannot submit my bundle anymore. I'm getting Asset validation failed error Invalid Bundle Identifier. Attempting to change bundle identifier from com.x.watchkitapp to com.x.watch is disallowed for bundle x.app/Watch/WatchX Watch App.app. (ID: 75a4621a-7e28-411d-a2a7-84674e460656) Any ideas how this could be solved?
1
0
292
May ’24