Post

Replies

Boosts

Views

Activity

EXC_BREAKPOINT in BGAppRefreshTask
When I run my app with XCode on my iPhone, and then moved into the background, I'm getting a EXC_BREAKPOINT exception after a few minutes, seemingly when iOS attempts to call my app with a BGAppRefreshTask: Thread 23 Queue: com.apple.BGTaskScheduler (com.mycompany.MyApp.RefreshTask) (serial) 0 _dispatch_assert_queue_fail 12 _pthread_wqthread Enqueued from com.apple.duet.activityscheduler.client.xpcqueue (Thread 23) 0 dispatch_async 20 start_wqthread I can't quite understand the reason from this crash. In the background task, I'm attempting to update live activities. In the process, it might encounter code that calls MainActor and manipulate @Observable objects. Might that be the reason?
2
0
262
2w
Live Activity without Dynamic Island
Is it possible to display a live activity on the lock-screen without a dynamic island? Or at least without expanding the dynamic island more than just for a small icon? struct SomeWidgetLiveActivity: Widget { var body: some WidgetConfiguration { ActivityConfiguration(for: SomeAttributes.self) { context in } dynamicIsland: { context in DynamicIsland { DynamicIslandExpandedRegion(.leading) { // Seems to be mandatory, any way around it? } } compactLeading: { } compactTrailing: { } minimal: { } } I couldn't quite find a way. Thank you
0
0
234
Jan ’25
Workouts fail to register on Fitness activity rings
Hello, My app syncs workout data from a third-party device and records workouts with HealthKit as follows: let builder = HKWorkoutBuilder(healthStore: healthStore, configuration: hkConf, device: hkDevice) try await builder.beginCollection(at: startDate) try await builder.addSamples(samples) try await builder.endCollection(at: endDate) let workout = try await builder.finishWorkout() let workoutRouteBuilder = HKWorkoutRouteBuilder(healthStore: healthStore, device: hkDevice) try await workoutRouteBuilder.insertRouteData(filteredLocations) try await workoutRouteBuilder.finishRoute(with: workout, metadata: nil) However, I’m encountering two issues: The workouts appear in Apple Fitness but do not contribute to the activity rings. The workout includes a route (visible in the raw workout data in Apple Health) but does not display on Apple Fitness. Is there any way to fix this? I’d appreciate any suggestions you might have. __
2
0
505
Jan ’25
SwiftData and async functions
Hello, I recently published an app that uses Swift Data as its primary data storage. The app uses concurrency, background threads, async await, and BLE communication. Sadly, I see my app incurs many fringe crashes, involving EXC_BAD_ACCESS, KERN_INVALID_ADDRESS, EXC_BREAKPOINT, etc. I followed these guidelines: One ModelContainer that is stored as a global variable and used throughout. ModelContexts are created separately for each task, changes are saved manually, and models are not passed around. Threads with different ModelContexts might manipulate and/or read the same data simultaneously. I was under the impression this meets the usage requirements. I suspect perhaps the issue lies in my usage of contexts in a single await function, that might be paused and resumed on a different thread (although same execution path). Is that the case? If so, how should SwiftData be used in async scopes? Is there anything else particularly wrong in my approach?
3
0
740
Dec ’24
HKCumulativeQuantitySample does not accumulate values
Hi, My app reports daily step counts, and I’m trying to use HKCumulativeQuantitySample to report them to HealthKit by adding such objects with each update: let sample = HKCumulativeQuantitySample(type: .stepCount, quantity: HKQuantity(unit: HKUnit.count(), doubleValue: dailyTotal), start: startOfDay, end: nowDate) However, HealthKit interprets them as regular samples—it sums them into a global aggregate instead of updating the daily cumulative value. So if I report the daily step count as 500 and then 550, HealthKit interprets it as 1,050 steps instead of 550. Is this expected behavior? If so, what is HKCumulativeQuantitySample intended for, and how should it be used? I’m struggling to find any examples. Thank you
0
0
381
Nov ’24