Search code examples
core-dataswiftdocument-basedxcode6

Document-Based App with Swift


Can someone please tell me how to fix the Apple Template in Xcode 6 for a document-based app with Swift. I've tried with and without core data(prefer with), with storyboards instead of regular Xibs. The standard, out of the box template returns a "The [insert document type here] type doesn't map to any NSDocumentClass. It's pretty frustrating when they release a new language with templates that don't work.


Solution

  • With the addition of modules in Xcode 6 and swift, you now have to qualify the document class type. For example, if my application name is MyApp (and I haven't created any other modules), and my document type is MyDoc, in Document Types the class should be listed as MyApp.MyDoc.

    I can't post screenshots of this yet because the NDA, but here are the steps to recreate what I changed:

    1. Inside Xcode, click on your application in the explorer pane
    2. Select your application under targets
    3. Click the Info tab on the top toolbar
    4. Expand Document Types

    Name - Document Type (your choice)

    Class - MyApp.MyDoc <--- Reflects the addition of modules, this won't show up in the dropdown (at least not as of Dev Preview 4)

    Extensions - mydoc (your choice)

    Icon - your icon image file

    Identifier - some unique identifier for the document type, generally use com.companyname.extension

    Role - editor (your choice)

    Mime Types - None (if you are using an XML Store you could change this to text/xml)

    Bundled - false

    Additional Info - I didn't have to add this to the exported UTI's, but I think its best practice to do so