Posts

Post not yet marked as solved
7 Replies
1.4k Views
On iOS 14 beta 5 and 6, when fetching a request on a new private queue context that has persistentContainer.newBackgroundContext() as a parent, returns the wrong number of objects (always 0 even if there are objects in the db). The same code on iOS 13 and iOS 14 beta 1 to 4 returns the correct number of objects. Am I doing something wrong? In the following sample code the second assert fails on Xcode 12 beta 5 and 6. let rootContext = self.persistentContainer.newBackgroundContext() let viewContext = persistentContainer.viewContext let goodRequest = NSFetchRequest<NSFetchRequestResult>() goodRequest.entity = NSEntityDescription.entity(forEntityName: Podcast.entityName(), in: viewContext) let batchRequest = NSFetchRequest<NSFetchRequestResult>() batchRequest.fetchBatchSize = 20 batchRequest.entity = NSEntityDescription.entity(forEntityName: Podcast.entityName(), in: viewContext) let entityDescription = NSEntityDescription.entity(forEntityName: Podcast.entityName(), in: viewContext)! let newPodcast = NSManagedObject(entity: entityDescription, insertInto: viewContext) as! Podcast newPodcast.title = "The Title" if viewContext.hasChanges { &#9;&#9;try? viewContext.save() } &#9;&#9; guard &#9;&#9;let goodPodcastsAfter = try! viewContext.fetch(goodRequest) as? [Podcast], &#9;&#9;let batchPodcastsAfter = try! viewContext.fetch(goodRequest) as? [Podcast] else {return} NSLog("After adding new podcast - podcast count - good request: \(goodPodcastsAfter.count) - batch request: \(batchPodcastsAfter.count)") assert(goodPodcastsAfter.count == batchPodcastsAfter.count, "Count of fetched podcasts should match") let newContext = NSManagedObjectContext(concurrencyType: NSManagedObjectContextConcurrencyType.privateQueueConcurrencyType) newContext.parent = rootContext newContext.automaticallyMergesChangesFromParent = true newContext.mergePolicy = NSMergePolicy.mergeByPropertyObjectTrump newContext.perform { &#9;&#9;guard &#9;&#9;&#9;&#9;let goodPodcastsInNewContext = try? newContext.fetch(goodRequest) as? [Podcast], &#9;&#9;&#9;&#9;let batchPodcastsInNewContext = try? newContext.fetch(batchRequest) as? [Podcast] &#9;&#9;else {return} &#9;&#9; &#9;&#9;NSLog("In new context - podcast count - good request: \(goodPodcastsInNewContext.count) - batch request: \(batchPodcastsInNewContext.count)") &#9;&#9;assert(goodPodcastsInNewContext.count == batchPodcastsInNewContext.count, "Count of fetched podcasts should match") }
Posted Last updated
.
Post marked as solved
2 Replies
1.3k Views
I added a Widget target to my project. If I build and run the Widget scheme everything works and I can see the widget in the simulator. But if I try to see the preview (clicking "resume") in the Canvas the compilation fails with an error about openssl libcrypto.a not having the correct architecture. ld: in /Users/username/Dev/iPhone Dev/ProjectName/openssl-1.0.2g-iOS/lib/libcrypto.a(cryptlib.o), building for iOS Simulator, but linking in object file (/Users/username/Dev/iPhone Dev/ProjectName/openssl-1.0.2g-iOS/lib/libcrypto.a(cryptlib.o)) built for iOS, file '/Users/username/Dev/iPhone Dev/ProjectName/openssl-1.0.2g-iOS/lib/libcrypto.a' for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Please note that openssl is not in the header search path or the library search path for the Widget target. They are in the target of the main iOS app and they build and run with no issue both on the device and the Simulator. Also note that libcrypto.a contains libraries for all architectures. This is the result of the command file libcrypto.a: file libcrypto.a libcrypto.a: Mach-O universal binary with 5 architectures: [i386:current ar archive] [armv7s] [armv7] [x8664] [arm64] libcrypto.a (for architecture i386): current ar archive libcrypto.a (for architecture armv7s): current ar archive libcrypto.a (for architecture armv7): current ar archive libcrypto.a (for architecture x8664): current ar archive libcrypto.a (for architecture arm64): current ar archive Many warnings are also displayed that in normal compilation aren't there about other targets having bitcode disabled (not true: they all have bitcoin enabled, and when compiling both the app and the widget scheme this warnings are not displayed) ld: warning: all bitcode will be dropped because '/Users/username/Library/Developer/Xcode/DerivedData/ProjectName-cvlnfysptxebwcaeifxqmaltnndr/Build/Intermediates.noindex/Previews/ProjectName/Products/Debug-iphonesimulator/WhatsNewKit.o' was built without bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. Filed report in Report Assistant as FB8619450
Posted Last updated
.