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

Cannot distribute app?
I have a watch app that I have been distributed for years. But on recent Xcode 15.0.1, I started having problem: Using a eligible provision profile, I started distribute app via TestFlight and App Store, and i got: Automatic signing cannot register bundle identifier "com.virtualgs.invaders.watchkitapp.watchkitextension". Automatic signing cannot register bundle identifiers with Apple. Register your bundle identifier on https://developer.apple.com/account and then try again. No profiles for 'com.virtualgs.invaders.watchkitapp.watchkitextension' were found Xcode couldn't find any iOS App Store provisioning profiles matching 'com.virtualgs.invaders.watchkitapp.watchkitextension'. But it has gone up for many years! Any ideas?
1
0
788
Oct ’23
Location Retrieval in watchOS for Alarm App
Hello! I'm currently working on a panic alarm app and am in the process of developing an extension for the Apple Watch. I'm trying to retrieve the location on watchOS, but I've encountered some issues. Could you provide an example or guide on how to successfully obtain the location? I suspect there might be a problem with the didFailWithError method not being recognized. Any assistance would be greatly appreciated. // Home2.swift // (watchOS) Watch App // // Created by Admin on 15.08.2023. // import SwiftUI import CoreLocation import CoreLocationUI class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate { let manager = CLLocationManager() @Published var location: CLLocationCoordinate2D? override init() { super.init() manager.delegate = self } func requestLocation() { manager.requestLocation() } func checkPermission() { print("authorization status:") switch manager.authorizationStatus { case .authorizedAlways: print("always") break case .authorizedWhenInUse: print("authorized when in use") break case .notDetermined: print("notdetermined") break case .denied: print("denied") break case .restricted: print("restricted") break default: print("none of the above") break } } func requestPermission() { checkPermission() manager.desiredAccuracy = kCLLocationAccuracyBest manager.requestWhenInUseAuthorization() } public func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { location = locations.first?.coordinate } public func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { // Error handling print("Error requesting location") } } struct Home2: View { @Binding var alarmStatus: String @StateObject var locationManager = LocationManager() @State var error: String = "" func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { // handle the error print("error ting location fra struct:" + error.message!) } func callForHelpSync() { let name = "EnBruger" /*do { try locationManager.requestPermission() print("her") let locVal = try locationManager.requestLocation() print("locVal: \(locVal)") } catch { print("locVal error: \(error)") } */ let userId = ReadlocalStorage(key: "userId") let lat: Double = 123 // TODO let long: Double = 1234 // TODO Task { let res = try await callForHelp(name: name, id: userId, lat: lat, long: long) print("callforhelp res: " + res as Any) if (res == "Sent") { //opdater binded value. alarmStatus = "Sent" } else { // vis error besked. error = "Error: \(res)" } } } var body: some View { VStack(){ Image("logo") .resizable() .aspectRatio(contentMode: .fit) Spacer() Button(action: { print("record clicked") WKInterfaceDevice.current().play(.click) }) { VStack() { Text("Aktiver Alarm") .multilineTextAlignment(.center) .padding(1.0) .font(.system(size: 22, weight: .bold)) Text("(Hold inde)") .multilineTextAlignment(.center) .padding(1.0) } } .padding(11.0) .background(/*@START_MENU_TOKEN@*//*@PLACEHOLDER=View@*/Color(hue: 1.0, saturation: 0.966, brightness: 0.824)/*@END_MENU_TOKEN@*/) .buttonStyle(.plain) .simultaneousGesture(LongPressGesture(minimumDuration: 2).onEnded({_ in callForHelpSync()})) Text(self.error).font(.footnote).foregroundColor(Color.red).fixedSize(horizontal: false, vertical: true) Spacer() Button(action: { print("test button 1 clicked") locationManager.requestPermission() }) { VStack() { Text("Test Knap 1") .multilineTextAlignment(.center) .padding(1.0) .font(.system(size: 22, weight: .bold)) } } .padding(6.0) .background(.blue) .buttonStyle(.plain) if let location = locationManager.location { Text("Your location: \(location.latitude), \(location.longitude)") } LocationButton { locationManager.requestLocation() } .frame(height: 44) .padding() Button(action: { print("test button 2 clicked") var lh = LocationHandler() lh.requestLocation() }) { VStack() { Text("Test Knap 2") .multilineTextAlignment(.center) .padding(1.0) .font(.system(size: 22, weight: .bold)) } } .padding(6.0) .background(.blue) .buttonStyle(.plain) } .background(/*@START_MENU_TOKEN@*//*@PLACEHOLDER=View@*/Color.white/*@END_MENU_TOKEN@*/) } } struct Home2_Previews: PreviewProvider { static var previews: some View { @State var alarmStatus = "none" Home2(alarmStatus: $alarmStatus) } }
0
1
418
Oct ’23
Unable to install "SwingMonitor"
Hi everyone, I am new to app development, and I am learning and develop a simple app with iPhone and Apple Watch. Initially, i was successful in building and installing the app. However, all of a sudden, the error /Unable to install "SwingMonitor"/ started to appear and I really struggle to find a solution. I even tried to start from scratch, but the issue remains. Please could you help me? I will be able to provide info.plist content and build phase/setting information as required. Many thanks in advance.
1
0
424
Oct ’23
Masking WKInterfaceLabel objects
I have a WKInterfaceLabel that spans two other objects (could be most anything, but generally solid color). (I'm using Interface Builder). One object is light and the other is dark. I'd like the part of the label on the light object to be black, and the part on the dark object to be white. See the example below. Is there any way to "mask" out part of the label so that the objects behind show through? I could have two labels, one black and one white, but would need to mask out each half. I can't simply half cover each label to mask it out because that will mask out the other.
0
0
411
Oct ’23
WKCrownDelegate.crownDidRotate() not always receiving events
I have a WatchOS app with scrollable views. Depending on the state of the app I would like to receive crown rotation events. To achieve this behavior I have set up a timer that calls the focus() method of the crownSequencer. In the Apple Watch simulator in XCode the app behaves consistently and there are no problems. However, some users (not all) report that rotating the crown does not work. What could be the reason for this behavior? Here is the relevant code: import WatchKit import Foundation import HealthKit class MyInterfaceController: WKInterfaceController { var controlTimer: Timer?; var restTimer: Timer?; var timer: Timer?; override func awake(withContext context: Any?) { super.awake(withContext: context) setupTimers() } override func willActivate() { super.willActivate() setupTimers() } override func didAppear() { super.didAppear() setupTimers() } func setupTimers() { clearTimers() restTimer = Timer.scheduledTimer(withTimeInterval: 0.01, repeats: true, block: { _ in // Do something }); timer = Timer.scheduledTimer(withTimeInterval: 0.01, repeats: true, block: { _ in // Do something }); controlTimer = Timer.scheduledTimer(withTimeInterval: 0.2, repeats: true, block: { _ in if (someCondition == false) { self.crownSequencer.resignFocus() } else { self.crownSequencer.delegate = self self.crownSequencer.focus() } }); } func clearTimers() { controlTimer?.invalidate() controlTimer = nil restTimer?.invalidate() restTimer = nil timer?.invalidate() timer = nil } } extension MyInterfaceController : WKCrownDelegate { func crownDidRotate(_ crownSequencer: WKCrownSequencer?, rotationalDelta: Double) { if (rotationalDelta > 0.2) { // Do something } else if (rotationalDelta < -0.2) { // Do something } } }
0
0
367
Oct ’23
XCode 15 - Getting WatchKit Extension Error while Project try to run in real device
Facing a error when switch project Xcode 14 to Xcode 15 in M1 Mac. In simulator it is working fine but when try to real device getting error. Also try all solution from below link but not able to solve the error. https://developer.apple.com/documentation/technotes/tn3117-resolving-build-errors-for-apple-silicon/ Let me know if anyone know solution.
0
0
383
Oct ’23
Watch Simulators always shows error "This watch face is not available on this watchOS"
I have created multiple faces, i want to test those on different watch series and watch OS. However i am not able to use simulators for that (iOS and WatchOS). To understand the case please do below steps. From simulator Open Apple watch app and share any face (create your own or share existing) Share via email or airdrop Drag this face into simulator again Error will be shown that face is not available for this device. If try to apply using below code, same error occur CLKWatchFaceLibrary().addWatchFace(at: url) I want to know how can i test my watch faces on different versions using simulators.
1
0
514
Oct ’23
How to create our own Watch face to our app?
Are we able to create our own watch face to our application. We have ios app and watch app, need to create watch face with few app data's like heart rate, steps count, etc on the watch face. But I fount some answers like it is not possible to create a watch face. Possible to create watch face for Apple Watch? Are developers allowed to publish watch faces? I have found a website Facer(https://www.facer.io/creator) where they are offering customizing options and generating .watchface from their website. What approach they are following?
1
0
2.2k
Oct ’23
WatchOS CoreBluetooth maximum peripheral connections
I have an app running on WatchOS. How many BLE peripherals can my app connect to at the same time? If the number of peripheral objects is limited in some way, is the limit imposed on each instance of CBCentralManager? Or is the limit imposed on each app? I have a use case that would require four BLE peripheral connections. Is tis possible? I have another use case that would require 6 BLE peripheral connections. Is this possible?
1
0
395
Oct ’23
Can we use Apple Watch sensors all day long with no limit?
I'm student from Korea. I'm interested in apple things. I have several questions about Apple Watch sensors such as ECG(Electrocardiogram), Heart rate, Oxygen Saturation, breath rate, atrial fibrillation(afib) and so on. First of all, Can I use these sensors all day long? with no limit? I'm planning to develop some healthcare application using Apple Watch with sensors. I can't find examples of using sensors 24/7. And Second, If I can use the sensors all day long, can I execute the app in background? Finally, If I can execute the app in background, can I activate the sensors in background? Thank you for your help. I have tried searching developer guide, and searching the GitHub.
1
0
675
Sep ’23
Unable to distribute watchOS only build
I don't see upload option for the App Store connect, can only export .ipa. Also having issues with Transporter, pasting error message here. Could not create a temporary .itmsp package for the app "Redacted.ipa". Unable to determine app platform for 'Undefined' software type. Is anyone else facing the same issue? I am using Xcode 15.
7
1
1k
Oct ’23
Issues with tint color not showing on Multicolor watch faces
I use the widget as a complication. Inside the widget, I have a Label and Image. I use SF symbols for the image. It should be possible to set the image colour in the code. I tried .tint() and .foregroundStyle(). I think my colour should be visible when selecting Multicolor tint varian. How to set an accent colour for an SF symbol inside a widget? Is anyone else having issues with this? My image just renders white on a black background. watchOS 10 Xcode 15 RC
0
0
442
Sep ’23
CLLocationManager with watchOS10 not sending anything to didUpdateLocations:
My watch app records workouts including health (with HKWorkoutSession) and location data.The watch app is on the App Store and runs without any problems since long time. I updated my own Watch Ultra to watchOS10 and my app does not properly work anymore. Everything works with the exception that the app does not receive any CLLocationManager data on the physical device. On the simulator it works perfectly. I tried several devices in the simulator and they all work. Also I de-coupled the watch from the phone, deleted the watch completely and re-installed it. My app's target is watchOS9, I tried it with watchOS10 and the problems are the same CLLocationManager has correct and valid permissions CLLocationManager is setup like this: locationManager = CLLocationManager() locationManager.delegate = self locationManager.allowsBackgroundLocationUpdates = true locationManager.activityType = .fitness locationManager.desiredAccuracy = kCLLocationAccuracyBest locationManager.distanceFilter = kCLDistanceFilterNone locationManager.startUpdatingLocation() CLLocationManager's delegate is listening to: func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) The CLLocationManager is starting and correctly giving feedback on 'didFailWithError' and on 'didChangeAuthorization'. Nothing that tells me that something is wrong and points to a problem. No data is sent to didUpdateLocations. The function is never ever called. Of course I'm outside with my watch and the GPS signal is strong and I wait long enough. My app is adding the recorded workout to Apple Fitness app (my app uses HKWorkoutSession) and even though my own app does not receive any CLLocationManager data, the workout that it sent to Apple Fitness includes all the CLLocationManager data. It really seems like being a problem with my app only. Does someone have an idea or knows of a same problem? Thomas
1
0
698
Sep ’23
Has WKExtendedRuntimeSession changed the way timers work in watchOS 10?
I have a stand-alone watchOS app that starts a WKExtendedRuntimeSession and a 1-second repeating timer when a button is pressed. No CPU-intensive stuff happens during this extended (background) time. On watchOS 9, this worked perfectly until I stopped it again (or after the hour I get out of a Mindfulness Session Type has passed, and the extended runtime session expires). The screen could go dark, and the timer would keep running. On watchOS 10, I get about 50 seconds when the screen goes dark, and then the timer just stops. No delegate methods are called (i.e. no "extendedRuntimeSession...willExpire()" or "...didInvalidateWith()" is called), though. Also, the scenePhase does not change at this point, it remains at inactive. The execution just stops. When I tap the watch to turn the screen back on, the timer resumes as if nothing happened. Does anybody know what's going on here? Has something changed in WKExtendedRuntimeSessions in watchOS 10, or is it a bug? I tried removing the timer and changing it to a recursive DispatchAsync.main.asyncAfter block, but it yielded the same result.
1
0
499
Sep ’23
iOS + WatchOS Build: How to automatize?
Hello, Have an iOS App with (extensionless) Watch App. Watch App is not a stand alone app. Watch App appears in the "Frameworks, Libraries & Embedded content" section of the iOS App Target. Nevertheless, I have to manually launch a build of the Watch App before building the iOS app if I want the build to succeed. Is there a way to automatize build in cascade (at least for release scheme and for "Archiving" ?
1
1
468
Sep ’23