2015-10-27 20:59:15 +00:00
|
|
|
/* Copyright 2015 Realm Inc - All Rights Reserved
|
|
|
|
* Proprietary and Confidential
|
|
|
|
*/
|
2015-10-02 21:57:54 +00:00
|
|
|
|
|
|
|
#import "AppDelegate.h"
|
|
|
|
#import "RCTRootView.h"
|
|
|
|
|
2015-10-26 20:25:15 +00:00
|
|
|
static NSString * const RealmReactEnableChromeDebuggingKey = @"RealmReactEnableChromeDebugging";
|
|
|
|
static NSString * const RCTDevMenuKey = @"RCTDevMenu";
|
|
|
|
|
2015-10-02 21:57:54 +00:00
|
|
|
@implementation AppDelegate
|
|
|
|
|
2015-10-26 20:25:15 +00:00
|
|
|
- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
|
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
|
|
|
|
|
|
// Check if this default is explicitly set, otherwise just leave the settings as is.
|
|
|
|
if ([defaults objectForKey:RealmReactEnableChromeDebuggingKey]) {
|
|
|
|
NSMutableDictionary *settings = [([defaults dictionaryForKey:RCTDevMenuKey] ?: @{}) mutableCopy];
|
|
|
|
NSMutableDictionary *domain = [[defaults volatileDomainForName:NSArgumentDomain] mutableCopy];
|
|
|
|
|
2016-01-06 23:24:00 +00:00
|
|
|
settings[@"executorClass"] = [defaults boolForKey:RealmReactEnableChromeDebuggingKey] ? @"RCTWebSocketExecutor" : @"RCTJSCExecutor";
|
2015-10-26 20:25:15 +00:00
|
|
|
domain[RCTDevMenuKey] = settings;
|
|
|
|
|
|
|
|
// Re-register the arguments domain (highest precedent and volatile) with our new overridden settings.
|
|
|
|
[defaults removeVolatileDomainForName:NSArgumentDomain];
|
|
|
|
[defaults setVolatileDomain:domain forName:NSArgumentDomain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2015-10-22 09:34:46 +00:00
|
|
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
|
|
NSURL *jsCodeLocation;
|
|
|
|
|
2016-01-15 09:57:58 +00:00
|
|
|
#if TARGET_OS_SIMULATOR
|
2015-10-22 09:34:46 +00:00
|
|
|
/**
|
|
|
|
* OPTION 1
|
|
|
|
* Load from development server. Start the server from the repository root:
|
|
|
|
*
|
|
|
|
* $ npm start
|
|
|
|
*
|
|
|
|
* To run on device, change `localhost` to the IP address of your computer
|
|
|
|
* (you can get this by typing `ifconfig` into the terminal and selecting the
|
|
|
|
* `inet` value under `en0:`) and make sure your computer and iOS device are
|
|
|
|
* on the same Wi-Fi network.
|
|
|
|
*/
|
|
|
|
|
2016-01-15 09:57:58 +00:00
|
|
|
#if DEBUG
|
|
|
|
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
|
|
|
|
#else
|
|
|
|
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=false"];
|
|
|
|
#endif
|
2015-10-22 09:34:46 +00:00
|
|
|
|
2016-01-15 09:57:58 +00:00
|
|
|
#else
|
2015-10-22 09:34:46 +00:00
|
|
|
/**
|
|
|
|
* OPTION 2
|
2016-01-15 09:57:58 +00:00
|
|
|
* Load from pre-bundled file on disk. The static bundle is automatically
|
|
|
|
* generated by "Bundle React Native code and images" build step.
|
2015-10-22 09:34:46 +00:00
|
|
|
*/
|
|
|
|
|
2016-01-15 09:57:58 +00:00
|
|
|
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
|
|
|
|
#endif
|
2015-10-22 09:34:46 +00:00
|
|
|
|
|
|
|
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
|
|
|
|
moduleName:@"ReactTests"
|
|
|
|
initialProperties:nil
|
|
|
|
launchOptions:launchOptions];
|
|
|
|
|
|
|
|
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
|
|
|
UIViewController *rootViewController = [[UIViewController alloc] init];
|
|
|
|
rootViewController.view = rootView;
|
|
|
|
self.window.rootViewController = rootViewController;
|
|
|
|
[self.window makeKeyAndVisible];
|
|
|
|
return YES;
|
2015-10-02 21:57:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|