title: Core Data Codegen fail in Xcode 8
body: <p>I have an iOS app containing a Core Data model with 6 entities. The entity <code>Name</code> is set up as follows:</p>
  
  <blockquote>
    <p>Class Name: <strong>Name</strong> </p>
    
    <p>Module: <strong>Current Product Module</strong> </p>
    
    <p>Codeine: <strong>Class Definition</strong></p>
  </blockquote>
  
  <p>(all 5 other entities are set up similarly).</p>
  
  <p><strong>Problem 1</strong> (fixed itself but leaving for posterity)</p>
  
  <p>Code IS generated in the derived data folder… not as ~class definitions as expected, but as extensions instead (named like <code>Name+CoreDataProperties.swift</code>. It doesn't seem to matter whether the Codegen is set to Class Definition or Category/Extension - I still get the same result.</p>
  
  <p><em>OK, hold that thought - all of a sudden both the class and extension files ARE now being generated… it looks like you need to delete the project's derived data folder and restart Xcode in between updates. Ignore Problem 1</em></p>
  
  <p><strong>Problem 2</strong></p>
  
  <p>Generated files ignore the data model Optional flag setting for String attributes and relationships - they are all generated as optionals</p>
  
  <p><strong>Problem 3</strong> (fixed itself but leaving for posterity)</p>
  
  <p>Ordered relationships are generated as <code>OrderedSet</code> (and a compilation error) rather than <code>NSOrderedSet</code> (can't change them as they get re-generated)</p>
  
  <p>Workaround for me was to temporarily add to the project…
  <code>
  public typealias OrderedSet = NSOrderedSet
  </code>  </p>
  
  <p><em>OK, now the compiler error has gone, and <code>OrderedSet</code> seems to be recognised. Ignore Problem 3.</em></p>
  
  <p><strong>Problem 4</strong></p>
  
  <p>None of the above really matters, because the compiler can't find the files it's just generated. For the <code>Name</code> entity above:</p>
  
  <blockquote>
    <p>:0: error: no such file or directory:
    '/Users/ashleymills/Library/Developer/Xcode/DerivedData/-grfqveelvqtlydbpwjmfdietnrss/Build/Intermediates/.build/Debug-iphonesimulator/.build/DerivedSources/CoreDataGenerated//.Name+CoreDataClass.swift'
    :0: error: no such file or directory:
    '/Users/ashleymills/Library/Developer/Xcode/DerivedData/-grfqveelvqtlydbpwjmfdietnrss/Build/Intermediates/.build/Debug-iphonesimulator/.build/DerivedSources/CoreDataGenerated//.Name+CoreDataProperties.swift'</p>
  </blockquote>
  
  <p>It's looking in derived data for files <code>.Name+CoreDataClass.swift</code> and <code>.Name+CoreDataProperties.swift</code> - notice the '.' at the front of the file names. (As a temp fix I added the generated files into the project)</p>
  
  <p>I assume I'm doing something wrong, as if this was the case for everyone, no-one would be able to build a Core Data project… or are these bugs that need raising?</p>
  
  <p>Cheers
  Ash</p>
  
  <p>(Also raised on Apple dev forums)</p>