Post

Replies

Boosts

Views

Activity

Incomplete sync using CloudKit+CoreData and the public database
My app is composed from 2 components: iOS app (public facing) + macOS app (where I will feed in public info). Both will share the same codebase for Services and Model. The app will have public content (that will be stored in the public db - and only I will have the option to modify) and private content that each user will be able to create on their private database. The model is basically simple: An entity A with primitive fields AF1, AF2, AF3 An entity B with primitive fields BF1, BF2 A OneToMany relation between A and B (A can have many B). The problematic flow: I save info to the public db via Mac app (check it via CK dashboard) I validate the data on the iOS app via a real device (bring app the background, bring app to foreground, wait a couple of seconds and the data is there) I do various tests like: Adding a new B to A -> save -> check or updating a B -> save -> check. Most of the time everything works like a charm (obvious the data comes with a delay, but it comes). The problem is that sometimes when I update via macAPP, I get partial data on the iOS app (e.g. the A table is always updated (by checking the primate fields) and the B relations will never get updated. Notes:the CK dashboard if up to date each time I trigger a save from Mac app on the iOS app, when the records don't reach the device, I manually check the sqlite DB and I can confirm that it's inconsistent. I blame the coredatastack, but I really didn't get much info for public database setup. My CoreDataStack is shared on both apps and looks like this: 		 		let cloudStoreLocation = storeDirectory.appendingPathComponent("cloud.sqlite") 		let cloudStoreDescription = NSPersistentStoreDescription(url: cloudStoreLocation) 		cloudStoreDescription.configuration = privateCloudStoreName 		cloudStoreDescription.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: "iCloud.ABC") 		cloudStoreDescription.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey) 		cloudStoreDescription.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey) 		let publicCloudStoreLocation = storeDirectory.appendingPathComponent("cloud-public.sqlite") 		let publicCloudStoreDescription = NSPersistentStoreDescription(url: publicCloudStoreLocation) 		publicCloudStoreDescription.configuration = publicCloudStoreName 		var cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: "iCloud.ABC") 		cloudKitContainerOptions.databaseScope = .public 		publicCloudStoreDescription.cloudKitContainerOptions = cloudKitContainerOptions 		 		if isiOSApp { // only iOS will load a private store 				container.persistentStoreDescriptions = [cloudStoreDescription, publicCloudStoreDescription] 		} else { 				container.persistentStoreDescriptions = [publicCloudStoreDescription] 		} 		container.loadPersistentStores(completionHandler: { (_, error) in 				guard let error = error as NSError? else { return } 				fatalError("###\(#function): Failed to load persistent stores:\(error)") 		}) 		container.viewContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy 		container.viewContext.transactionAuthor = "appauthname" 		container.viewContext.automaticallyMergesChangesFromParent = true 		do { 				try container.viewContext.setQueryGenerationFrom(.current) 		} catch { 				fatalError("###\(#function): Failed to pin viewContext to the current generation:\(error)") 		} 		NotificationCenter.default.addObserver( 				self, selector: #selector(type(of: self).storeRemoteChange(_:)), 				name: .NSPersistentStoreRemoteChange, object: nil)
4
0
1.8k
Dec ’20
Core Data transactions from Public database are coming very slow
HI! I'm developing an app that uses CloudKit as it's main database. I have a relatively small database (around 200 entries, each with 2-3 relationships) that I offer pre-populated as as the public database (new in iOS 14). I noticed that the CK mirroring is very very slow. I get the first 5-6 transactions in a matter of seconds an that I have to wait around 2 minutes for all the data to populate. As I can't show partial results (I can't allow the user to see the main entity if it's relations are not fetched yet) this is a big problem for me. Is there a way to speed up the CK mirroring process? (make it more efficient)? How can I diagnose what is taking that much? Apple recommended in the last WWDC to use this public database as an initial set of data, but people will get frustrated if the initial app load takes 2 minutes :o
0
0
659
Mar ’21
CoreData + CloudKit initial db seed
I'm having some trouble setting an initial sqlite seed for my project. I'm using the public database and I exported the initial .sqlite, .sqlite-shm, .sqlite-wal files in the project bundle. The files are consumed properly and the seed is reflected on my device, but when I test on a different device (signed in with another iCloud account), I get a reimport and the error: Failed to set up CloudKit integration for store: NSSQLCore: 0x13e9171d0 (URL: file:///var/mobile/Containers/...CloudPublic.sqlite) Error Domain=NSCocoaErrorDomain Code=134405 "(null)" UserInfo={PFCloudKitOldUserIdentityKey=_***, PFCloudKitNewUserIdentityKey=_YYY, NSCloudKitMirroringDelegateResetSyncReasonKey=3} Sending 'NSCloudKitMirroringDelegateWillResetSyncNotificationName' with reason: 'AccountChange' Is there any way around this for setting an initial sqlite seed?
0
0
846
Mar ’21
CoreData + CloudKit compilation problem in iOS 15
I'm trying to validate by app with the latest Xcode 13 RC. I found out that what was building well on Xcode 12, is not longer compiling on 13 RC. For example, I started getting:  Cannot find type 'CKRecord' in scope in a class that already has the import CoreData statement. In iOS 14 I didn't have to import CloudKit. If I add the import CloudKit statement, it compiles fine and runs on a iOS 15 simulator but it no longer works on iOS 14. I started getting the following runtime error: dyld: Library not loaded: /System/Library/Frameworks/_CoreData_CloudKit.framework/_CoreData_CloudKit   Referenced from: /Users/andrei/Library/Developer/CoreSimulator/Devices/8554B734-4894-4DD0-A8FA-6C20983F3A49/data/Containers/Bundle/Application/73F15947-880B-4902-A640-689C139DE4C4/***.app/***   Reason: image not found dyld: launch, loading dependent libraries DYLD_SHARED_CACHE_DIR=/Users/andrei/Library/Developer/CoreSimulator/Caches/dyld/20G95/com.apple.CoreSimulator.SimRuntime.iOS-14-5.18E182 DYLD_ROOT_PATH=/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 14.5.simruntime/Contents/Resources/RuntimeRoot DYLD_LIBRARY_PATH=/Users/andrei/Library/Developer/Xcode/DerivedData/***-fuozrngfgzmoluasjlbqzfiahbvg/Build/Products/Debug-iphonesimulator:/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 14.5.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 14.5.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 14.5.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libMainThreadChecker.dylib:/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 14.5.simruntime/Contents/Resources/RuntimeRoot/Developer/Library/PrivateFrameworks/DTDDISupport.fram Any ideas?
4
0
1.6k
Sep ’21
How to make search bar in iOS 15 appear by default?
I started to develop an application using iOS15 and the new .searchable modifier. I have a simple layout with some placeholder results on the main page and a search field attached to the navigationBar. Currently, if the user loads the page and looks at the results (even scrolls a bit) will not be able find the search field as it's hidden by default. The user needs to scroll in reverse for the search bar to appear. How is this a good for UX? The only workaround is the drawer placement with .always, but that will make the navigation title inline. I really want to achieve the result from the Notes app, that has the search bar visible all the time. Any workaround? Was this feature really tested by anyone in a real app?
0
0
939
Nov ’21
XcodeCloud fails while Resolving Dependencies
After trying to build with macOS 15 and XCode 16 (beta and beta2), XcodeCloud started to crash at the Resolve package dependencies step. Everything works perfect on my local system running same OS same XC. Details: [<IDESwiftPackageCore.IDESwiftPackageDependencyPlaceholderFileReference, 0x7fb23a2082a0: name:swift path:(No Path)>] Function: unregisterDependencyFileReferences(_:) Thread: <_NSMainThread: 0x600002094200>{number = 1, name = main} Hints: Backtrace: 0 -[DVTAssertionHandler handleFailureInFunction:fileName:lineNumber:assertionSignature:messageFormat:arguments:] (in DVTFoundation) 1 _DVTAssertionHandler (in DVTFoundation) 2 _DVTAssertFromSwift (in DVTFoundation) 3 _DVTAssert(_:file:line:function:varargs:) (in DVTFoundation) 4 DVTAssert(_:_:file:line:function:) (in DVTFoundation) 5 closure #1 in closure #1 in IDESPMWorkspaceDelegate.unregisterDependencyFileReferences(_:) (in IDESwiftPackageCore) 6 closure #1 in IDESPMWorkspaceDelegate.unregisterDependencyFileReferences(_:) (in IDESwiftPackageCore) 7 closure #1 in OS_dispatch_queue.dvt_sync<A>(execute:) (in DVTFoundation) 8 thunk for @callee_guaranteed () -> () (in DVTFoundation) 9 thunk for @escaping @callee_guaranteed () -> () (in DVTFoundation) 10 -[DVTModelObjectGraph performBlockCoalescingModelChanges:] (in DVTFoundation) 11 DVTModelObjectGraph.performBlockCoalescingModelChanges<A>(_:) (in DVTFoundation) 12 IDESPMWorkspaceDelegate.unregisterDependencyFileReferences(_:) (in IDESwiftPackageCore) 13 closure #1 in closure #1 in IDESPMWorkspaceDelegate.registerDependencyFileReferences(_:) (in IDESwiftPackageCore) 14 closure #1 in IDESPMWorkspaceDelegate.registerDependencyFileReferences(_:) (in IDESwiftPackageCore) 15 closure #1 in OS_dispatch_queue.dvt_sync<A>(execute:) (in DVTFoundation) 16 thunk for @callee_guaranteed () -> () (in DVTFoundation) 17 thunk for @escaping @callee_guaranteed () -> () (in DVTFoundation) 18 -[DVTModelObjectGraph performBlockCoalescingModelChanges:] (in DVTFoundation) 19 DVTModelObjectGraph.performBlockCoalescingModelChanges<A>(_:) (in DVTFoundation) 20 IDESPMWorkspaceDelegate.registerDependencyFileReferences(_:) (in IDESwiftPackageCore) 21 closure #1 in IDESPMWorkspaceDelegate.dependencyPackagesDidUpdate(packages:graphHasErrors:) (in IDESwiftPackageCore) 22 closure #1 in OS_dispatch_queue.dvt_sync<A>(execute:) (in DVTFoundation) 23 thunk for @callee_guaranteed () -> () (in DVTFoundation) 24 thunk for @escaping @callee_guaranteed () -> () (in DVTFoundation) 25 __58-[DVTModelObjectGraph performBlockCoalescingModelChanges:]_block_invoke (in DVTFoundation) 26 -[DVTModelGraphTransactionScope performTransaction:] (in DVTFoundation) 27 -[DVTModelObjectGraph performBlockCoalescingModelChanges:] (in DVTFoundation) 28 DVTModelObjectGraph.performBlockCoalescingModelChanges<A>(_:) (in DVTFoundation) 29 IDESPMWorkspaceDelegate.dependencyPackagesDidUpdate(packages:graphHasErrors:) (in IDESwiftPackageCore) 30 SPMWorkspace.packageGraphActionFinished(_:) (in SwiftPM) 31 closure #3 in SPMWorkspace.processPackageGraphActionsInBackgroundIfNeeded() (in SwiftPM) 32 swift::runJobInEstablishedExecutorContext(swift::Job*) (in libswift_Concurrency.dylib) 33 swift_job_runImpl(swift::Job*, swift::SerialExecutorRef) (in libswift_Concurrency.dylib) 34 _dispatch_main_queue_drain (in libdispatch.dylib) 35 _dispatch_main_queue_callback_4CF (in libdispatch.dylib) 36 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ (in CoreFoundation) 37 __CFRunLoopRun (in CoreFoundation) 38 CFRunLoopRunSpecific (in CoreFoundation) 39 +[DVTKVOConditionValidator waitForCondition:sourceObject:keyPathAffectingConditionBlock:timeout:] (in DVTFoundation) 40 -[Xcode3CommandLineBuildTool waitForRemoteSourcePackagesToFinishLoading] (in Xcode3Core) 41 -[Xcode3CommandLineBuildTool _resolveInputOptionsWithTimingSection:] (in Xcode3Core) 42 -[Xcode3CommandLineBuildTool run] (in Xcode3Core) 43 XcodeBuildMain (in libxcodebuildLoader.dylib) 44 -[XcodebuildPreIDEHandler loadXcode3ProjectSupportAndRunXcode3CommandLineBuildToolWithArguments:] (in xcodebuild) 45 -[XcodebuildPreIDEHandler runWithArguments:] (in xcodebuild) 46 main (in xcodebuild) 47 start (in dyld) bash: line 1: 4274 Abort trap: 6 xcodebuild -resolvePackageDependencies -project /Volumes/workspace/repository/***.xcodeproj -scheme '***' -derivedDataPath /Volumes/workspace/DerivedData -hideShellScriptEnvironment Error Command exited with non-zero exit-code: 134
9
3
1.1k
Jun ’24
Unable to use SWIFT_EXPLICIT_MODULES
I'm following the guidance from [wwdc24/10171] using Xcode 16 beta 2 on Sonoma (https://developer.apple.com/wwdc24/10171) and find myself unable to active the _EXPERIMENTAL_SWIFT_EXPLICIT_MODULES = YES setting. I tried both in the project file and in the XCConfig file and nothing. After cleaning and building with timing summary, I can't find any "Compiling Swift module" nor any "modules report". I only get multiple statements of "Compiling clang module" and the "GenerateClangModulesReport" What am I doing wrong?
1
0
461
Jul ’24