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

131 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

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
987
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
644
Sep ’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
376
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.1k
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
488
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
376
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
362
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
397
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
408
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
409
Oct ’23
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
769
Oct ’23
Migrating from CoreData to SwiftData causes crashes on Watch app
I'm working on migrating my app from using CoreData to SwiftData. The swift data code generated by Xcode works correctly for the iOS and Mac Catalyst targets but it is causing a crash for the WatchOS target. It gives me this message **Fatal error: Application must register a ValueTransformer for NSSecureUnarchiveFromDataTransformer ** This attribute is the only one with a .transformable option. @Attribute(.transformable(by: "NSSecureUnarchiveFromDataTransformer")) public var linkedEntities: [UUID] = [] Changing the string NSSecureUnarchiveFromDataTransformer to NSValueTransformerName.secureUnarchiveFromDataTransformerName.rawValue causes a generic crash with no error message. The app has CloudKit integration as well (not sure if relevant). Does anyone have a similar issue and can help me on what to do here?
2
0
610
Nov ’23
Is there somehow to change automatically my Bundle Identifier for my Companion App?
Hello! In my project here we have 3 build modes / schemas for our iPhone app: Dev, Stage, Prod. And each one has one bundle identifier, for example, com.myproject.app-Dev, com.myproject.app-Stage and com.myproject.app. How do I can get each bundle identifier and store it inside the WKCompanionAppBundleIdentifier key automatically? Is it possible? Because, sometimes we need to build manually the Stage version here and XCode says the info.plist key for WatchOS App is different from the iPhone App.
1
0
606
Nov ’23
How to support Siri on a watchOS app with iOS app(play media intent)
Project Info:A music player iOS App with watchOS app embedded. Project Structure: app target: music intent extenstion: intent (for iOS platform) watchOS app target: watchKit watchOS extension: watchKit Extension iOS app use intent extension to support SiriKit with play media intent, it works very well. now i want to support Siri on watchOS app, but i don't know how. i have tried to add new watch extension target, but it doesn't work. i t keeps saying "my app doesn't support *** instruction". Please share if I have missed to read through some documentation / reference that solves this problem.
0
0
525
Nov ’23