Document-based app fails to create new document in Xcode 4.3.2


I’m trying to build a document-based application in Xcode 4.3.2, and it fails to open a new document, maybe because the default template Apple provides is somehow corrupt in Xcode 4.3.2

Here’s are the exact steps that lead to the below error message when I open my application:

  1. Open a new project using the Applescript ObjC document-based application template.
  2. Enable garbage collection in Target > Build Settings, since the Applescript ObjC application template has this disabled.
  3. Adding one document type in Target > Info > Document Types, choosing basic values. (Class is set by default to Document.)
  4. At this point if I try to build the application, it fails, suggesting me to delete the word “script” in “end script” down the bottom of the default Document.applescript file. So I delete this extra “script” and the project builds fine, but:
  5. No document window is created when I open the app, and trying to create a new document results in the console error quoted higher.

Is there anything I can do to fix this unexpected behavior? I think I might have to submit a bug report to Apple for the template to be fixed, but wanted to be sure I’m not missing something important here.

Thanks for your expertise on this!


The template is borked. All the outError code doesn’t work. More importantly, it uses the reserved AS word data as a parameter to readFromData_ofType_error_, which is never going to work. If you have my book, you can read about this in the chapter on document-based apps.

Hi Shane,

Thanks for your response. I’ve now found the root cause of my issue, that is not exactly the one your post suggests, although it’s linked to the template Apple provides.
The current document-based AppleScript Obj-C template that comes with Xcode 4.3 was modified by Apple since you wrote chapter 22.

There are 2 extra modifications to make to the default template so that the app once built successfully opens a new document window:

  1. In the Document.applescript file, replace “script Document” with “script MyDocument”
    Failing to do so results in the project failing to build, suggesting that “end script” should be replaced with just “end”

  2. In the Target > Info > Document Types > DocumentType, set Class to “MyDocument” in place of just “Document”

I’ll be submitting a bug report to Apple to try to have that fixed asap.


If you enter a class prefix in the “Choose options for your new project” dialog you will no longer had to make many of the changes mentioned above!

Just posted more about this in my Linked In group: