Skip to content

Instantly share code, notes, and snippets.

@ikhsanalatsary
Created September 30, 2018 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ikhsanalatsary/6573592c41b0613fec6be24f739472d2 to your computer and use it in GitHub Desktop.
Save ikhsanalatsary/6573592c41b0613fec6be24f739472d2 to your computer and use it in GitHub Desktop.
ifdef in Swift
//
// AppDelegate.swift
// ReactNativeSwift
//
// Created by Gabriel Lai on 26/8/18.
// Copyright © 2018 Facebook. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
let jsCodeLocation: URL
#if DEBUG
jsCodeLocation = RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index", fallbackResource: nil)
#else
jsCodeLocation = CodePush.bundleURL()
#endif
let rootView = RCTRootView(bundleURL: jsCodeLocation, moduleName: "ReactNativeSwift", initialProperties: nil, launchOptions: launchOptions)
rootView?.backgroundColor = UIColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 1)
window = UIWindow(frame: UIScreen.main.bounds)
let rootViewController = UIViewController()
rootViewController.view = rootView
window?.rootViewController = rootViewController
window?.makeKeyAndVisible()
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment