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

相關文章
相關標籤/搜索