A great article on a subject. http://useyourloaf.com/blog/core-data-code-generation/
On Tue, Jan 17, 2017 at 2:21 AM, Jack Lawrence via swift-users < swift-users@swift.org> wrote: > This is better suited to the Apple developer forums/stack overflow, FYI. > > I selected "Class Definition" in the CodeGen pop up menu in the inspector. > > This tells Xcode to automatically create and maintain the entity classes > for you. They don't show up in the project navigator because they're > autogenerated files, but they're available via autocomplete and > command-click jump to definition. > > I then asked Xcode to generate the files with the "Create NSManagedObject > subclasses". > > Xcode has already generated NSManagedObject subclasses for you, so you've > now created duplicate classes. That's why you're getting this: > > But everything breaks. Building the project, I now get several errors > similar to this: > > <unknown>:0: error: filename "PHAudioFile+CoreDataClass.swift" used > twice: > > > TL;DR: Don't create NSManagedObject subclasses manually—they're already > created and automatically updated for you in Xcode 8. > > On Jan 15, 2017, at 10:01 PM, Jean-Denis Muys via swift-users < > swift-users@swift.org> wrote: > > Hi, > > Using Xcode 8.2.1 I just created a brand new document-based Cocoa > application using Core Data and Swift. I created a single entity in the > Document.xcdatamodeld file. I selected "Class Definition" in the CodeGen > pop up menu in the inspector. > > My entity is named PHAudioFile. > > I then asked Xcode to generate the files with the "Create NSManagedObject > subclasses". It generated two files: > > - PHAudioFile+CoreDataClass.swift > - PHAudioFile+CoreDataProperties.swift > > But everything breaks. Building the project, I now get several errors > similar to this: > > <unknown>:0: error: filename "PHAudioFile+CoreDataClass.swift" used > twice: '/Users/jdmuys/Phoenix/PHAudioFile+CoreDataClass.swift' and > '/Users/jdmuys/Library/Developer/Xcode/DerivedData/Phoenix- > buxfnwoppzieggdrogkoajdyimri/Build/Intermediates/Phoenix. > build/Debug/Phoenix.build/DerivedSources/CoreDataGenerated/Document/ > PHAudioFile+CoreDataClass.swift' > > <unknown>:0: note: filenames are used to distinguish private declarations > with the same name > > More over, the Xcode editor shows many syntax errors in the generated > files. > > PHAudioFile+CoreDataClass.swift contains this: > > import Foundation > import CoreData > > @objc(PHAudioFile) > public class PHAudioFile: NSManagedObject { > > } > > With this error on the "public class PHAudioFile" line: > > "Invalid redeclaration of PHAudioFile" > > PHAudioFile+CoreDataProperties.swift starts with this line: > > extension PHAudioFile { > > Which breaks with: > > "'PHAudioFile' is ambiguous for type lookup in this context" > > and of course every line thereafter breaks too. > > Searching for 'PHAudioFile' in my Xcode project, finds only those two > files. In particular I can't find any other declaration for 'PHAudioFile'. > > Am I missing something, or is this broken? > > Thanks, > > Jean-Denis > > > > > > > > > > > > > has this line in error: > > > > > _______________________________________________ > swift-users mailing list > swift-users@swift.org > https://lists.swift.org/mailman/listinfo/swift-users > > > > _______________________________________________ > swift-users mailing list > swift-users@swift.org > https://lists.swift.org/mailman/listinfo/swift-users > >
_______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users