The following WatchOs App example is very short, but already not functioning as it is expected, when using Digital Crown (full code):
import SwiftUI
struct ContentView: View {
let array = ["One","Two","Three","Four"]
@State var selection = "One"
var body: some View {
Picker("Array", selection: $selection) {
ForEach(array, id: \.self) {
Text($0)
}
}
}
}
The following 2 errors are thrown, when using Digital Crown for scrolling:
ScrollView contentOffset binding has been read; this will cause grossly inefficient view performance as the ScrollView's content will be updated whenever its contentOffset changes. Read the contentOffset binding in a view that is not parented between the creator of the binding and the ScrollView to avoid this.
Error: Error Domain=NSOSStatusErrorDomain Code=-536870187 "(null)"
Any help appreciated. Thanks a lot.
Posts under watchOS tag
200 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I have an iPhone 14 running iOS 16.1 and my series 5 watch running watchOS 9.1. I was able to turn on Developer Mode on the phone by going to Settings--> Privacy & Security --> Developer Mode. On the watch however (I'm doing this directly on the watch and not on the watch app on the phone) once I'm in Privacy & Security, there is no option to select Developer Mode. How do I get my watch in Developer Mode in order to get a successful build in xCode?
Target: WatchOS 10.5
NOTE: This is a watchOS only app
Given:
A single view containing NavigationSplitview, with the List in the "sidebar", a TabView in the "detail" and a TabView in a sheet attached to each tab in the "detail" view.
When:
Navigating between top-level list and "detail" TabView, or navigating through "detail" to "sheet" TabView
Then:
Memory leaks occur.
If the TabView() views are replaced with List() views there are no longer memory leaks.
There are no reference types involved. Everything is in Structs
Code below causes the issue which can be observed in Instruments.
So my question is what have I coded incorrectly to cause this issue? Or, How can I fix this?
Thanks in advance.
@main
struct VerticalTabView_MemLeak: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
struct ContentView: View {
struct ParentItem: Identifiable, Hashable {
var id = UUID()
var name: String
var children: [Item]
init(_ name: String, _ children: [Item]){
self.name = name
self.children = children
}
}
struct Item: Identifiable, Hashable {
var id: UUID = UUID()
var name: String
init(_ name: String){ self.name = name }
}
@State var selectedParentItem: ParentItem?
@State var selectedItem: Item?
var parentItems = [
ParentItem("A", [Item("one"),Item("two"),Item("three")]),
ParentItem("B", [Item("four"),Item("five"),Item("six")]),
ParentItem("C", [Item("seven"),Item("eight"),Item("nine")])
]
var body: some View {
NavigationSplitView {
List(selection: $selectedParentItem) {
ForEach(parentItems, id: \.id) { parentItem in
NavigationLink(value: parentItem) {
HStack {
Text(parentItem.name)
}
.padding()
}
}
}
.navigationTitle("Top Level")
} detail: {
if let items = selectedParentItem?.children {
TabView(selection: $selectedItem) {
ForEach(items, id:\.id) { item in
Text(verbatim: item.name)
.tag(item)
.onTapGesture {
selectedItem = item
}
}
}
.tabViewStyle(.verticalPage)
.navigationTitle(selectedParentItem?.name ?? "")
.sheet(item: $selectedItem,
onDismiss: { selectedItem = nil },
content: { item in
TabView {
Text(item.name).foregroundStyle(.yellow)
Text(item.name).foregroundStyle(.yellow)
}
.tabViewStyle(.verticalPage)
.navigationTitle(selectedParentItem?.name ?? "")
})
}
}
}
}
#Preview {
ContentView()
}
Starting from Xcode 16 Beta 2, NSValue.CGSizeValue is no longer available on watchOS, whereas this method was supported in previous versions of Xcode. The Xcode header files mark this method as unavailable on watchOS, but after manually modifying the Xcode files to remove the unavailable macro, the code compiles and runs normally. Is there a change in this API that makes it unsupported on watchOS, or is this an error?
Previously, I submitted feedback FB14072192, and the status of this feedback was updated to "Unable to diagnose with current information" without any further response. If this is indeed an issue, I hope it can be fixed.
I have a watchOS app written in C++, Swift and SwiftUI. This app is meant only for 64-bit architecture. I know Apple uses the arm architecture, so I thought arm64 will be the arch of latest AppleWatches.
I tested my code in x64 simulator (Intel Mac) and arm64 simulator (silicon Mac) - no trouble. Next is to test on a device - AppleWatch Series 9, model: A2984. I set the arch to arm64 and my application failed to build, with Xcode showing a popup about arch mismatch... which is due to the app's arch begin different from device's arch. When I change Xcode arch setting to arm64_32, then I don't get this popup, but my builds fail. When I read about arm64_32, I realised that this is a version of arm64 with 32 bit pointers... not the arm64 with 64 bit pointers.
Looking at the specification of AppleWatch Series 9, Apple has confirmed that it has 64 bit CPU, but the instruction set is unknown. This wiki page about different AppleWatch CPUs is marked TBC for AppleWatch Series 9. From Xcode, I got to know that this unconfirmed arch is arm64_32. This completely breaks my code. Are there any 64-bit watches with 64-bit pointer sizes? What is Apple's future in this area? Do they plan to release AppleWatches that support 64-bit pointers or it's always going to be 32?
Hi,
Suddenly product's are not being loaded on WatchOS anymore, no error throwing.
Just empty array response...
Works normal on iOS. Any idea why?
WatchOS 10.5
During WatchOS 10 dev betas and now into 11 dev betas, I am still seeing were stands are not being detected. What I do not know is if the steps are detected. But here is the situation.
Today:
I was going on some wiring outside and in the basement.
I was clearly up and moving around for over an hour.
I can see on my camera's I went outside at 15:50, came back in at 16:18. Then went to my basement and was working down there from 16:19 until 16:30. After that cleaned up my mess. So I was up and down stairs and without a doubt standing. At 16:50 I got the reminder to stand.
Other cases:
1: I get home from work about XX:10 . I have to walk about 50 ft from my garage to my house, up stairs, take the dog out, make dinner, and finally get my chair to eat and at XX:50 I get the reminder.
2: I'm at work, I'm going to get lunch and I have to walk pretty far and again at XX:50 I get the reminder. This is very rare, but it has happened.
Now, in a odd twist. I get up in the morning at XX:50, I have 10 steps to the bathroom, and I manage to get that hourly stand.
I have a watchOS app where a user can select a picture. I’d like the picture to be displayed in a complication. I’m using WidgetKit, and I found out that for some watch faces (rendering mode = accented), the image gets tinted. Instead of the picture, the user sees only a colored box.
It appears that using the old framework, ClockKit, it was possible to display an image that gets slightly colored with the tint color on tinted watch faces. I believe this is to ensure backward compatibility of old complications.
My question is: can I do the same using WidgetKit? I tried using the widgetAccentable() modifier, but it doesn’t work.
Here's an example of what I mean. In the middle complication, instead of the pink square, I'd like to display the user picture.
I am developing a watchOS-only app, and whenever I attempt to make a network request, it always fails and throws the following error:
Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline."
I noticed that when I turn off Wi-Fi and Bluetooth in the settings of the iPhone paired with the Apple Watch (thus disconnecting the Apple Watch from the iPhone), my app can successfully connect to the network.
Additionally, when the app contains both an iOS app and a watchOS app, after granting network permissions on the iOS app, the watchOS app can access the network normally when connected to the iPhone.
When opening some system apps on the Apple Watch (such as the "Workout" app), the app will display a network permission request similar to that on iOS, but this request does not automatically pop up when my watchOS app attempts to access the network.
Is there a way to request network permissions in a watchOS-only app so that it can access the network while connected to the iPhone?
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.
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.
So I am banging my head, I realized my stand along Watch App had a STUPID long name of "App Name - WatchKit App" so I went into my Target and changed the Display Name to "App Name" removing WatchKit App. Well now my app won't validate when uploading to the Appstore. I get the message - Invalid Info.plist key. The key
WKExtensionDelegateClassName in bundle App Name.app/Watch/App Name WatchKit App.app is invalid.
My Info.plist has the value of
<key>WKExtensionDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).ExtensionDelegate</string>
I have confirmed that I have @WKExtensionDelegateAdaptor(ExtensionDelegate.self) var delegate in my @main for the SwiftUI App. And when I print a few values in my app launch I get the following confirmations:
Super Init - ExtensionDelegate
Contentview
applicationDidFinishLaunching for watchOS
Super Init - ExtensionDelegate
Optional(My_App_Extension.Setup)
Optional(My_App_Extension.Statistics)
Optional(My_App_Extension.Other)
applicationDidBecomeActive for watchOS
update complication
I create three classes at launch and print this in the log with print(ExtensionDelegate.shared.Setup as Any) , etc. The other lines are just confirming where I am at app startup.
This is a WatchOS8 application and I am running Xcode version Version 13.1 (13A1030d).
I have installed IOS18 and WatchOS11 Beta 3 already... all complications sent to clock (usign FACER app) is not showing up... they all appears DISABLED.
doesnt matter what face watch i use.., its all disabled.
Any help on it please????
We are migrating ClockKit complications to WidgetKit in our watch app (watchOS 9+). The migration went smoothly, UI part works just fine. However, we've hit the wall with widgets not updating when requested by the watch app. I believe we are missing something very simple and fundamental, but couldn't find what exactly so far. Advice and tips would be very welcome! 🙇♂️
Our implementation details:
Whenever data is changed in the main app, the updated data is submitted to the watch app via WatchConnectivity framework using WCSession.default.transferCurrentComplicationUserInfo(_:). According to documentation, this method should be used to transfer complication-related data, since it will wake the watch app even if it is in the background or not opened at all.
Watch app receives updated data and stores it in UserDefaults shared with Watch Widget Extension hosting WidgetKit complications via App Group.
Watch app then request widget timeline reload via WidgetCenter.shared.reloadAllTimelines(). According to documentation, it reloads the timelines for all configured widgets belonging to the containing app, so it seems the appropriate way to reload WidgetKit complications.
Widget Timeline Provider class in Watch Widget Extension reads updated data from shared UserDefaults and uses it to provide the updated snapshot for widget views to render.
We believe our implementation logic is correct, but it doesn't work, for some reason. Widgets sometimes update when the watch app is opened, but not always. The most definitive way to force widgets to update is to switch to a different watch face, which confirms that the Widget Timeline Provider has access to properly updated data.
P.S. We are aware of the daily reload budget imposed on widgets, so we use widgets reload trigger sparingly. Anyway, according to documentation, reload budget is not effective when in DEBUG mode, but widgets won't reload even in DEBUG mode.
Thank you!
I have started to work on adding Live Activities to my app in watchOS 11. The app already has interactive Live Activities on the phone that works as expected.
I have added a view for the activityFamily: small and it shows up as expected.
My problem is that buttons doesn't work. I use the Intent based button, and on the iPhone Lock Screen they work. On the watch, nothing happens.
Has anyone got this working? Not sure if I'm missing something or if it's a bug.
After updating to iOS 17.5 & WatchOS 10.5, the didFinish response from WCSessionDelegate does not come when transferring files from iPhone to Watch.
It worked normally until 17.4 & 10.4.
There is no problem with checking file completion even if a didFinish response is not received, but I think Apple needs to check this issue and update.
File transfer is done using the transferFile function of WCSession.
The file being transferred is a single file and its size does not exceed 30MB.
When you try to transfer Pi, the message below appears in the Xcode log section.
-[WCFileStorage persistOutgoingFileTransfer:] error serializing file transfer <WCSessionFileTransfer: 0x300155d60, session file: <WCSessionFile: 0x3001575c0, identifier: 0C8857EC-7D74-4E78-BA28-6C5526DE8949, file: /private/var/mobile/Containers/Data/Application/DD797847-DED1-42C0-989F-34CD05825007/tmp/C042D096-F12B-4B50-8792-868475DBBF47.zip, hasMetadata: YES>, transferring: YES> due to Error Domain=NSCocoaErrorDomain Code=4866 "Caught exception during archival: This object may only be encoded by an NSXPCCoder.
(
0 CoreFoundation 0x000000019b064f2c 00E76A98-210C-3CB5-930B-F236807FF24C + 540460
1 libobjc.A.dylib 0x0000000192ef6018 objc_exception_throw + 60
2 Foundation 0x0000000199fe7778 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 1419128
3 Foundation 0x0000000199ea0e14 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 81428
4 WatchConnectivity 0x000000021d055f60 1AB4DDD6-9238-3965-B744-819F2916C8CC + 126816
5 Foundation 0x0000000199ea0e14 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 81428
6 WatchConnectivity 0x000000021d0567f0 1AB4DDD6-9238-3965-B744-819F2916C8CC + 129008
7 Foundation 0x0000000199ea0e14 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 81428
8 Foundation 0x0000000199f30628 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 669224
9 WatchConnectivity 0x000000021d0583ac 1AB4DDD6-9238-3965-B744-819F2916C8CC + 136108
10 WatchConnectivity 0x000000021d04390c 1AB4DDD6-9238-3965-B744-819F2916C8CC + 51468
11 WatchConnectivity 0x000000021d046640 1AB4DDD6-9238-3965-B744-819F2916C8CC + 63040
12 Foundation 0x0000000199ea9be0 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 117728
13 Foundation 0x0000000199ea9aa0 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 117408
14 Foundation 0x0000000199ea98a0 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 116896
15 Foundation 0x0000000199ea7b40 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 109376
16 Foundation 0x0000000199f2c558 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 652632
17 Foundation 0x0000000199f2c1a4 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 651684
18 libdispatch.dylib 0x0000000105ed7764 _dispatch_block_async_invoke2 + 148
19 libdispatch.dylib 0x0000000105ec67bc _dispatch_client_callout + 20
20 libdispatch.dylib 0x0000000105ec98e0 _dispatch_continuation_pop + 676
21 libdispatch.dylib 0x0000000105ec8bb8 _dispatch_async_redirect_invoke + 680
22 libdispatch.dylib 0x0000000105edaae4 _dispatch_root_queue_drain + 404
23 libdispatch.dylib 0x0000000105edb4d8 _dispatch_worker_thread2 + 188
24 libsystem_pthread.dylib 0x00000001f7ebb8f8 _pthread_wqthread + 228
25 libsystem_pthread.dylib 0x00000001f7eb80cc start_wqthread + 8
)" UserInfo={NSDebugDescription=Caught exception during archival: This object may only be encoded by an NSXPCCoder.
(
0 CoreFoundation 0x000000019b064f2c 00E76A98-210C-3CB5-930B-F236807FF24C + 540460
1 libobjc.A.dylib 0x0000000192ef6018 objc_exception_throw + 60
2 Foundation 0x0000000199fe7778 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 1419128
3 Foundation 0x0000000199ea0e14 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 81428
4 WatchConnectivity 0x000000021d055f60 1AB4DDD6-9238-3965-B744-819F2916C8CC + 126816
5 Foundation 0x0000000199ea0e14 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 81428
6 WatchConnectivity 0x000000021d0567f0 1AB4DDD6-9238-3965-B744-819F2916C8CC + 129008
7 Foundation 0x0000000199ea0e14 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 81428
8 Foundation 0x0000000199f30628 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 669224
9 WatchConnectivity 0x000000021d0583ac 1AB4DDD6-9238-3965-B744-819F2916C8CC + 136108
10 WatchConnectivity 0x000000021d04390c 1AB4DDD6-9238-3965-B744-819F2916C8CC + 51468
11 WatchConnectivity 0x000000021d046640 1AB4DDD6-9238-3965-B744-819F2916C8CC + 63040
12 Foundation 0x0000000199ea9be0 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 117728
13 Foundation 0x0000000199ea9aa0 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 117408
14 Foundation 0x0000000199ea98a0 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 116896
15 Foundation 0x0000000199ea7b40 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 109376
16 Foundation 0x0000000199f2c558 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 652632
17 Foundation 0x0000000199f2c1a4 3D3A12E3-F5E9-361F-B00A-4A5E8861AA55 + 651684
18 libdispatch.dylib 0x0000000105ed7764 _dispatch_block_async_invoke2 + 148
19 libdispatch.dylib 0x0000000105ec67bc _dispatch_client_callout + 20
20 libdispatch.dylib 0x0000000105ec98e0 _dispatch_continuation_pop + 676
21 libdispatch.dylib 0x0000000105ec8bb8 _dispatch_async_redirect_invoke + 680
22 libdispatch.dylib 0x0000000105edaae4 _dispatch_root_queue_drain + 404
23 libdispatch.dylib 0x0000000105edb4d8 _dispatch_worker_thread2 + 188
24 libsystem_pthread.dylib 0x00000001f7ebb8f8 _pthread_wqthread + 228
25 libsystem_pthread.dylib 0x00000001f7eb80cc start_wqthread + 8
)}
I'm trying to create a Apple Watch game using Xcode 14.2 and watchOS 9. Getting started creating a watchOS App seems pretty straight forward, and getting started creating a game project via the starter template seems easy enough. Trying to put these two together though doesn't seem to work (or is not straight foward). The documentation specifies limitations on what libraries can be used with watchOS noting WKInterfaceSKScene, but doesn't give any specific examples of how to start out a WatchOS project using this. Additionally nearly every online tutorial that I'm able to find uses Storyboards to create a watchOS game, which does not seem to be supported in the latest version of watchOS or Xcode. Can anyone provide example starter code using the watchOS App project starter that that loads with a small colored square on the screen that moves from left to right using the WKInterfaceSKScene library?
I've tried the Apple documentation, asking ChatGPT for a sample or reference links, and various tutorials on YouTube and elsewhere.
Looking into making requests using URLSession via a proxy, on watchOS, and found that in URLSessionConfiguration, there's a proxyConfigurations property.
However, since ProxyConfiguration is part of the Network framework, does it means that TN3135 low level networking rules also applies in this case?
Hello,
I have an iOS app and a companion watchOS app. Users record a workout on Apple Watch, the data for which is then transferred using both Watch Connectivity and Core Data + CloudKit (NSPersistentCloudKitContainer) to their iPhone, where it is processed and displayed.
As users are recording the workout on their Apple Watch, when they finish and the transfer begins, their iPhone is often not reachable to immediately send the data using Watch Connectivity and they have no network connection (cellular or Wi-Fi).
With Watch Connectivity I use transferFile from WCSession, which queues the file for transfer. With Core Data + Cloudkit I save the data and the export is queued.
An undetermined amount of time may pass until the user returns to their iPhone or connects to Wi-Fi and most of the time neither of the transfer methods actually transfers the data until the user opens the watchOS app into the foreground, at which point the transfer happens immediately for both methods.
I've tried a number of things already, without success, such as:
Using sendMessage from WCSession to send an immediate message to the watchOS app when the iOS app returns to the foreground to try and wake the watchOS app up so it can complete the data transfer.
On the watchOS app, after attempting to transfer the data, using downloadTask from URLSession to queue a background task to download something, in the hope that it would wake the watchOS app when network connectivity was restored and enable it to complete the data transfer.
On the watchOS app, instead of saving the data using NSPersistentCloudKitContainer, using CKRecord and CKDatabase directly to save the data using userInitiated as the quality of service, in the hope that it would be exported once network connectivity was restored.
Is there a way to trigger the watchOS app to transfer the data using Watch Connectivity or Core Data + CloudKit in the background when reachabillity or network connectivity is restored, even if the app may have been suspended by watchOS?
Many Thanks,
Alex
I'm excited to bring my Live Activity to Apple Watch via the .supplementalActivityFamilies([.small]) modifier.
However, I'm also wondering whether it is possible for my watchOS app, separately, to initiate a Live Activity and receive updates for it via push notification. From my testing it seems like no, but the function call itself can be made, since ActivityKit is available on watchOS.
Are there any other recommendations for how to go about initiating a Live Activity from a watchOS app? Would I have to communicate with a companion iOS app to start the Live Activity on the phone instead?