Xcode 6 missing main.swift file for new projects

I reinstalled Xcode 6 after I was unable to get the usual ctrl-click help. Now, when I create a new Xcode project for OS X Cocoa Application, the main.swift file is no longer in the supporting files, as it was before. I have 2 sections and Mavericks on one, Yosemite on the other. Can someone tell me what is happening and how to get around it? This is my first question, feel free to tell me any errors in this, please. Thanks

+4
source share
1 answer

You do not need a file main.swift. The main (heh) purpose of this file is to call NSApplicationMain(), the function that launches the Cocoa application. But, since every application should do this, Apple has added a less capable way of doing something.

Now you just need to mark the application delegate class with an attribute @NSApplicationMain. Then, Xcode will create the correct hooks so that your application runs in its main launch loop with an instance of the class you select as a delegate NSApp. New project templates do this, so you no longer need it main.swift. (It also frees you from having to assign an application delegate to the main bank, which is useful for applications using the OS X storyboard.)

, , , NSApplication, main.swift NSApplicationMain() . ( , @NSApplicationMain .)

+13

All Articles