Fire & Document Based Apps for Apple Platform


(Alan White) #1

Can anyone help me with the correct process for taking the generated macOS project in Fire to being a document based app using storyboards please? I’ve gone round in circles trying to figure this out and not making much headway.

My only experience in doing this before Fire is in Xcode, where it generate all the basic artefacts needed for a document based app. As such there may be better way’s to think about this so happy to hear if so!


(marc hoffman) #2


it should be pretty straight-forward and work basically the same as it would in an Xcode project — you’ll create a descendant from NSDocument where you implement the right methods to read/write your project, along with a view, and then all you need to do is register that in the Info.plist.

Examples from Fire itself:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">

<plist version="1.0">
                <string>Fire Solution</string>

where SolutionDocument is the NSDocument Descendant class I implemented, and where I overrode these two methods:

    public override bool writeToURL(NSURL! url) ofType(NSString! typeName) forSaveOperation(NSSaveOperationType saveOperation) originalContentsURL(NSURL absoluteOriginalContentsURL) error(ref NSError outError)
    public override bool readFromURL(NSURL! url) ofType(NSString! typeName) error(ref NSError outError)

as well

    public override void makeWindowControllers()
        this.addWindowController(new SolutionDocumentWindowController withDocument(this));

to create it's Window (snippets are C#, but same concepts apply in Oxygene or Silver).

I'll see if I can turn this into full sample project, next week

(Alan White) #3

Thanks Marc, as always! Would be good to see an example that doesn’t use storyboards to achieve the document model Apple implement. Might help me piece together what’s going on under all these artefacts!

(marc hoffman) #4

Lemme see if I can whip one up now. Whats your preferred language? I’ll start with that (and we’ll of course later convert it to all four).

(Alan White) #5

Definitely swift for me please Marc!

(marc hoffman) #6 (438.9 KB)

How does this look for a start?

(Alan White) #8

Deleted my question as on reflection I didn’t think it was fair to ask you. One of my biggest challenges with the Apple ecosystem is it’s not transparent how much of the routing and behaviours happen in an app.

Trying to find out why now, in the example provided, we don’t get the click on window title to bring down the save as panel.

(marc hoffman) #9

No, by all means, please ask — if I can help, I’ll be happy to, and it might benefit other readers, as well!

curious, yeah, I didn’t notice that. in Fire itself I get that for free w/o any manual code…

(Alan White) #10

Found it!

In FooDocument.swift add this code:

override class var autosavesInPlace: Bool {
    return true

(marc hoffman) #11

Interesting. I just came across that reviewing Fire as well, but thought, “na, that cant possibly influence that, can it…?” :wink:

(Alan White) #12

Obscure eh? :slight_smile:

(marc hoffman) #13

Updated the sample.

(marc hoffman) #14


(marc hoffman) #15

Final Sample is up, for all four languages, at (and the corresponding three other languages folders).