<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">This is better suited to the Apple developer forums/stack overflow, FYI.<div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="">I selected "Class Definition" in the CodeGen pop up menu in the inspector.</div></div></blockquote><div class="">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.</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="">I then asked Xcode to generate the files with the "Create NSManagedObject subclasses".</div></div></blockquote>Xcode has already generated NSManagedObject subclasses for you, so you've now created duplicate classes. That's why you're getting this:</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="">But everything breaks. Building the project, I now get several errors similar to this:</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px 0px 0px 12px; font-size: 11px; line-height: normal; font-family: menlo;"><unknown>:0: error: filename "PHAudioFile+CoreDataClass.swift" used twice: </div></div></div></blockquote><br class=""></div><div class="">TL;DR: Don't create NSManagedObject subclasses manually—they're already created and automatically updated for you in Xcode 8.</div><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 15, 2017, at 10:01 PM, Jean-Denis Muys via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi,<div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">My entity is named PHAudioFile.</div><div class=""><br class=""></div><div class="">I then asked Xcode to generate the files with the "Create NSManagedObject subclasses". It generated two files:</div><div class=""><br class=""></div><div class=""><div class="">- PHAudioFile+CoreDataClass.swift</div></div><div class=""><div class="">- PHAudioFile+CoreDataProperties.swift</div></div><div class=""><br class=""></div><div class="">But everything breaks. Building the project, I now get several errors similar to this:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px 0px 0px 12px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><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'</div><p style="margin:0px 0px 0px 12px;font-size:11px;line-height:normal;font-family:menlo" class="">
</p><div style="margin: 0px 0px 0px 12px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><unknown>:0: note: filenames are used to distinguish private declarations with the same name</div></div><div class=""><br class=""></div><div class="">More over, the Xcode editor shows many syntax errors in the generated files.</div><div class=""><br class=""></div><div class="">PHAudioFile+CoreDataClass.swift contains this:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="">import</span><span style="font-variant-ligatures:no-common-ligatures" class=""> Foundation</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="">import</span><span style="font-variant-ligatures:no-common-ligatures" class=""> CoreData</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="">@objc</span><span style="font-variant-ligatures:no-common-ligatures" class="">(PHAudioFile)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="">public</span><span style="font-variant-ligatures:no-common-ligatures" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="">class</span><span style="font-variant-ligatures:no-common-ligatures" class=""> PHAudioFile: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">NSManagedObject</span><span style="font-variant-ligatures:no-common-ligatures" class=""> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">}</span></div></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class="">With this error on the "</span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="">public</span><span style="font-family: menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-family:menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="">class</span><span style="font-family: menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class=""> PHAudioFile</span>" line:</div><div class=""><br class=""></div><div class="">"Invalid redeclaration of <span style="font-family: menlo; font-size: 11px;" class="">PHAudioFile</span>"</div><div class=""><br class=""></div><div class=""><div class="">PHAudioFile+CoreDataProperties.swift starts with this line:</div></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(112, 61, 170);" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="">extension</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures:no-common-ligatures" class="">PHAudioFile</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> {</span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><br class=""></span></div><div class="">Which breaks with:</div><div class=""><br class=""></div><div class="">"'<span style="font-family: menlo; font-size: 11px;" class="">PHAudioFile</span>' is ambiguous for type lookup in this context"</div><div class=""><br class=""></div><div class="">and of course every line thereafter breaks too.</div><div class=""><br class=""></div><div class="">Searching for '<span style="font-family: menlo; font-size: 11px;" class="">PHAudioFile</span>' in my Xcode project, finds only those two files. In particular I can't find any other declaration for '<span style="font-family: menlo; font-size: 11px;" class="">PHAudioFile</span>'.</div><div class=""><br class=""></div><div class="">Am I missing something, or is this broken?</div><div class=""><br class=""></div><div class="">Thanks,</div><div class=""><br class=""></div><div class="">Jean-Denis</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">has this line in error:<br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></div>
_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></div></body></html>