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/
Follow these steps,
Disable automatic generation for each entity individually by setting the "Codegen" setting to "Manual/None" for the entity.
Change entity name to something else to get it to save. For example change the class name; build; change the class name back; build again.
Tom Harrington Answer is correct. However, there is a way to add your own functions and/or vars without doing any of the two mentioned options.
Just create an extension to the class. (make sure you name the swift file something different than the standard auto-generated NSManagesObject files.)
For example. If you have an entity called MyEntity
you could add a swift file called MyEntityExtension.swift
which could look something like this:
import Foundation
import CoreData
import UIKit
extension MyEntity {
var color: UIColor {
get {
return self.colorValue as! UIColor
}
set {
if newValue.isMember(of: UIColor.self) {
self.colorValue = newValue
}
}
}
}
For everyone having trouble getting autogen to work:
I had to set the "com.apple.syncservices.Syncable" to "NO" on the User Info settings for the Entity.
Maybe that helps out.