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

133 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Error creating LLDB target at path - Xcode 12
I'm using Xcode 12 beta 3. When running my Apple Watch's target on WatchOS 7, I get this error: Warning: Error creating LLDB target at path '/Users/evan/Library/Developer/Xcode/DerivedData/audigo-cneguthkmmoulfgcprsazbryrlrl/Build/Products/Debug-watchsimulator/AudigoWatchApplication.app'- using an empty LLDB target which can cause slow memory reads from remote devices. I know this error use to be when running 32 bit frameworks on 64 bit devices, but I'm not doing that. Is this a bug? Or is there a setting I don't know of that needs to be updated?
20
2
22k
Oct ’23
.sheet no longer dismissable in WatchOS 7?
In WatchOS 6 a presented .sheet could be dismissed by swiping down or tapping on the navigationBarTitle. In the WatchOS 7 beta, presented sheets are no longer dismissible by either method...forcing the addition of a button to dismiss. It appears as if .sheet is now acting as .fullScreenCover within WatchOS 7. Anyone else running into this? Wondering if this is now expected behavior on WatchOS or if it's a bug...
7
0
2.6k
Oct ’23
Minimum deployment Version for older WatchOSs and newer iOSs.
If a "Minimum Deployment Target" is updated to WatchOS7 on a product(iOS app with a companion watch app) that is already available on the App Store, watches running WatchOS6 will obviously no longer get updates. However, what is the experience for a user who has a WatchOS6 (maybe they own a Series 2) connected to an iPhone with iOS14? Will both the iPhone app and the Watch app stop getting updates? Will the Watch app stop getting updates, but the iPhone app continue receiving them and we have to manage this? Something else? Thanks in advance!
2
0
1.4k
Oct ’23
WatchKit sendMessage wakes up iPhone app
According to the docs, calling WatchKit's sendMessage on an Apple Watch app extension wakes up the corresponding iPhone app in the background. This enables the iPhone app to provide the Watch app with data it needs, even if the iPhone app is currently not in the foreground. Unfortunatelly, I cannot find much information about this process. I'd like to know the answer to these questions: Is there a special launchOptions key present when the iPhone app starts up in the background? According to these docs, an empty launchOptions indicates that the user started the app from the home screen - all other startup reasons have their own launchOptions key. However, when testing the wakeup, I get an empty launchOptions. Are there other options that can be used to detect that the iPhone app runs in the background? For example, I expected [UIScreen mainScreen] to be nil because in the background we do not have screens and windows, but there seems to be no difference in mainScreen in the background process. Are there any limits to the background process? For example, is there a limit in how long it can run? Is there a way I can debug such a background process in XCode? Can I tell XCode "wait until the app runs on the iPhone", such that the debugger gets attached as soon as the app runs?
1
0
1k
Aug ’23
I'm confused about WatchKit and WidgetKit and Watch Apps... Help!
Sorry for the length of this post, and all the questions. I have an iOS app written in Objective-C (too big to convert to Swift right now), and I successfully added a WatchKit app and WatchKit Extension some years ago. I also added Home Screen widgets when iOS 14 was released. With the iOS 16 betas I'd like to support Lock Screen widgets, and have also decided to move the WatchKit app/extension to SwiftUI. User journey: MyApp is launched and an item with an image is created. This item is stored in Core Data and its image is stored in a directory in the app's documents directory. A version of it is stored in NSUserDefaults in a shared app group. The user adds a Home Screen widget to show that item. Its data is pulled from the defaults, and the image is loaded from the document's directory. The user installs the Watch app and launches it. The Watch app looks inside the user defaults to retrieve the item. The iOS app sends the image to the Watch and the Watch app stores it locally (it's a small image, taking up barely a few Kb). This all works fine right now. Currently I have these targets: MyApp = main iOS app. MyApp WatchKit = Watch app storyboards and asset catalogs. MyApp WatchKit Extension = code to update the Watch interface. MyApp Widget = Home Screen widgets. MyApp IntentHandler = dynamic intents handler for the Home Screen widgets. Q1. Where do I put the code for the Lock Screen widgets? I figure these go into the My App Widget target because they're widgets and appear on the iPhone? In this video (https://developer.apple.com/videos/play/wwdc2022/10050) at 07:00 it tells you to duplicate the existing Widget target, change the bundle, change it to run on watchOS and embed it in your existing Watch App. As my original Watch App is written in Objective-C (MyApp WatchKit Extension, above) I can't/shouldn't do that, so... Q2. I think I have to create a new MyApp Watch App target, and perform the video steps on that target? I can create the views for that app, no problem. Most people update to the latest watchOS, and it's only now that watchOS 9 won't support Watch Series 3. Q3. Do I need to keep MyApp WatchKit and MyApp WatchKit Extension around? I can support older versions of watchOS if it helps my users, but they'll probably want to use the new version of watchOS, right? Can you install both versions of the app on your Watch (with watchOS 9), or does the new Swift app override the old WatchKit extension? Q4. Once I've designed the new Watch App's views in SwiftUI to replace the old WatchKit extension, where do I put the code for the complications that are being replaced? The WWDC 2022 videos (above, and a couple linked to on that page) have confused me a bit. Do I put complications views in the new MyApp Watch App target along with the other views that replace the old Watch app, or in MyApp Widget? Q5. The MyApp Widget target contains a bunch of code (WidgetUtils.swift) that populates the Home Screen widgets (and the new Lock Screen widgets), and it would fit right into the new MyApp Watch App target. Can I share that code between the two app targets just by adding WidgetUtils.swift to both target's membership? MyApp sends small images to the current MyApp WatchKit Extension. There's no code in the existing WidgetUtils.swift to handle file transfers because the images for the Home Screen widgets are pulled from the iOS app, so I need to write that in Swift for the new MyApp Watch App. The logic is already there in the old target, but I can't see any sort of equivalent to the WatchKit extension delegate where I currently handle the file transfers. Q6. Where does that go in MyApp Watch App? The existing MyApp WatchKit Extension occasionally asks MyApp for some new data. This is all done in the extension delegate which wakes up the iOS app and updates the NSUserDefaults which the extension then reads from. Q7. How do you do that in MyApp Watch App? Don't be afraid to be verbose in your responses. The more detail the better! Thank you in advance.
4
0
2.7k
Oct ’23
Older watch app with extension template, unable to load any saved data from UserDefault watchOS 9 beta 7
Hi all, I am working with an older watch app that still uses the older template that combines the WatchKit App and WatchKit App Extension targets. While trying to migrate the ClockKit complication to the new WidgetKit complication, I cannot get the widget complications to load anything from user defaults. It seems like the widget complications are not using the same user defaults as the watch app though being in the same App Group. I experimented with a new watch app using the new SwiftUI template and the WidgetKit complication was able to load data from user default successfully. Did anyone got WidgetKit complication to load data successfully from user default with the older watch app template? Thanks in advance!
3
0
1.2k
Sep ’23
WatchOS 9 complications with WidgetKit - daily limit.
I am working on an indipendant WatchOS application which received messages from APNS push notifications. There are three kind of messages and each one has it's own widget which represent the current state of the message category. With WatchOS 9, my ClockKit complications are deprecated and I have to migrate to WidgetKit. I did that, but I am having problems with updating the widgets on time. It seems like I am exceeding the widget's daily limit or somehow the OS throttle the updates (they are not instant after the third update in 2 minutes). The main app and the widget extension targets share the data using CoreData. I need to update the widgets every time the database changes. I am currently using WidgetCenter.shared.reloadTimelines(ofKind: ***). I am calling this function when the app is in foreground and thought that the limit should not be a problem, but it looks like it does. Did someone manage to achieve this kind of widgets update?
2
2
1.1k
Aug ’23
The Watch App and iPhone App health care permissions are not synchronized.
I developed an iPhone/Watch app with the single target setting (new method) for Watch app projects, which will be available from Xcode14. This app uses HealthKit to retrieve information such as step count and heart rate from healthcare. The watch app is not independent and requires the iPhone app (companion app). Regarding the permission to access health care, i found some differences from the Old WatchApp Project (application project structure using WatchExtension when Xcode 13.4 or lower is used). This does not occur in the iPhone simulator or watch simulator, but only on the actual device. Both the iPhone app and watch app now display a dialog to allow access to health care In the Old WatchApp Project, if access was granted in either app, the granted access is synchronized. When checking the Health Care access status in the iPhone Settings App, permission settings for both the iPhone app and watch app are displayed independently. Because each permission setting is independent, you can choose to allow access to the iPhone app but not to allow it to the watch app. the Old WatchApp Project, permission settings for the iPhone app and watch app were synchronized, so it was not possible to have different settings for each. These behaviors are not described in the documentation. It would be understandable if the transition from watch "extension" to watch "app" is to split the app into two separate units. However, since there is no official documentation explaining this, i cannot determine whether this is the correct specification or not. Furthermore, since the companion app is required rather than a separate Watch app, having the Health Care permission settings out of sync with the companion app could cause unexpected problems and worsen the user experience. (It would be difficult and cumbersome for the user to know what settings they have made). Is there a solution to synchronize this behavior with the companion app like as the Old WatchApp Project? Do i have to go back to the project configuration (use of watchExtension) before Xcode13? I have prepared a sample project below that can test the above. https://github.com/HayakawaAKIRA/SingleTargetWatchOSApp-HealthKit reference: https://developer.apple.com/videos/play/wwdc2022/10133/ https://developer.apple.com/documentation/watchkit/wkapplication https://developer.apple.com/documentation/healthkit/setting_up_healthkit
6
0
1.9k
Nov ’23
CLKComplicationWidgetMigrator not working
I'm trying to migrate from Complication with CLKComplication to WidgetKit. I have implemented the required methods in https://developer.apple.com/documentation/widgetkit/converting-a-clockkit-app, but the migration is not working. There is no evidence that the method for migration is also called. It was the same with Xcode 14.0.1 and Xcode 14.1RC. class ComplicationController: NSObject, CLKComplicationDataSource, CLKComplicationWidgetMigrator { ...     @available(watchOS 9.0, *)     var widgetMigrator: CLKComplicationWidgetMigrator {         return self     }     @available(watchOS 9.0, *)     func widgetConfiguration(from complicationDescriptor: CLKComplicationDescriptor) async -> CLKComplicationWidgetMigrationConfiguration? {         return CLKComplicationStaticWidgetMigrationConfiguration(kind: "MyWidget", extensionBundleIdentifier: "com.example.myapp.mywatchkitapp.mywidget")     } } What's wrong? Has anyone been able to migrate?
6
1
1.6k
Sep ’23
XCode 14.x, adding Watch to existing and WCSession isWatchAppInstalled = false
I added a Watch app to an existing iOS app using XCode 14.1. (single target template) When using WCSession delegate, so I can message between the apps, I always get isWatchAppInstalled = false. If Icreate the same scenario using XCode 13.x, I have no issues. Has anyone been able to add a watch app to an existing iOS app, create a WCSession object and have isWatchAppInstalled = true? print("Session:activationDidCompleteWith --> IsPaired[(String(describing: session.isPaired))] isWatchAppInstalled[(String(describing: session.isWatchAppInstalled))] isReachable[(String(describing: session.isReachable))]"); displays: Session:activationDidCompleteWith --> IsPaired[true] isWatchAppInstalled[false] isReachable[false]
1
0
1.1k
Dec ’23
Flutter App with WatchOS - Archive Problem
Hi there, I have a problem archiving a Flutter App containing an Apple WatchOS Target. The WatchOS target is built with the new logic, containing only one app and no Watchkit extension. When I build the app on my iPhone/Simulator everything is working just fine and they can communicate without any problems. The error occurs when I'm trying to upload my built archive to App Store Connect for Testflight testing purposes. It fails with the error Asset validation failed: "Missing Info.plist value. A value for the key “WKApplication“, or “WKWatchKitApp“ if your project has a WatchKit App Extension target, is required in “Runner.app/Watch/MyWatchOSApp Watch App.app“ bundle. For details, see: https://developer.apple.com/documentation/watchkit/creating_independent_watchos_apps/setting_up_a_watchos_project". I tried to fix it by adding a info.plist to the WatchOS target, which isn't created initially. By doing so I can not build the Runner App anymore because it fails with "A WatchKit app within this app is not a valid bundle.". Can anyone help me fix it please? Thank you! Greetings
3
1
2.4k
Oct ’23
Name Intent Complications
Hello, I try to add a couple of Complications to my App. Most of the Complications needs to be Configurable, so I use an IntentConfiguration for them. I use this recommendations function to create my complications.     func recommendations() -> [IntentRecommendation<ConfigurationIntent>] {         var recommendations = [IntentRecommendation<ConfigurationIntent>]()        for vehicle in vehicleStatusList {             let intent = ConfigurationIntent() intent.vehicleItem = VehicleItem(identifier: vehicle.id, display: vehicle.name)             recommendations.append(IntentRecommendation(intent:  intent, description: vehicle.name))         }         return recommendations     } But with this I get the result from the screenshot... How can I change this to get a better User Experience? When I click one item in the List, I get a correct Complication. But it would be nice to have a change to name them correctly... The first in the List is a StaticConfiguration...
2
0
1.2k
Oct ’23
Can't Apple Watch App Widget Complication to Update
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
4
1
1.2k
Aug ’23
ClockKit Complications not working with Xcode 14 single-target watchOS app
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
3
1
1.5k
Jan ’24
Xcode 14: WatchKit App doesn't contain any WatchKit Extensions
I am trying to add a watch extension to my existing iOS app. I added a new watch target and I see the new single watch app folder (no extension folder anymore). I also added the watch target as a dependency (embedded content / target dependency) to my app target. I also made sure the bundle identifier of the watch target matches the apps identifier + .watchkitapp But when I try to archive the app and choose validate, I get the error that the watch info.plist is missing the WKWatchKitApp property. So I add it via the Info tab on the watch target. (Which creates a new info.plist file that only contains this single property) When I try again, the build fails with this: Error (Xcode): WatchKit App doesn't contain any WatchKit Extensions. Verify that the value of NSExtensionPointIdentifier in your WatchKit Extension's Info.plist is set to com.apple.watchkit. So I add <key>NSExtension</key> <dict> <key>NSExtensionPointIdentifier</key> <string>com.apple.watchkit</string> </dict> to the watch info.plist but the build error remains. I am a bit lost here, as all questions and tutorials refer to the old Xcode style.
2
0
1.2k
Aug ’23
How to mirror VoIP notification on WatchOS 9 and iOS app?
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.
1
1
1k
Jun ’23