iOS18 Crash FetchedProperty CoreData

Hi Folks,

starting with iOS18 and using Xcode16, accessing fetchedProperties results in an error. I identified the issue to occur as soon as the initialization of a fetched property with external binary data storage starts.

Console output during debugging:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'This expression has evaluation disabled'
*** First throw call stack:
[...]
libc++abi: terminating due to uncaught exception of type NSException

Console output when trying to "print" the item via the contact menu of the debugger:

Printing description of variable:
error: error: Execution was interrupted, reason: internal ObjC exception breakpoint(-6)..
The process has been returned to the state before expression evaluation.
Message from debugger: killed

The identical code works with iOS before iOS 18 (same for iPadOS 18).

Does anyone observed a similar issue and figured out a solution already?

Cheers, folox

Yeah, Core Data fetched property is broken in iOS 18, and the team is actively working on that. The error message I saw was pretty much the same as what you provided, but I’d still suggest that you file your own feedback report so your use case is covered by the potential fix – If you do so, please share your report ID here for folks to track.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Hello,

Is there any new about this? We are experiencing the same issue.

I need a solution, how do you fix this?

Also having this problem, 18.1 and up seems to work without any code changes, but app crashing on 18.0 consistently. Is there a workaround for fetched properties on 18 so I can put a fix out for older versions of iOS/iPad OS?

The bug is real, even the official Apple's guide Linking Data Between Two Core Data Stores crashes on launch on iOS 18.0.

It would help if Apple Engineers could have a look at this solution:

How about manually fetching the corresponding records from Core Data? In the Apple's example, instead of

extension Book {
    var feedbackList: [Feedback]? { // The accessor of the feedbackList property.
        return value(forKey: "feedbackList") as? [Feedback]
    }
}

have something like:

import CoreData

extension Book {
    var feedbackList: [Feedback]? { // The accessor of the feedbackList property.
        if #available(iOS 18.1, *) {
            //iOS 18.1+ usual code (current)
            return value(forKey: "feedbackList") as? [Feedback]
        } else if #available(iOS 18, *) {
            //iOS 18.0-18.1 only code
            return fetchFeedbackManually()
        } else {
            //below iOS 18.0 usual code
            return value(forKey: "feedbackList") as? [Feedback]
        }
    }
    
    private func fetchFeedbackManually() -> [Feedback]? {
        guard let viewContext = self.managedObjectContext,
              let bookUUID = self.uuid else {
            return nil
        }
        
        return viewContext.performAndWait {
            let request: NSFetchRequest<Feedback> = Feedback.fetchRequest()
            request.predicate = NSPredicate(format: "bookUUID == %@", bookUUID as CVarArg)
            
            do {
                return try viewContext.fetch(request)
            } catch {
                return nil
            }
        }
    }
}

It seems to work, but I can't say what the consequences of such an approach are...

iOS18 Crash FetchedProperty CoreData
 
 
Q