There is no main() method in swift. The program must start the execution from somewhere. So what is the entry point of swift code execution and how is it decided?
main()
The entry point in a plain Swift module is the file in the module called main.swift. main.swift is the only file which is allowed to have expressions and statements at the top level (all other Swift files in the module can only contain declarations).
main.swift
Cocoa Touch uses the @UIApplicationMain attribute on an implementation of UIApplicationDelegate instead of a main.swift file to mark the entry point. Cocoa used to use a minimal main.swift file which simply called NSApplicationMain, but as of Xcode 6.1 uses the @NSApplicationMain attribute on an implementation of NSApplicationDelegate.
@UIApplicationMain
UIApplicationDelegate
NSApplicationMain
@NSApplicationMain
NSApplicationDelegate
2.1m questions
2.1m answers
60 comments
57.0k users