Created
November 20, 2017 18:19
-
-
Save justinmakaila/42773a50c1aa86d03e6c1b3536042280 to your computer and use it in GitHub Desktop.
React Native App Delegate in Swift 4.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
let CodeLocation = "index" | |
let ModuleName = "<ProjectName>" | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
func application( | |
_ application: UIApplication, | |
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil | |
) -> Bool { | |
guard let codeLocation = RCTBundleURLProvider.sharedSettings().jsBundleURL( | |
forBundleRoot: CodeLocation, | |
fallbackResource: nil | |
), | |
let rootView = RCTRootView( | |
bundleURL: codeLocation, | |
moduleName: ModuleName, | |
initialProperties: nil, | |
launchOptions: launchOptions | |
) | |
else { | |
return false | |
} | |
let rootViewController = UIViewController() | |
rootViewController.view = rootView | |
self.window = UIWindow(frame: UIScreen.main.bounds) | |
self.window?.rootViewController = rootViewController | |
self.window?.makeKeyAndVisible() | |
return true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add a bridging header to the project with these contents: