I have been trying to add core data.
And every time I got the same error:
error: filename "EntityName +CoreDataClass.swift" used twice: '/Users/userName/Desktop/Development/MyApp/AppName/EntityName +CoreDataClass.swift' and '/Users/userName/Library/Developer/Xcode/DerivedData/AppName-dgwzrmxsetzvtedibxrazuutjwnh/Build/Intermediates/AppName.build/Debug-iphoneos/AppName.build/DerivedSources/CoreDataGenerated/Model/EntityName +CoreDataClass.swift'
I add core data using the following steps:
1.New file/ DataModel; save it in the root dir of my project
select Model.xcdatamodeld and add entity, add several attributes, save,
editor/create NSManagedObjectClass Subclass.
As a result I observe 4 new files in navigator:
Model.xcdatamodeld, EntityName+CoreDataProperties.swift, EntityName +CoreDataClass.swift, _COREDATA_DATAMODELNAME_+CoreDataModel.swift
their content:
_COREDATA_DATAMODELNAME_+CoreDataModel.swift:
import Foundation
import CoreData
___COREDATA_DATAMODEL_MANAGEDOBJECTCLASSES_IMPLEMENTATIONS___
EntityName +CoreDataClass.swift:
import Foundation
import CoreData
class EntityName: NSManagedObject {
}
EntityName+CoreDataProperties.swift:
import Foundation
import CoreData
extension EntityName {
@nonobjc class func fetchRequest() -> NSFetchRequest< EntityName > {
return NSFetchRequest< EntityName >(entityName: "EntityName");
}
@NSManaged var str: String?
}
What I have tried:
1. Clean build, remove DerivedData, delete content of var/folders, restart
2. Delete generated files, displayed in navigator
All my efforts were out of luck.
What I am doing wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…