The Swift, Non-Storyboard, Document-Based Application Template is Broken

Originator:nate
Number:rdar://18194445 Date Originated:9/1/2014
Status:Open Resolved:No
Product:OS X SDK Product Version:14A298i
Classification:Serious Bug Reproducible:Always
 
Summary:
Versions: Xcode: Version 6.0 (6A280e), OS X: 10.10 (14A298i)

The Swift, non-storyboard, document-based application template does not produce apps that function immediately.

Steps to Reproduce:
Steps to Reproduce:
Install and open Xcode 6A280e under OS X 10.10 (14A298i).

Create a new Cocoa Application.
Enter Any Product Name, Organization Name, Organization Identifier.
Select Swift as the language.
Uncheck “Use Storyboards”.
Check “Create Document-Based Application”.
Enter any Document Extension.
Uncheck “Use Core Data”.

Create the project in an auspicious location on disk.

(Alternatively: download the attached Demo.zip, extract its contents, and open the enclosed Xcode project.)

Run the app.

You will see an alert with the text “No document could be created.

You will see in the console <<2014-09-01 16:35:22.463 Demo[39748:12877248] The DocumentType type doesn't map to any NSDocumentClass.>>


Expected Results:
A new Document window should appear when the app launches for the first time or whenever you select "File"->"New".

Actual Results:
When the app launches for the first time, and thereafter whenever you select "File"->"New", an alert is presented with the text "No document could be created." and into the console is logged "The DocumentType type doesn't map to any NSDocumentClass.".

Version:
Xcode: Version 6.0 (6A280e)
OS X: 10.10 (14A298i)

Notes:
There are a couple of workarounds:

(1)  Override readableTypes() in Document.swift:

    override class func readableTypes() -> [AnyObject] {
        return ["DocumentType"]
    }

(2)  In the Info.plist, change the entry for "Document Types"->"Item 0"->"Cocoa NSDocument Class" to the mangled version of "$(PRODUCT_MODULE_NAME).Document" (for example "_TtC4Demo8Document").

It looks like the immediate cause of the bug is in the implementation of -[NSDocumentController _getReadableNotWritable:types:forDocumentClass:] where the unmangled "Demo.Document" is compared via isEqualToString: to the mangled "_TtC4Demo8Document" with predictable results.

Configuration:


Attachments:
'Demo.zip' was successfully uploaded.

Comments

This issue has been verified as resolved and can be closed. Resolved in DP6.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!