UIApplicationMain issue

Hi all, i'm trying xcode 8 and swift 3 with one of my apps. I have an own main.swift file that works on swift 2.3.


My main.swift file looks like this:

UIApplicationMain(Process.argc, Process.unsafeArgv, nil, NSStringFromClass(AppDelegate))


The problem now is that Process.unsafeArgv has changed and it's declaration is:

public static var unsafeArgv: UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>


And the declaration of UIApplicationMain is not expecting an optional value for argv parameter:

public func UIApplicationMain(_ argc: Int32, _ argv: UnsafeMutablePointer<UnsafeMutablePointer<Int8>>!, _ principalClassName: String?, _ delegateClassName: String?) -> Int32


Any help to fix this is welcome


Thanks!!

Replies

You just need to convert the `Pointee` type:

UIApplicationMain(Process.argc, UnsafeMutablePointer(Process.unsafeArgv), nil, NSStringFromClass(AppDelegate))


But why don't you use `@UIApplicationMain`?

Your line of main.swift is very ordinary and it seems you have no need to have main.swift.

Remove main.swift, and put `@UIApplicationMain` to your AppDelegate class.

This thread: https://forums.developer.apple.com/thread/46405 answers your question.