React Native 踩坑

1.react-native ListView的屬性flexWrap為wrap不起作用解決之道

2.React Native 0.32以下版本Xcode8報錯解決辦法

2.1 'RCTRootView.h' file not found

  • cd到這個項目中,執行npm install react-native
  • 此項目中還有其他依賴,執行npm install,即可添加所有依賴


如果運行還有錯誤,請參考以下

2.2 RCTSRWEBSOCKET.M報錯
Ignoring return value of function declared with warn_unused_result attribute
這個報錯在此文件中有兩處,代碼
SecRandomCopyBytes(kSecRandomDefault, sizeof(uint32_t), (uint8_t *)mask_key);
修改為
(void)SecRandomCopyBytes(kSecRandomDefault, sizeof(uint32_t), (uint8_t *)mask_key);

2.3 RCTSCROLLVIEW.M 報錯
Use of undeclared identifier '_refreshControl'; did you mean 'refreshControl'?

@implementation RCTCustomScrollView { __weak UIView *_dockedHeaderView; RCTRefreshControl *_refreshControl; // 加入此行 }


重新打開項目運行

3.React Native iOS 之Could not connect to development server
將項目中的

jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];

改為本地IP

jsCodeLocation = [NSURL URLWithString:@"http://127.0.0.1:8081/index.ios.bundle?platform=ios&dev=true"];

PS:127.0.0.1為本地的IP

reason:做本地局域網開發環境,大部分都會做服務器映射處理,localhost 被指向特定的IP 而不是本機的127.0.0.1, 就會出現這樣的問題。
4.項目開始運行報錯



原因一:
先前運行過其它的React-Native項目。
解決辦法:
退出終端程序,重新運行項目即可
原因二:
AppDelegate.m文件中



index.iOS.js文件中

兩個文件中MyProject字段設置不一樣。

解決辦法:
將字段設為一樣的字符即可。

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容