Post

Replies

Boosts

Views

Activity

Core Data crash while trying to merge
I'm looking for guidance how to mitigate this crash. It seems super deep inside Core Data' FRC fetchedObjects management. In my code, it's initiated by this viewContext.perform { [unowned self] in self.viewContext.mergeChanges(fromContextDidSave: notification) } which is directly followed by the stack trace below. Basically merging data from .NSManagedObjectContextDidSave notification from another NSManagedObjectContext. Nothing special, it works great for years, apart from these rare occurrences. Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Reason: -[__NSCFArray objectAtIndex:]: index (235) beyond bounds (234) Termination Reason: SIGNAL 6 Abort trap: 6 Triggered by Thread: 0 Last Exception Backtrace: 0 CoreFoundation 0x199e947cc __exceptionPreprocess + 164 (NSException.m:249) 1 libobjc.A.dylib 0x1971672e4 objc_exception_throw + 88 (objc-exception.mm:356) 2 CoreFoundation 0x199fc4258 _NSArrayRaiseBoundException + 368 (NSCFArray.m:22) 3 CoreFoundation 0x199e288a4 -[__NSCFArray objectAtIndex:] + 200 (NSCFArray.m:42) 4 CoreData 0x1a1e17338 -[_PFMutableProxyArray objectAtIndex:] + 40 (_PFArray.m:1860) 5 CoreData 0x1a1e1673c -[NSFetchedResultsController _updateFetchedObjectsWithInsertChange:] + 380 (NSFetchedResultsController.m:1582) 6 CoreData 0x1a1e1426c __82-[NSFetchedResultsController(PrivateMethods) _core_managedObjectContextDidChange:]_block_invoke + 2240 (NSFetchedResultsController.m:2171) 7 CoreData 0x1a1dcdf80 developerSubmittedBlockToNSManagedObjectContextPerform + 156 (NSManagedObjectContext.m:4002) 8 CoreData 0x1a1e41a44 -[NSManagedObjectContext performBlockAndWait:] + 216 (NSManagedObjectContext.m:4113) 9 CoreData 0x1a1e41034 -[NSFetchedResultsController _core_managedObjectContextDidChange:] + 124 (NSFetchedResultsController.m:2379) 10 CoreFoundation 0x199e632f4 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 148 (CFNotificationCenter.c:701) 11 CoreFoundation 0x199e63210 ___CFXRegistrationPost_block_invoke + 88 (CFNotificationCenter.c:194) 12 CoreFoundation 0x199e63158 _CFXRegistrationPost + 436 (CFNotificationCenter.c:222) 13 CoreFoundation 0x199e6170c _CFXNotificationPost + 728 (CFNotificationCenter.c:1248) 14 Foundation 0x198a84ea4 -[NSNotificationCenter postNotificationName:object:userInfo:] + 92 (NSNotification.m:531) 15 CoreData 0x1a1e11650 -[NSManagedObjectContext _createAndPostChangeNotification:deletions:updates:refreshes:deferrals:wasMerge:] + 1736 (NSManagedObjectContext.m:8098) 16 CoreData 0x1a1e10e0c -[NSManagedObjectContext _postRefreshedObjectsNotificationAndClearList] + 164 (NSManagedObjectContext.m:7631) 17 CoreData 0x1a1e0fad8 -[NSManagedObjectContext _processRecentChanges:] + 100 (NSManagedObjectContext.m:7714) 18 CoreData 0x1a1e3563c -[NSManagedObjectContext _coreMergeChangesFromDidSaveDictionary:usingObjectIDs:withClientQueryGeneration:] + 3436 (NSManagedObjectContext.m:3723) 19 CoreData 0x1a1e34350 __116+[NSManagedObjectContext(_NSCoreDataSPI) _mergeChangesFromRemoteContextSave:intoContexts:withClientQueryGeneration:]_block_invoke_4 + 76 (NSManagedObjectContext.m:9531) 20 CoreData 0x1a1dcdf80 developerSubmittedBlockToNSManagedObjectContextPerform + 156 (NSManagedObjectContext.m:4002) 21 CoreData 0x1a1e41a44 -[NSManagedObjectContext performBlockAndWait:] + 216 (NSManagedObjectContext.m:4113) 22 CoreData 0x1a1e39880 +[NSManagedObjectContext _mergeChangesFromRemoteContextSave:intoContexts:withClientQueryGeneration:] + 2372 (NSManagedObjectContext.m:9537) 23 CoreData 0x1a1e344a0 -[NSManagedObjectContext mergeChangesFromContextDidSaveNotification:] + 292 (NSManagedObjectContext.m:0)
1
0
48
Apr ’25
URLSession download task fails with NSPOSIXErrorDomain error Code=1
I have a Push Notification Service Extension, which is processing notification payload to attach image, if imageUrl is key is present. I use this simple code to perform the download: let downloadTask = URLSession.shared.downloadTask(with: urlRequest) { [weak self] tempURL, response, error in /// parse results... } Notification payload contains "mutable-content" : 1 inside aps. It's entirely randomly will it work or not. When it doesn't work, I get this error: Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted" UserInfo={NSErrorFailingURLStringKey=https://w7.pngwing.com/pngs/1005/607/png-transparent-african-elephant-animal-elephant-thumbnail.png, NSErrorFailingURLKey=https://w7.pngwing.com/pngs/1005/607/png-transparent-african-elephant-animal-elephant-thumbnail.png, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDownloadTask <4A847242-2314-4125-99E4-A424CF4B4B7C>.<7>" ), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDownloadTask <4A847242-2314-4125-99E4-A424CF4B4B7C>.<7>} I have no idea what Apple's internal code throws this error, what could possibly go wrong here. This is happening for a while now, I just re-tested on iOS 17.5.1 on 14 Pro. App is compiled using Xcode 15.4 and Swift 5.10, latest SDK. Not sure is it relevant but main iOS app has DataProtection capability set to Complete.
9
0
1.5k
Jun ’24
Include/exclude .xcassets file per chosen build configuration
I have a single iOS target project which is used with dozen or so .xcconfig files to build multiple different apps. xcconfig file allows us to customise app icon, launch storyboard, API endpoints, bundle identifiers etc. However, we also need to customise the .xcassets per configuration which I don't know how to do. I have Brandcolors.xcassets which needs to be different for each configuration. I can do this manually by changing target membership of certain files in the project based on active xcconfig/scheme. Is there some (sane) way to do this automatically other than manually adjusting pbxproj in the run-script build phase?
0
0
546
Jan ’23
UIFlowLayoutRow crash
I am getting intermittent crash in _UIFlowLayoutRow layoutRow. I can't figure out what is causing this to happen, it seems like a normal layout stack. In vast majority of cases it works so this must be some race condition which I can't catch. Thread 0#0 (null) in -[_UIFlowLayoutRow layoutRow] () #1 (null) in -[_UIFlowLayoutRow layoutRow] () #2 (null) in -[_UIFlowLayoutSection computeLayoutInRect:forSection:invalidating:invalidationContext:] () #3 (null) in __76-[UICollectionViewFlowLayout _updateItemsLayoutForRect:allowsPartialUpdate:]_block_invoke () #4 (null) in __NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__ () #5 (null) in -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] () #6 (null) in -[UICollectionViewFlowLayout _updateItemsLayoutForRect:allowsPartialUpdate:] () #7 (null) in -[UICollectionViewFlowLayout _fetchItemsInfoForRect:] () #8 (null) in -[UICollectionViewFlowLayout collectionViewContentSize] () #9 (null) in -[UICollectionViewFlowLayout invalidateLayoutWithContext:] () #10 (null) in -[UICollectionViewLayout _invalidateLayoutUsingContext:] () #11 (null) in -[UICollectionView setBounds:] () #12 (null) in -[UIView(Geometry) _applyISEngineLayoutValuesToBoundsOnly:] () #13 (null) in -[UIView(Geometry) _resizeWithOldSuperviewSize:] () #14 (null) in -[UIScrollView(_UIOldConstraintBasedLayoutSupport) _resizeWithOldSuperviewSize:] () #15 (null) in __46-[UIView(Geometry) resizeSubviewsWithOldSize:]_block_invoke () #16 (null) in __NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__ () #17 (null) in -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] () #18 (null) in -[UIView(Geometry) resizeSubviewsWithOldSize:] () #19 (null) in -[UIView(AdditionalLayoutSupport) _is_layout] () #20 (null) in -[UIView _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] () #21 (null) in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] () #22 (null) in CA::Layer::layout_if_needed(CA::Transaction*) () #23 (null) in CA::Layer::layout_and_display_if_needed(CA::Transaction*) () #24 (null) in CA::Context::commit_transaction(CA::Transaction*, double, double*) () #25 (null) in CA::Transaction::commit() () #26 (null) in CA::Transaction::flush_as_runloop_observer(bool) () #27 (null) in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ () #28 (null) in __CFRunLoopDoObservers () #29 (null) in __CFRunLoopRun () #30 (null) in CFRunLoopRunSpecific () #31 (null) in GSEventRunModal () #32 (null) in -[UIApplication _run] () #33 (null) in UIApplicationMain ()
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
443
Apr ’22
UIFlowLayoutRow crash
I am getting intermittent crash in _UIFlowLayoutRow layoutRow. I can't figure out what is causing this to happen, it seems like a normal layout stack. In vast majority of cases it works so this must be some race condition which I can't catch. Thread 0#0 (null) in -[_UIFlowLayoutRow layoutRow] () #1 (null) in -[_UIFlowLayoutRow layoutRow] () #2 (null) in -[_UIFlowLayoutSection computeLayoutInRect:forSection:invalidating:invalidationContext:] () #3 (null) in __76-[UICollectionViewFlowLayout _updateItemsLayoutForRect:allowsPartialUpdate:]_block_invoke () #4 (null) in __NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__ () #5 (null) in -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] () #6 (null) in -[UICollectionViewFlowLayout _updateItemsLayoutForRect:allowsPartialUpdate:] () #7 (null) in -[UICollectionViewFlowLayout _fetchItemsInfoForRect:] () #8 (null) in -[UICollectionViewFlowLayout collectionViewContentSize] () #9 (null) in -[UICollectionViewFlowLayout invalidateLayoutWithContext:] () #10 (null) in -[UICollectionViewLayout _invalidateLayoutUsingContext:] () #11 (null) in -[UICollectionView setBounds:] () #12 (null) in -[UIView(Geometry) _applyISEngineLayoutValuesToBoundsOnly:] () #13 (null) in -[UIView(Geometry) _resizeWithOldSuperviewSize:] () #14 (null) in -[UIScrollView(_UIOldConstraintBasedLayoutSupport) _resizeWithOldSuperviewSize:] () #15 (null) in __46-[UIView(Geometry) resizeSubviewsWithOldSize:]_block_invoke () #16 (null) in __NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__ () #17 (null) in -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] () #18 (null) in -[UIView(Geometry) resizeSubviewsWithOldSize:] () #19 (null) in -[UIView(AdditionalLayoutSupport) _is_layout] () #20 (null) in -[UIView _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] () #21 (null) in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] () #22 (null) in CA::Layer::layout_if_needed(CA::Transaction*) () #23 (null) in CA::Layer::layout_and_display_if_needed(CA::Transaction*) () #24 (null) in CA::Context::commit_transaction(CA::Transaction*, double, double*) () #25 (null) in CA::Transaction::commit() () #26 (null) in CA::Transaction::flush_as_runloop_observer(bool) () #27 (null) in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ () #28 (null) in __CFRunLoopDoObservers () #29 (null) in __CFRunLoopRun () #30 (null) in CFRunLoopRunSpecific () #31 (null) in GSEventRunModal () #32 (null) in -[UIApplication _run] () #33 (null) in UIApplicationMain ()
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
710
Apr ’22
How to verify that Apple's CDN has picked up newer version of the apple-app-site-association file?
We updated the file ~2 days ago and the feature we are working on seemingly does not work - web links never open in the app, always end up at the browser. I set up new test site, added the file there and linked it up with the app. Tapping the link opens in the app. So my conclusion is that Apple's CDN is not updated. But how I can verify that?
5
1
23k
Jan ’22
How to attach to a running process on Apple Watch?
I connect my iPhone to Mac. I use Debug / Attach to Process and then pick the Watch Extension process running on my paired Watch Series 4. Xcode 11.7, watchOS is 6.2.8, iOS is 13.7 The error dialog I get after a while is: attach failed (Not allowed to attach in process. Look in the console messages (Console.app) near the debugserver entries when the attached failed.. But there's nothing useful I can find. Where in Console.app should I look for those entries?
1
0
1.7k
Sep ’20