React – Native 踩坑记

 

  1. 运行的时候先报错说can’t be opened because it is from an unidentified developer,这是osx本身安全设置搞过高,去安全选项改了(allow apps download from anywhere)以后。又报错说permission问题,因而在终端用(chmod -R 755 /项目根目录)(主意:755后面必定要加空格)把全部文件都改为755权限,而后就能够完美运行了。
  2. 用模拟器和真机调试时,环境不一样,在工程AppDelegate.m的- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions方法中:模拟器调试时用jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];真机调试时用jsCodeLocation = [NSURL URLWithString:@"http://10.18.51.27:8081/index.ios.bundle?platform=ios&dev=true"];
  3. 找不到sever,没有注册 : 项目根目录下运行 react-native start
  4. cocoaPods 集成第三方库,编译报错 symbol(s) not found for architecture arm64 在other linker Flags 中添加 $(inherited)
  5. cocoaPods 找不到头文件 在user header search path 中添加$(SRCART)
  6. 当属性为函数引用时,若是该引用函数中有用到this,须要用bind方法将this传递进去
  7. 另一直解决方案是:
    文件: RCTWrapperViewController.m
    方法: - (void)viewWillAppear:(BOOL)animated
    插入下面一句

self.navigationController.tabBarController.tabBar.hidden=self.navigationController.childViewControllers.count>1?YES:NO;react

相关文章
相关标签/搜索