報錯提示 undefined is not an object (evaluating 'RNFetchBlob.DocumentDir')

鏈接Android包
打開android/app/build.gradle,添加此行
dependencies {
...
+ implementation project(':rn-fetch-blob')
}
打開android/settings.gradle,添加這些行,將RNFetchBlob Android項目依賴項添加到您的應用程序。
include ':app'
+ include ':rn-fetch-blob' + project(':rn-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/rn-fetch-blob/android')
添加這些行MainApplication.java,以便RNFetchBlob包成為React Native包的一部分。
...
+ import com.RNFetchBlob.RNFetchBlobPackage;
...
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
+ new RNFetchBlobPackage()
);
}
};
...
項目<0.28
React Native在0.27中更改了OkHttp版本,如果您的項目早於0.28,則必須明確指定OkHttp版本 node_modules/rn-fetch-blob/android/build.gradle
dependencies {
implementation 'com.facebook.react:react-native:+'
+ implementation 'com.squareup.okhttp3:okhttp:3.4.1'
- //{RNFetchBlob_PRE_0.28_DEPDENDENCY}
}
鏈接IOS包
打開Xcode在導航器中展開項目,然后右鍵單擊Libraries,選擇Add files to ..

選擇 node_modules/rn-fetch-blob/ios/RNFetchBlob.xcodeproj

在導航器中單擊您的項目,在TARGET中選擇您的項目,然后單擊General

單擊+ sign“ 鏈接的框架和庫”下的

選擇並添加 libRNFetchBlob.a

最終我報錯的原因是xcode沒有link上,參考git文章地址rn-fetch-blob,需要能夠幫助你
