Swift 3 Entity Master Data: Using an Undeclared Type

Use of undeclared type 'Transcription'

I follow this simple Core Data tutorial in Swift 3 ( https://learnappdevelopment.com/uncategorized/how-to-use-core-data-in-ios-10-swift-3/ )

and I get the above error in the line: let fetchRequest: NSFetchRequest<Transcription> = Transcription.fetchRequest()

I double checked, and Entity "Transcription" is spelled correctly in my .xcdatamodeld file

The tutorial was developed for Swift 3, but there was another change since it was released that I fixed, so I assume that some changes in Swift over the last 2 months caused this error.

I'm new to Core Data, so I don't know how to debug this. I would be very grateful for the decision!

+6
source share
7 answers

Remember to import CoreData to your subclass

+9
source

Select the data model, go to the editor -> Subclass NSManagedObject ...

This solved the error

+4
source

I was worried about the same error I used for Xcode 8.2.1. I cleaned the project, closed Xcode and reopened it, the error was fixed after the build.

+4
source

Perhaps this was due to the fact that Xcode cannot determine the .xcdatamodel path , you can see a related error while cleaning up the project. This error occurred with one of my projects when changing the name of .xcdatamodel .

The solution includes the following:

  • go to Product → Clean (Shift-Cmd-K)
  • if the error persists
    • Ctrl-click (right click) problematic .xcdatamodelShow in Finder
    • Drag .xcdatamodel to import into the project, a new entry must be created
    • Delete the previous .xcdatamodel entry.
  • Build (Cmd-B) to confirm the fix
+2
source

Using Xcode version 8.2 beta (8C30a), when I add or modify an object, I get the same error. In the data model inspector, change the Codegen parameter to Manual / None, as if I was going to create dynamic classes myself. Save and then go back to category / Extension, and it seemed to work. (I also tried cleaning the project with Option-Clean by restarting Xcode, but I could easily play it back.) I hope the beta beta beta beta 4.0 update will be fixed.

+1
source

No. 1) Create a subclass, go to the editor → Create a subclass of NSManagedObject ... Then replace the subclass files in the folder of the same project:

Creating NSManagedObject

2) then delete the files in the derived data - in Xcode -> Settings:

Deleting derivedData

3) and then remove the link to the old NSManagedObject Subclass files, because they automatically create the system:

enter image description here

0
source

I had to remove my entity, which gave me an error, in your Transcription case, from my .xcdatamodeld file, and then add it manually again.

0
source

Source: https://habr.com/ru/post/1257897/


All Articles