Any one knows the launch sequence of a swift app?. As i can see there is no main
function in a swift application. Then who is responsible for doing this
// Entry point of a normal iOS app
int main(int argc, char * argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
Your application object and AppDelegate is getting created here. But for swift app i was wondering who is creating these.
If any one knows, share your thoughts.
If you look at AppDelegate.Swift
class, you will find the @UIApplicationMain
statement written in the global area of the file. As @Daniel also mention in his answer.
Now I tried commenting that line and compiling the code, look what I got..
In very simple language, error say compiler trying to search implicit entry/start for main executable
, but not getting.
it shows @UIApplicationMain
statement in AppDelegate.Swift
creates a implicit entry point for Swift program.
And I tried to write main.swift class explicitly...it works.
my main.swift looks like..
import Foundation
import UIKit
UIApplicationMain(C_ARGC, C_ARGV, NSStringFromClass(UIApplication), NSStringFromClass(AppDelegate))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With