I've been seeing warning like the following with my Apple Watch app:
=== AttributeGraph: cycle detected through attribute 140952 ===
=== AttributeGraph: cycle detected through attribute 131640 ===
=== AttributeGraph: cycle detected through attribute 131640 ===
=== AttributeGraph: cycle detected through attribute 131640 ===
=== AttributeGraph: cycle detected through attribute 131640 ===
=== AttributeGraph: cycle detected through attribute 131640 ===
=== AttributeGraph: cycle detected through attribute 131640 ===
I've done some debugging with Instruments and Xcode, I've determined that its caused by adding a
.toolbar {
ToolbarItemGroup(placement: .topBarTrailing) {
Label("Stop", systemImage: "xmark")
}
}
to an item within my NavigationSplitView List Destination view.
To aid reproduction of this issue even more, I've verified the same warning occurs with the Apple sample code from the WWDC23 Backyard Birds app.
https://developer.apple.com/documentation/swiftui/backyard-birds-sample?changes=_9
If you take the Apple sample code, open it in Xcode 15.4 and run it in the Apple Watch WatchOS 10.5 simulator, then select the Bird Springs item, all is well.
If you then add the above toolbar code to the BackyardSummaryTab file at the bottom of the VStack, you'll see the same AttributeGraph issues I'm seeing in my app.
Is this a bug? I can't understand why adding a static ToolBarItem in WatchOS is causing this.
I've seen this issue in the simulator and also on device.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
It's fairly well know and stated that the Apple Health / HealthKit data store is unavailable when iPhone is locked.
Since Lock Screen Widgets were introduced there's been a feature parity mismatch with Apple's own Fitness app which is able to display updating Activity Rings on the Lock Screen. Third party apps cannot do this and have to rely unlocking their device to then trigger an update. This means they often display stale and wrong Health data.
With the release of iOS 18 beta, I see no changes to this... Is there anything I've missed?
Currently for requesting the Timeline Updates on my Widget I have to just keep requesting updates as often as possible and hope that each time the iPhone might be unlocked.... This is inefficient and a waste of device resources. Even a Widget timeline reload API that let the developer say "Only call update if iPhone unlocked" would be useful.
Topic:
App & System Services
SubTopic:
Health & Fitness
Tags:
iOS
Health and Fitness
HealthKit
WidgetKit
I'm looking to migrate my users ClockKit complications to WidgetKit in my next app update. I can only do this for WatchOS 10 users because the APIs are too limited for WatchOS 9 (eg. Widget corner round text not available). But I do need to do this for WatchOS 10 users in order to get in the Smart Stack.
When I tried to mark my getWidgetConfiguration method in my ComplicationController.swift with:
@available(watchOS 10.0, *)
it complains and says: Protocol 'CLKComplicationWidgetMigrator' requires 'getWidgetConfiguration(from:completionHandler:)' to be available in watchOS 9.0 and newer
I then tried modifying my WidgetKit extension to only support WatchOS 10. This seems to work for a while but at some point WatchOS 9 devices still try the migration and crash with symbolNotFound DYLD issues for the WidgetKit extension which shouldn't even be embedded in the WatchOS 9 builds! (all visible in iPhone Analytics data crashes)
So I'm not sure what else to try. I've researched a lot in docs etc... but can find no official way to achieve this.
Topic:
App & System Services
SubTopic:
General
Tags:
watchOS
WidgetKit
wwdc2023-10029
wwdc2023-10309
How can I open the user's Health Privacy Settings directly from my app when I'd like them to review them?
I believe similar questions have been asked before like this one: https://forums.developer.apple.com/forums/thread/730434
However, I'm wondering if the situation is changed for iOS 17 or if there's a way that works for Health permissions.
This is directly possible in the Garmin Connect app for example which is a major app on the store.
I'm seeing problems with the new Apple Watch Modular Ultra Watch face...
This is all using the latest WatchOS 10.1 and with WidgetKit complications. (Have also tested with the new WatchOS 10.2 beta in the simulator)
The Graphic Circular (accessoryCircular) complications space the numbers differently sometimes causing maximum and minimum numbers to look like one long number (see small circular complications in screenshot)
The exact same complication in the accessoryRectangular on the Modular Ultra face clips text when it doesn't on any other watch face
I've filed feedback FB13344580
Hopefully the screenshots show the issue well.
My app's Widgets on iPhone rely on access to the Health Store to update. This makes them appearing in the new StandBy mode not a good experience as they never update.
Is there a way to opt out of this mode but keep the options for my users to put Widgets on their home screen?
Thanks
I'm having a problem in my app where when the use dismisses the side bar in a NavigationSplitView, the TabView on the detail view animates with a glitch to an offset page position.
I've simplified the issue into a Single View which can be previewed in Xcode. This issue occurs on real hardware and in the simulator.
This issue only occurs in landscape on iPad when dismissing the sidebar.
Here is the code:
struct ContentView: View {
@State var pageIndex = 9
var body: some View {
NavigationSplitView {
Text("AppSidebarList")
} detail: {
TabView(selection:$pageIndex) {
ForEach(0..<10, id:\.self) { i in
ScrollView(.vertical, showsIndicators: false) {
Text("Page \(i)").padding(.top,50)
Rectangle().fill(Color.red)
.frame(height:25).frame(maxWidth:.infinity)
.padding()
}
}
}.tabViewStyle(.page(indexDisplayMode: .never))
}.accentColor(Color.indigo)
}
}
Here is the preview before selecting anything:
This is then the expected behaviour after selecting the button top left to hide the sidebar:
But instead the transition animation glitches and I get this:
Note, the page is offset as indicated by the red bar. I've tried playing around with frame of maxWidth:.infinity.
This issue does not happen if the iPad is in portrait, this seems to be because the sidebar in this mode overlays the detail view, where as in portrait they share the space and the detail view resizes to fill the space.
Note the page index, it's the app behaviour that the TabView shows a selection of pages with the last one being the default and the user swiping backwards through. This issue does not occur if the default pageIndex is 0
Either this is a bug or there's a work around or I'm not using something correctly. It would be good to establish which.
Many thanks
Relative Date labels on WatchOS complications do not update when in the .WidgetLabel section modifier. Am I missing anything?
For example if I want a .accessoryCircular complication in the top centre middle of the Infograph Watch Face, I can have maybe an Icon for the app in the circular slot and then use the .WidgetLabel modifier to display text. However, the Text(Date(), style: .relative) will not update in the WidgetLabel area, but it will update in main area. This is a bug I suspect. This same problem also exists with the .accessory corner complications and the WidgetLabel.
The best example of where this works fine currently in the WatchOS system is the Heart Rate complication. Here the WidgetLabel text shows the relative date. It also has formatting options for the date (like only showing minutes), none of this is available to third party developers.
Have tested this on the latest public releases of iOS, WatchOS & Xcode as well as the new iOS 17, WatchOS 10 and Xcode 15 Beta releases.
Example Code:
import SwiftUI
import WidgetKit
struct WatchWidget: Widget {
let kind: String = "WatchWidget"
var body: some WidgetConfiguration {
StaticConfiguration(kind: kind, provider: TimelineProvider()) { entry in
Text(Date(), style: .relative)
.widgetLabel { Text(Date(), style: .relative) }
}
.configurationDisplayName("WatchWidget")
.description("WatchWidget")
.supportedFamilies([.accessoryCircular, .accessoryCorner])
}
}
I'm trying to ensure my watch app launches as quickly as possible. I'm using the @WKApplicationDelegateAdaptor because of needing to implement the BackgroundRefresh handlers.
What I'm finding is that the time between the app calling the main init() and then the ExtensionDelegate calling applicationDidFinishLaunching is often > 2 seconds.
I've tried using Instruments to profile the App launch but have never had any luck with the tool on a watch app.
So I then created a blank project just with the elements needed to implement the same WKApplicationDelegateAdaptor and oslog calls, performance was the same... This is tested on WatchOS 9.5 & 9.5. This is on a Series 6 and Series 8 Apple Watch (FYI S6 == S7 == S8 for Apple Watch CPU performance)
Interestingly, on the simulator, the time gap was less, more like 1 second between main init() and applicationDidFinishLaunching.... not sure why this would be this way.
Anyway, for real world device usage, is this the best performance I can expect? Is there anything that can be done to improve this?
Topic:
Developer Tools & Services
SubTopic:
Instruments
Tags:
Instruments
WatchKit
watchOS
wwdc2022-110362
For Apple Watch complications displayed on tinted faced, developers can use:
@Environment(\.complicationRenderingMode) var renderingMode
to see if the watch face is tinted. You can then use the
.complicationForeground()
modifier to set elements of the complication to match that tint color. (I appreciate that
.complicationForeground()
is now deprecated in favour of
.widgetAccentable()
but I believe the behaviour is the same).
However, this can only be applied to a view I believe. I'd like to display a Swift Chart where only certain elements of the chart have the
.complicationForeground()
rather than the whole chart.
For example, in one case I'd like the LineMark to pop with the tinted color of the complication whilst the rest of the complication get the gray default tint.
Is there a way to do with with the current APIs?
Thanks
Topic:
App & System Services
SubTopic:
General
Tags:
WatchKit
watchOS
Watch Complications
Swift Charts
On my Watch app pre-WatchOS 9 I had code as follows:
`
TabView {
NavigationView {
TodayView(model: delegate.model)
.navigationBarTitleDisplayMode(.large)
}
NavigationView {
SettingsView(model: delegate.model)
}
}
.tabViewStyle(.page)
However, for WatchOS 9 I'm using the new NavigationStack like this:
`
NavigationStack {
TabView {
TodayView(model: delegate.model)
.navigationBarTitleDisplayMode(.large)
The issue is, with WatchOS 9 the title always displays as .inline and never large. I've tried embedding a list or scroll view. I've also tried placing a navigationView within the NavigationStack and TabView, that just makes duplicate titles.
So, using the NavigationStack with a TabView on WatchOS 9, how do you get large titles?
Thanks
I'm trying to create a UI layout and navigation functionality similar to the Apple Fitness app on Apple Watch.
This is all WatchOS 9 so no need for older API support, phew!
I want to have NavigationTitle set for each view in a TabBar.
I want each selected NavigationDestination to hide the TabBar controls and disable swiping when opened.
I want the NavigationTitle and update to remain whilst navigating between Tabs and Childs.
I've created this sample code based off the Building a productivity app for Apple Watch sample code from Apple and other examples on navigation with the new NavigationStack in WatchOS 9, iOS 16 etc...
import SwiftUI
@main
struct Test_Watch_App_Watch_AppApp: App {
@SceneBuilder var body: some Scene {
WindowGroup {
TabView {
NavigationStack {
ScrollView {
VStack {
NavigationLink("Mint", value: Color.mint)
NavigationLink("Pink", value: Color.pink)
NavigationLink("Teal", value: Color.teal)
}
}
.navigationDestination(for: Color.self) { color in
Text("Hello").background(color)
}
.navigationTitle("Colors")
}
NavigationStack {
ScrollView {
VStack {
NavigationLink("headline", value: Font.headline)
NavigationLink("title", value: Font.title)
NavigationLink("caption", value: Font.caption)
}
}
.navigationDestination(for: Font.self) { font in
Text("Hello").font(font)
}
.navigationTitle("Fonts")
}
}.tabViewStyle(.page)
}
}
}
The problem here is, when selecting any of the Navigation Links, the child view still displays the Tab Bar page indicators and allows you to swipe between the tabs, I don't want this. The functionality as I'd like exists int eh Apple Fitness app on the Watch. The app launches in the Activity Tab. You can swipe across to Sharing, select a person, and in that view it's not then possible to swipe straight back to Activity.
I've tried Embedding the whole TabView in a NavigationStack and removing the NavigationStacks per tab. This works as far as fixing the child views hiding the TabBar page indicator controls and swiping. However, it then breaks NavigationTitles on launch and when moving in and out of Childs, so I don't think it should be this way.
Any help very appreciated.
I supported the Always-On display in my app complications from day one but since am continuing to find animation glitches and bugs that have never been fixed and exist currently on WatchOS 8 & 9 (I've tried Series 6 & 8 devices). I'm thinking about scrapping it and just returning the handler(nil).
Does anyone have an example of where they use it and it really adds value to their app complications? And do they have any suggestions to try and work around the glitches?
Thanks
Topic:
App & System Services
SubTopic:
Core OS
Tags:
watchOS
Watch Complications
Apple Watch
ClockKit
I’m having an issue with an app I’ve developed where it grinds to a halt and freezes when using the TabView with a certain iOS Setting enabled.
To simplify things, I can easily reproduce this with a demo project.
Launch Xcode 12.5, start a new iOS project with swift, swiftUI lifecycle and SwiftUI interface. Then replace the Text code in the content view body with ithe following simple code:
TabView {
Text("Hello, world! Tab 1")
.tabItem {
Label("Tab 1", systemImage: "list.dash")
}
Text("Tab 2")
.tabItem {
Label("Tab 2", systemImage: "list.dash")
}
}
If you launch and run this on device or on the simulator, it all works fine. You can click between the tabs etc…
However, if you navigate to the iPhone settings (and this is available in the simulator) and go Accessibility -> Keyboards -> Full Keyboard Access and toggle this ON, it causes a problem.
When re-opening the app we just made, as soon as you select a tab at the bottom, the app CPU usage jumps to 100%+ and grinds to a halt. The only fix is to force quite the app, but the issue persists on re-launches until you disable Full Keyboard Access.
Is this a bug? Or am I missing something? It seems to have been around throughout iOS 14’s life time.
Thank you
Classically, the demo in the Meet WidgetKit video used a Calendar as an example, where clearly the times to update are simple to calculate based on when the users events will occur.
I'd like to know about the Activity/Fitness Widget. There's no way to tell when a user will burn that next calorie and as far as I can tell, there's still no background observer in HealthKit you can use to call an update on changes. So, with that in mind, how often should I call to update?
This same dilemma applies to ClockKit and WatchOS complications.