Post

Replies

Boosts

Views

Activity

Is @ObservationIgnored necessary for private var?
In SwiftUI's ViewModel class that are @Observable, is it necessary to annotate private fields as @ObservationIgnored? I'm not sure if adding @ObservationIgnored to these fields will get performance gains, since there are no SwiftUI structs referencing these fields because they're private. However, I'd like to know what's the recommended approach here? While this might not seem obvious for the example below, however, sometimes I have private fields that are changing pretty frequently. For these frequently changed fields, I think the performance gains will be larger. Example: @Observable class UserProfileViewModel { var userName: String? var userPhoneNumber: String? private var isFetchingData = false } vs @Observable class UserProfileViewModel { var userName: String? var userPhoneNumber: String? @ObservationIgnored private var isFetchingData = false }
2
0
617
Sep ’24
CKSyncEngine how to handle new fields added to a CKRecord in future versions
I am seeking guidance on handling field-level schema changes in CKSyncEngine, specifically when introducing new fields in a subsequent app version. The current CKSyncEngine documentation (https://developer.apple.com/documentation/cloudkit/cksyncengine) and the GitHub sample (https://github.com/apple/sample-cloudkit-sync-engine) provide clear instructions for managing changes to existing CKRecords. However, I am uncertain about the best approach for handling newly added fields in a new version of my app. For example: In version 1 of my app, I have a CKRecord named User with a field called name. In version 2, I plan to add a new field, phone_number, to the User record. When version 1 (e.g., installed on a user's iPad) and version 2 (e.g., installed on the same user's iPhone) sync using CKSyncEngine, version 1 is unaware of the phone_number field. My concern is how to ensure version 1 handles this scenario gracefully without blocking other sync events. Additionally, when version 1 on the iPad is later updated to version 2, there will be no new sync events unless the "phone_number" field is modified again. This could result in the "phone_number" field never being synced to the iPad. Could you please advise on the best practices for handling such cases to ensure seamless synchronization across different app versions? Thank you for your assistance.
1
0
406
Sep ’24
SwiftData app always at 100% cpu when idle after upgrading to Xcode 15.3
Our app is using SwiftData + SwiftUI. After upgrading to Xcode 15.3 Beta, RC1, RC2, we’ve experienced the same issue that the app is having 100% CPU activity even when left idle. This happens as long as the SwiftUI is using @Query to fetch SwiftData and the query does return at least 1 result (there is no issue if the query returns empty result). We’ve tried the following and therefore confirmed that this is a Xcode 15.3 beta issue: Xcode 15.3 Beta + iOS 17.2 -> 100% CPU activity when idle Xcode 15.3 Beta + iOS 17.4 beta -> 100% CPU activity when idle Xcode 15.2 Beta + iOS 17.2 -> normal This only happens during debug run. When profiling / using instrument, this doesn't happen.
16
6
3.5k
Mar ’24