Selaa lähdekoodia

Update AppDelegate.m (#3026)

To save new RNN users some trouble, I've updated the recommended Obj-C that the installation guide tells us to paste over our App Delegate. I think the old one is obsolete because the #import and one of the Obj-C methods has change. Also removed a potentially misleading warning that might now cause users to wrongly blame their NPM version for trouble instead of these new changes. Anyway this new version works for me though someone might want to double check.
John Gorenfeld 6 vuotta sitten
vanhempi
commit
350f89db9d
1 muutettua tiedostoa jossa 11 lisäystä ja 28 poistoa
  1. 11
    28
      example/ios/example/AppDelegate.m

+ 11
- 28
example/ios/example/AppDelegate.m Näytä tiedosto

@@ -1,14 +1,17 @@
1
+/**
2
+ * Copyright (c) 2015-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ */
9
+
1 10
 #import "AppDelegate.h"
2 11
 #import <React/RCTBundleURLProvider.h>
3 12
 
4
-// **********************************************
5
-// *** DON'T MISS: THE NEXT LINE IS IMPORTANT ***
6
-// **********************************************
7 13
 #import "RCCManager.h"
8 14
 
9
-// IMPORTANT: if you're getting an Xcode error that RCCManager.h isn't found, you've probably ran "npm install"
10
-// with npm ver 2. You'll need to "npm install" with npm 3 (see https://github.com/wix/react-native-navigation/issues/1)
11
-
12 15
 #import <React/RCTRootView.h>
13 16
 
14 17
 @implementation AppDelegate
@@ -17,34 +20,14 @@
17 20
 {
18 21
   NSURL *jsCodeLocation;
19 22
 #ifdef DEBUG
20
-//  jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.bundle?platform=ios&dev=true"];
21 23
   jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
22 24
 #else
23
-   jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
25
+  jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
24 26
 #endif
25
-
26
-
27
-  // **********************************************
28
-  // *** DON'T MISS: THIS IS HOW WE BOOTSTRAP *****
29
-  // **********************************************
27
+  
30 28
   self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
31 29
   self.window.backgroundColor = [UIColor whiteColor];
32 30
   [[RCCManager sharedInstance] initBridgeWithBundleURL:jsCodeLocation launchOptions:launchOptions];
33
-
34
-  /*
35
-  // original RN bootstrap - remove this part
36
-  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
37
-                                                      moduleName:@"example"
38
-                                               initialProperties:nil
39
-                                                   launchOptions:launchOptions];
40
-  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
41
-  UIViewController *rootViewController = [UIViewController new];
42
-  rootViewController.view = rootView;
43
-  self.window.rootViewController = rootViewController;
44
-  [self.window makeKeyAndVisible];
45
-  */
46
-  
47
-
48 31
   return YES;
49 32
 }
50 33