Xcode looks up the names of kernel data objects with a dot; without compiling

I worked on the project for some time and recently upgraded to Xcode 8 and Swift 3.0 and iOS 10. But since I did this, I could not compile.

I get an error for each of my entities:: 0: error: no such file or directory: '' /Users/mark/Library/Developer/Xcode/DerivedData/.../.Account+CoreDataProperties.swift 'Each case It has. (dot) before the object name: .Account + CoreDataProperties.swift.

I changed the Gen code from "Category / Extension" to "Manual / None", I make a clean and clean directory by deleting the DerivedData directory. Interestingly, when I look in the corresponding directory, there is a real file, just without a dot prefix.

This is very confusing. Can anyone explain this? I need to solve this problem in order to continue the basic data.

TIA Mark

+5
source share
4 answers

Point files are generated by Xcode8. See WWDC2016 . I came across the same issue after deleting data due to another problem.

Two possible fixes:

1) Recommended modern approach

  • Remove all created NSManagedObject subclasses from your project, if they exist.
  • Set Codegen to Class Definition in .xcdatamodel for all objects
  • Make sure Module empty ("Global Namespace" in light gray) (Apple error workaround, see @ Chris Hansons answer )

Note. Even you do not see the generated files in your project, Xcode has a link to it, so you can write extensions, etc. For instance:

 extension MyEntity { func doSomething() { // } } 

Alternatively, you can invoke + click on the generated file in Xcode.

2) Pretty paranoid, but bulletproof approach, ignoring the new Xcode features

  • Remove all created NSManagedObject subclasses from your project, if they exist.
  • Set Codegen to Manual/None in .xcdatamodel for all objects
  • Clear project
  • Empty DerivedData folder
  • Restart xcode
  • Manually subclass NSManagedObject (in the Editor menu)
  • Make sure these files are added to your project.
  • to build

If your problem persists, repeat:

+8
source

This happens when the object module is installed in the "Current Product Module" (for example, it is in the Swift namespace, and not in the Objective-C global namespace).

The workaround for this is to remove the setting for the “Module” field of the object, so it defaults to “Global namespace” (in light gray text).

+2
source

I changed the Gen code from the Category / Extension section

Change Codegen to a class definition.

enter image description here

Now get rid of what you did in your code to turn your entities into pseudo-classes. Your entities are now real classes!

Now you can significantly reduce your code. You no longer need to specify the type of the object as a class. When you retrieve Person objects, your selection results are typical Person parameters, so each selected object is Person. Similarly, to create a new person, simply call Person(context:) and configure and save the repository. The word "entity" is likely to cease to exist anywhere in your code.

+1
source

I solved it. I was going to completely debug the entire application from scratch to avoid the problem, and I noticed that the entity class files were in the directory, although they were not visible in Xcode. Therefore, I deleted these files and removed this obstacle.

Now I am very happy.

0
source

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


All Articles