Post

Replies

Boosts

Views

Activity

SwiftUI Sheet never releases object from memory on iOS 17
I've found a very strange behaviour which looks like a bug. SwiftUI sheet or fullScreenCover do not release objects that were passed to its item: parameter (and to the view builder body by the way, but here is the simplified case). It works well and memory is releasing on iOS 16 built with both Xcode 14 or 15. (simulators, devices) Memory is leaking and NOT releasing on iOS 17 built with Xcode 15. (simulator, device 17.0.2) Any ideas how we can solve this or we have to wait for the bugfix? This is going to be a global memory leak, I am sure most of SwiftUI apps are using classes passed to the sheet or fullScreenCover. struct SheetView: View { @State var sheetVM: SheetVM? var body: some View { Button { sheetVM = .init() } label: { Text("Navigate") } .sheet(item: $sheetVM) { sheetVM in Color.yellow } } } final class SheetVM: ObservableObject, Identifiable { @Published var title: String = "Title" init() { print("SheetVM init") } deinit { print("... SheetVM deinit") } } struct SheetView_Previews: PreviewProvider { static var previews: some View { SheetView() } }
9
7
3.1k
Oct ’23
In-App Purchases still "Waiting for Review" after app rejected
I have submitted the first version of my app with 2 In-Apps. It was rejected to make some updates. In-Apps was in status "Developer Action Needed". I've updated description and In-Apps are "Waiting for Review" now. But I cannot add them to the app anymore because they are not "Ready to Review". How can I make them "Ready to Review" again, they are just not visible for attaching to the bundle?
0
0
613
May ’21
Can Bundle ID mismatch with the App Name?
During developing I've created bundle ID for my app, setup CloudKit etc. and wanted to name my app let's say MyChatApp. I've created Bundle ID com.NameSurname.MyChatApp. Then I've decided to name the app with better and unique name like LetsGoChat. Do I need to change bundle ID to com.NameSurname.LetsGoChat or it does not matter? Personally for me I don't care if it will be different, but will it be something not correct for Apple when it will be time to review the app for AppStore?
0
0
473
Nov ’20
Accepting again leaved share CloudKit causing token problems
I have sync troubles with CKServerChangeToken when re-accepting again CKShare. Here is the steps to explain, starting from the point when share accepted and everything synched. Model: List. It is parent for Items. It can be shared. Item. Have parent List, sharing inherited from parent List. Steps that are causing the problem: Share accepted by user B, user A is owner, zone synched, CKServerChangeToken stored by User B. User B's Shared Zone contains List1, List2 with some Items inside each User B delete CKShare for List1 only from that zone in his Shared database, e.g. leaved share (shown as invited for User A now) User B use the same link to accept share again, he is shown as accepted participant for User A, everything is fine so far. User B perform sync operations, but turns out like nothing was changed since stored CKServerChangeToken and List1 with all it's items is being skipped on sync. CKFetchRecordZoneChangesOperation returns nothing as each of CKRecords (List1 and it's Items) was not changed. Updating List1 CKRecord solves the problem as it's a change after stored CKServerChangeToken. Also each Item CKRecord inside List1 must be updated to be detected by sync operation as updated records after CKServerChangeToken. How to manage this issue?
1
0
476
Oct ’20
Generic function does not work as expected
Hello, Please look at the code below. When compiling, I am getting an error "Global function 'fetchingFunc(entityType:)' requires that 'NSManagedObject' conform to 'CloudKitManagedObject'". Somehow the row 22 works great, but row 27 doesn't work, though everything looks logically. Row 27 will work if I will make fetchingFunc(entityType:) not generic receiving CloudKitManagedObject directly. But in that case NSFetchRequest<CloudKitManagedObject> at row 18 doesn't work. For me not working row 27 looks like some sort of a bug, don't see any reason it should not work. Actually the goal here is to make row 18 working, could not achieve that without making function generic. import CloudKit import CoreData protocol CloudKitManagedObject where Self: NSManagedObject {     static var entityName: String { get } } extension CloudKitManagedObject where Self: NSManagedObject {     static func fetchRequest() -> NSFetchRequest<Self> {         return NSFetchRequest<Self>(entityName: self.entityName)     } } class Item: NSManagedObject, CloudKitManagedObject { static let entityName = "Item" } class List: NSManagedObject, CloudKitManagedObject { static let entityName = "List" } func fetchingFunc<SyncObj: CloudKitManagedObject>(entityType: SyncObj.Type) {     let fetchRequest: NSFetchRequest<SyncObj> = entityType.fetchRequest()     fetchRequest.predicate = nil } fetchingFunc(entityType: Item.self) let types: [CloudKitManagedObject.Type] = [Item.self, List.self] for type in types {     fetchingFunc(entityType: type) //This won't compile }
1
0
379
Aug ’20
NSCloudKitMirroringDelegate "Never successfully initialised" error
After single attempt to fetch context on persistentContainer right after internet was restored (NWPathMonitor update handler), CoreData+CloudKit mirroring stuck and messaging that no internet, and cannot initialise. All CloudKit requests work perfect, but CloudKitMirroring cannot do sync, only app restart helps. Have no idea how simple fetch can kill CoreData mirroring... It happens each time I fetch on internet restore (I have to do that, to upload parent records to CloudKit manually as Apple did not implemented that in NSPersistentCloudKitContainer, all my records must have parents in order to share them). 2020-07-24 19:36:25.309059+0300 Grocery List[1045:148713] [error] error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate requestAbortedNotInitialized:]1379: &lt;NSCloudKitMirroringDelegate: 0x281e048f0&gt; - Never successfully initialized and cannot execute request '&lt;NSCloudKitMirroringDelegateSerializationRequest: 0x283c6cec0&gt; B20F9DB7-9600-4456-B682-056F4849FE4D resultType: Records resultType: Records objectIDsToSerialize: {(     0xccdeb685a950d0db &lt;x-coredata://D745D081-107C-46B4-BA82-FAF2D86D959C/Item/p100&gt; )}' due to error: &lt;CKError 0x282671440: "Network Unavailable" (3/NSURLErrorDomain:-1009); "Схоже, що немає інтернет-зʼєднання."&gt; 2020-07-24 19:36:25.309837+0300 Grocery List[1045:148713] [error] error: CoreData+CloudKit: -[NSPersistentCloudKitContainer recordForManagedObjectID:]block_invoke(253): Record serialization failed with error: Error Domain=NSCocoaErrorDomain Code=134406 "Request 'B20F9DB7-9600-4456-B682-056F4849FE4D' was aborted because the mirroring delegate never successfully initialized due to error: &lt;CKError 0x282671440: "Network Unavailable" (3/NSURLErrorDomain:-1009); "Схоже, що немає інтернет-зʼєднання."&gt;" UserInfo={NSLocalizedFailureReason=Request 'B20F9DB7-9600-4456-B682-056F4849FE4D' was aborted because the mirroring delegate never successfully initialized due to error: &lt;CKError 0x282671440: "Network Unavailable" (3/NSURLErrorDomain:-1009); "Схоже, що немає інтернет-зʼєднання."&gt;}
2
0
1.2k
Jul ’20
How to get final changes of Persistent History in Core Data?
Is there some way to effectively get final change for each changed NSManagedObject in Persistent History with it's final states? Or maybe that's possible to get whole past context at timestamp and fetch it, so I can just compare it with the current one? After fetching context returns an array of [NSPersistentHistoryTransaction], and it's not comfortable to navigate there as object can be updated many times (let's say 100 updates), and the only way to get final state is go through each update as transaction contains only updated property.
0
0
356
Jul ’20
How to extend NSPersistentCloudKitContainer to upgrade generated CKRecords
Hi, I am developing sharing feature with already working mirroring and need to set parentRecord to child items. I want to extend NSPersistentCloudKitContainer (or any it's component used for mirroring) in some way to get access to CKRecords it is creating before container will push records to the server. Goal — I want to set CKRecord.parent right before CKModifyRecordsOperation fires somewhere in NSPersistentCloudKitContainer. Reason — NSPersistentCloudKitContainer do not handle parent records by itself.
0
0
449
Jul ’20
Child records not showing in the Shared Database when sharing the Parent record in CloudKit
I've set up a Core Data mirroring to CloudKit using NSPersistentCloudKitContainer. My simplified data structure consists of List and Item. List have one-to-many relationship items with many Items, Item has parentList property. When I am getting CKRecord associated with List NSManagedObject and sharing it, I expect all child Items to be shared too. I know, I can set parentRecord property for each CKRecord associated with the List childRecord.setParent(parentRecord) But I believe there is some smart way to avoid doing that manually, because everything is mirroring automatically and it looks not nice to start handling each single property manually to only set parentRecord. Is there any way to do that for NSManagedObjects? Because my custom relationship does not mean for CloudKit that the List is parent for the Item.
0
0
459
Jul ’20
Outdated CKRecord on NSPersistentCloudKitContainer.record(for:)
Hi, I am trying to fetch CKShare for NSManagedObject. Firstly I get CKRecord for it using NSPersistentCloudKitContainer's record(for:) method. And getting situation when: First time record(for:) gives correct CKRecord I successfully create CKShare, see it in online Dashboard Next time record(for:) gives old CKRecord which don't have share yet, it's outdated! I swipe down notification Notification Center or minimise the app (go to home screen), and when go back, database is being immediately updated and record(for:) returns correct CKRecord with existing share now. I can get correct CKRecord if I use only recordID from CKRecord that I get from record(for:), and fetch updated CKRecord using fetch(withRecordID:completionHandler:). But it increase awaiting time twice because I need to get response for correct CKRecord and then fetch CKShare for it. If no share for CKRecord, I could get that nil immediately but now I have to fetch correct updated CKRecord. So, anyone know how to keep local database updated as expected without call Notification Center or minimising an app?
0
0
403
Jul ’20