react-native 版本是0.55.4
1. 安裝 react-native-file-selector 插件
npm i react-native-file-selector -S
2. 執行 react-native link react-native-file-selector
ios版本
1. 選中 項目工程/Libraries 右鍵 Add File to "xxx(app工程)

如果 選擇的 RNFileSelector.xcodeproj 文件是灰色的 ,
1. 在這個目錄(node_modules/react-native-file-selector/ios)下 運行 pod install ,
2. 然后選擇 Pods.xcodeproj文件 ,路徑: node_modules/react-native-file-selector/ios/Pods/Pods.xcodeproj
2. 在build phases / Link Binary with libraries 下添加 FileBrowser.framework



3. Build Settings -> Frameworks Search Path 添加 ${BUILT_PRODUCTS_DIR}/FileBrowser


4. 處理這個插件的bug (沒有這個會報線程出錯 Thread 1: signal SIGABRT)
具體錯誤信息
查看詳情錯誤 xCode

dyld: Library not loaded: @rpath/libswiftCore.dylib
Referenced from: /Users/***/Library/Developer/Xcode/DerivedData/APPName-ciohvchhwvwbfubwetjezrhgxcbs/Build/Products/Debug-iphonesimulator/FileBrowser.framework/FileBrowser
Reason: image not found
解決辦法:



注意點:

android 依賴時出現各種問題處理
1. build時報錯,包下載不下來,超時
Could not resolve all artifacts for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:3.5.3.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:3.5.3.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.3/gradle-3.5.3.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.3/gradle-3.5.3.pom'.
> Connection reset
> Could not resolve com.android.tools.build:gradle:3.5.3.
> Could not get resource 'http://maven.google.com/nexus/content/groups/public/com/android/tools/build/gradle/3.5.3/gradle-3.5.3.pom'.
> Could not GET 'http://maven.google.com/nexus/content/groups/public/com/android/tools/build/gradle/3.5.3/gradle-3.5.3.pom'.
> Connect to maven.google.com:80 [maven.google.com/172.217.24.67, maven.google.com/2404:6800:4005:805:0:0:0:2003] failed: Connection timed out: connect
處理方法 :
1. 到node_modules / react-native-file-selector / android / build.gradle 文件下面
把 google() 替換成 maven { url 'https://maven.aliyun.com/repository/google' }
把 jcenter() 替換成 maven { url 'https://maven.aliyun.com/repository/jcenter' }
2. 如果后面啟動項目還報這個錯誤 , 可以去項目下 “項目應用 / android / build.gradle 文件
a. 同上 替換 上面倆個google() 和 jcenter()
b. 可以把 maven { url "https://maven.google.com" } 注釋掉,這個下載依賴 會出現 443 拉不下來的問題
2. Could not resolve com.nbsp:library:1.8.

解決:到node_modules / react-native-file-selector / android / build.gradle
它更新到 1.9.x:所以使用 compile 'com.nbsp:materialfilepicker:1.9.1'
把 compile 'com.nbsp:library:1.8' 替換成 compile 'com.nbsp:materialfilepicker:1.9.1'
3. com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
這是因為編譯的版本配置不正確
原版
android {
compileSdkVersion safeExtGet("compileSdkVersion", 27)
buildToolsVersion safeExtGet("buildToolsVersion", "27.0.3")
defaultConfig {
minSdkVersion safeExtGet("minSdkVersion", 16)
targetSdkVersion safeExtGet("targetSdkVersion", 27)
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
}
修改之后
android {
compileSdkVersion safeExtGet("compileSdkVersion", 28)
buildToolsVersion safeExtGet("buildToolsVersion", "28.0.3")
defaultConfig {
minSdkVersion safeExtGet("minSdkVersion", 21)
targetSdkVersion safeExtGet("targetSdkVersion", 28)
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
}
4. 如果的你用的是 androidx 會報一些老的類已經棄用
//import android.support.v4.app.ActivityCompat;
import androidx.core.app.ActivityCompat;
//import android.support.v4.content.ContextCompat;
import androidx.core.content.ContextCompat;
//import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
5. build 應用包報錯
Could not determine the dependencies of task ':react-native-file-selector:verifyReleaseResources'.
> Could not resolve all task dependencies for configuration ':react-native-file-selector:releaseRuntimeClasspath'.

解決辦法:
修改文件路徑:node_modules/react-native-file-selector/android/build.gradle
注釋下面代碼:

