Swift 2, warning: could not load any Objective-C class information from the dyld shared cache

XcodeCore DataConsoleSwift2Xcode7

Xcode Problem Overview


I have found a few questions regarding this issue, yet none of them were helping with my problem. I am trying to save an object to core data using this code (which worked perfectly fine in Xcode 6 and Simulator...):

let fetchRequest = NSFetchRequest(entityName: "Patient")
let fetchedResults : [NSManagedObject]!
do {
    fetchedResults = try managedContext.executeFetchRequest(fetchRequest) as! [NSManagedObject]
    patienten = fetchedResults
}    catch {
    print("error")
}

I added the do-try-catch once I started working on this project in the Xcode 7 beta and a physical device. Now, when I hit the Save button, this piece of code is called, the app freezes and I get the following:

>warning: could not load any Objective-C class information from the dyld shared cache. This will significantly reduce the quality of type information available.

Screenshot

Does anybody know where I went wrong?

Xcode Solutions


Solution 1 - Xcode

For anyone coming across this in the future, I just ran into this problem myself and it turned out that I was actually getting a stack overflow from a recursive function.

Apparently calling setValue:forKey: on an NSObject calls the respective set[Key] function, where [Key] is the (capitalized) name you gave to the forKey section.

So, if like me, you have code that looks like the following, it will cause an infinite loop and crash.

func setName(name: String) {
    self.setValue(name, forKey: "name")
}

Solution 2 - Xcode

Choose Product > Clean

I had similar issue. I deleted the app from the device. Then "Product->Clean" in the XCode menu. When I ran the app again, the issue got resolved.

Solution 3 - Xcode

Swift 3:

Actually this problem happened often when you have any property in input declared as type NSError and the compiler expect an Error output, so change the input type to Error usually solve this issue.

Solution 4 - Xcode

What helped me in similar problem (xCode 7, Swift 2):

reading this question

Or more quickly without explaining the reason of solution: just comment @objc(className) in your NSManagedObjectSubclass , that was generated from your CoreData Entity (@objc(Patient) - in your case ).

This solution (if issue still appears) does not applicable to xCode 7.1/Swift 2.1, as the way of generating NSManagedObjectSubclasses was changed.

Don't forget about cleaning your project (Product > Clean) and deleting the app from your device/simulator to replace CoreData storage on it.

Solution 5 - Xcode

let fetchRequest = NSFetchRequest(entityName: "Patient")

do {
  let fetchedResults = try managedObjectContext!.executeFetchRequest(fetchRequest)
  print("\(fetchedResults)")
} catch {
  print("error")
}

The above code worked for me. Maybe the issue maybe with how your core data is managed.

  1. Check if your managedObjectContext is actually getting created.
  2. Check the modelling of your core data

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionzeroView Question on Stackoverflow
Solution 1 - XcodethislooksfunView Answer on Stackoverflow
Solution 2 - XcodeBig DView Answer on Stackoverflow
Solution 3 - XcodeAlessandro OrnanoView Answer on Stackoverflow
Solution 4 - XcodeYurii KovalView Answer on Stackoverflow
Solution 5 - XcodeRobert D'AlmeidaView Answer on Stackoverflow