react-native-navigation的迁移库

AppDelegate.m 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #import "AppDelegate.h"
  2. #import <React/RCTBundleURLProvider.h>
  3. // **********************************************
  4. // *** DON'T MISS: THE NEXT LINE IS IMPORTANT ***
  5. // **********************************************
  6. #import "RCCManager.h"
  7. // IMPORTANT: if you're getting an Xcode error that RCCManager.h isn't found, you've probably ran "npm install"
  8. // with npm ver 2. You'll need to "npm install" with npm 3 (see https://github.com/wix/react-native-navigation/issues/1)
  9. #import <React/RCTRootView.h>
  10. @implementation AppDelegate
  11. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  12. {
  13. NSURL *jsCodeLocation;
  14. #ifdef DEBUG
  15. // jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
  16. jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
  17. #else
  18. jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
  19. #endif
  20. // **********************************************
  21. // *** DON'T MISS: THIS IS HOW WE BOOTSTRAP *****
  22. // **********************************************
  23. self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  24. self.window.backgroundColor = [UIColor whiteColor];
  25. [[RCCManager sharedInstance] initBridgeWithBundleURL:jsCodeLocation];
  26. /*
  27. // original RN bootstrap - remove this part
  28. RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
  29. moduleName:@"example"
  30. initialProperties:nil
  31. launchOptions:launchOptions];
  32. self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  33. UIViewController *rootViewController = [UIViewController new];
  34. rootViewController.view = rootView;
  35. self.window.rootViewController = rootViewController;
  36. [self.window makeKeyAndVisible];
  37. */
  38. return YES;
  39. }
  40. @end