NOTE the syntax has been updated for XCode 10.1 and Swift 5 in Jun 2019 ( credits to matt's answer here && Tung Fam's answer here ), if you are looking for the previous syntaxes look at the edit section. Ok, I've found the solution First, I've noticed that, at the top of the AppDelegate.swift file, there is this line @UIApplicationMain Since this line is outside any scope (it's at file level), it'