react-native啟動開發常見錯誤(持續更新)

toringo發表於2018-11-18

react-native啟動開發常見錯誤(持續更新)

1. debug error: make directory ... File exists

error: make directory /Users/mobilewise/Library/Developer/Xcode/DerivedData/MCDM-epoyegaizqaljifbmfuxvovvwxqn/Build/Products/Debug-iphoneos/MCDM_guangzhoudianwang.app/mapapi.bundle/images: File exists
error: couldn't remove '/Users/mobilewise/Library/Developer/Xcode/DerivedData/MCDM-epoyegaizqaljifbmfuxvovvwxqn/Build/Products/Debug-iphoneos/MCDM_guangzhoudianwang.app/mapapi.bundle' after command failed: Directory not empty
複製程式碼

解決方案: Build Phases--->>Copy Bundle Resources, 刪除多餘的檔案即可 ., 類似的缺少打包後存放目錄的檔案件等, 新建資料夾即可。

2. iOS開發 Build operation failed without specifying any errors 問題fix

xcode報錯如下:

verify final result code for completed build operation
Build operation failed without specifying any errors. Individual build tasks may have failed for unknown reasons.
One possible cause is if there are too many (possibly zombie) processes; in this case, rebooting may fix the problem.
Some individual build task failures (up to 12) may be listed below.
複製程式碼

解決方案如下: 是由於cocoapods版本導致, 重新安裝即可:

//刪除1.4.0包
sudo gem uninstall cocoapods -v 1.4.0

//然後安裝指定版本的Cocoapods
sudo gem install cocoapods -v 1.3.1

//檢查版本
pod --version
複製程式碼

參考文章-掘金

3. 專案地址改變後出現問題

Argument list too long: recursive header expansion failed at 解決方案:Build Settings -> User Header Search Paths 刪除其中內容

4. 安卓打包報錯

':app:bundleReleaseJsAndAssets FAILED'
解決方案: ./gradlew assembleRelease -x bundleReleaseJsAndAssets

5. 安卓打包報錯

Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease 解決方案:add the below to your ProGuard rules ` -ignorewarnings

-keep class * { public private *; } ` stackoverflow.com/questions/4…

6. 安卓模擬器debbuger報錯

CORS issue with JS Remote Debugging when using xip.io 解決辦法https://github.com/facebook/react-native/issues/17618

7. 安卓webview無法返回資料

react native android webview onmessage not working 解決方案:

// 方案1
if (window.postMessage.length !== 1) {
  window.postMessage = function(msg) {
    setTimeout(function () {
      console.log('window.postMessage not ready')
      window.postMessage(msg);
    }, 500);
  }
}
// 方案2
function waitForBridge() {

   //the react native postMessage has only 1 parameter
   //while the default one has 2, so check the signature
   //of the function

   if (window.postMessage.length !== 1){
     setTimeout(waitForBridge, 200);
   }
   else {
     window.postMessage('abc');
   }
}

window.onload = waitForBridge;
複製程式碼

參考

github.com/facebook/re… stackoverflow.com/questions/4…

8. Xcode 10 的一些錯誤

錯誤:third-party: 'config.h' file not found

github.com/facebook/re…

錯誤:'config.h' file not found

github.com/facebook/re…

錯誤: libfishhook.a cannot be found

github.com/facebook/re…

錯誤: ``React/RCTBridgeModule.hfile not found

stackoverflow.com/questions/4…

9. iOS編譯報錯duplicate symbol OBJC_CLASS$_RCTFrameAnimation

dfile:

圖片描述
圖片描述
參考: github.com/auth0/react…

ios. 啟動報錯

The request was denied by service delegate (SBMainWorkspace) for reason: Security ("Entitlement "com.apple.frontboard.debugapplications" required to launch applications for debugging"). 解決方案: 刪除以下資料夾所有內容:/Users/xx/資源庫/Developer/CoreSimulator/Devices/ 參考: www.jianshu.com/p/133672f61…

相關文章