React Native iOS pod install报错:无法找到React-RCTFabric依赖
React Native iOS pod install 报错:找不到React-RCTFabric依赖
执行pod install时触发如下错误:
Unable to find a specification for 'React-RCTFabric' depends upon by 'RNGestureHandler'
项目Android端可正常构建,但iOS端始终无法完成Pod安装。已尝试清理node_modules重装依赖、替换为react-native init生成的默认Podfile,问题均未解决。
项目配置信息
package.json
{ "name": "caremeMobile", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "lint": "eslint .", "start": "react-native start", "test": "jest" }, "dependencies": { "@config-plugins/react-native-ble-plx": "^3.0.0", "@material-ui/core": "^4.12.4", "@material-ui/pickers": "^3.3.10", "@mui/material": "^5.3.0", "@react-native-async-storage/async-storage": "~1.17.3", "@react-native-masked-view/masked-view": "^0.2.8", "@react-native-picker/picker": "^2.4.8", "@react-navigation/bottom-tabs": "^6.0.9", "@react-navigation/devtools": "^6.0.4", "@react-navigation/drawer": "^6.5.0", "@react-navigation/native": "^6.0.13", "@react-navigation/native-stack": "^6.9.1", "@types/lodash": "^4.14.186", "@types/uuid": "^8.3.4", "cron-parser": "^4.5.0", "i18next": "^21.6.10", "i18next-browser-languagedetector": "^7.0.0", "jetifier": "^2.0.0", "js-base64": "^3.7.2", "lodash": "^4.17.21", "metro-config": "^0.66.2", "native-base": "2.15.2", "react": "18.2.0", "react-dom": "18.0.0", "react-i18next": "^11.15.3", "react-native": "0.71.1", "react-native-ble-plx": "^2.0.3", "react-native-bluetooth-state-manager": "^1.3.4", "react-native-calendars": "^1.1276.0", "react-native-circular-action-menu": "^0.5.0", "react-native-elements": "^3.4.2", "react-native-gesture-handler": "~2.5.0", "react-native-get-random-values": "~1.8.0", "react-native-keyboard-aware-scroll-view": "^0.9.5", "react-native-linear-gradient": "^2.6.2", "react-native-modal-datetime-picker": "^14.0.0", "react-native-paper": "^4.11.2", "react-native-reanimated": "^2.11.0", "react-native-safe-area-context": "4.3.1", "react-native-screens": "~3.15.0", "react-native-svg": "12.3.0", "react-native-svg-transformer": "^1.0.0", "react-native-swipe-list-view": "^3.2.9", "react-native-ui-lib": "^6.22.1", "react-native-uuid": "^2.0.1", "rxjs": "^7.5.2", "uuid": "^8.3.2", "victory-native": "^36.6.8", "visualtis-messaging-service": "file:./visualtis-messaging-service-1.0.0.tgz" }, "devDependencies": { "@babel/core": "^7.20.0", "@babel/preset-env": "^7.20.0", "@babel/runtime": "^7.20.0", "@react-native-community/eslint-config": "^3.0.0", "@tsconfig/react-native": "^2.0.2", "@types/jest": "^29.2.1", "@types/react": "^18.0.24", "@types/react-test-renderer": "^18.0.0", "babel-jest": "^29.2.1", "eslint": "^8.19.0", "jest": "^29.2.1", "metro-react-native-babel-preset": "0.73.7", "prettier": "^2.4.1", "react-test-renderer": "18.2.0", "typescript": "4.8.4" }, "jest": { "preset": "react-native" } }
Podfile
require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' platform :ios, min_ios_version_supported prepare_react_native_project! # If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set. # because `react-native-flipper` depends on (FlipperKit,...) that will be excluded # # To fix this you can also exclude `react-native-flipper` using a `react-native.config.js` # ```js # module.exports = { # dependencies: { # ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}), # ``` flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled linkage = ENV['USE_FRAMEWORKS'] if linkage != nil Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green use_frameworks! :linkage => linkage.to_sym end target 'mobile' do config = use_native_modules! # Flags change depending on the env values. flags = get_default_flags() use_react_native!( :path => config[:reactNativePath], # Hermes is now enabled by default. Disable by setting this flag to false. # Upcoming versions of React Native may rely on get_default_flags(), but # we make it explicit here to aid in the React Native upgrade process. :hermes_enabled => flags[:hermes_enabled], :fabric_enabled => flags[:fabric_enabled], # Enables Flipper. # # Note that if you have use_frameworks! enabled, Flipper will not work and # you should disable the next line. :flipper_configuration => flipper_config, # An absolute path to your application root. :app_path => "#{Pod::Config.instance.installation_root}/.." ) target 'mobileTests' do inherit! :complete # Pods for testing end post_install do |installer| react_native_post_install( installer, # Set `mac_catalyst_enabled` to `true` in order to apply patches # necessary for Mac Catalyst builds :mac_catalyst_enabled => false ) __apply_Xcode_12_5_M1_post_install_workaround(installer) end end
解决方法
1. 强制关闭Fabric新架构
React Native 0.71默认禁用Fabric,但你的Podfile中使用了flags[:fabric_enabled],可能存在环境变量误开启的情况。直接在Podfile中强制关闭:
修改use_react_native!中的配置项:
:fabric_enabled => false,
或者在项目根目录创建.xcode.env.local文件,添加:
RCT_NEW_ARCH_ENABLED=0
2. 升级react-native-gesture-handler
当前使用的~2.5.0版本可能对Fabric有不必要的依赖,升级到适配RN 0.71的最新稳定版:
npm install react-native-gesture-handler@latest
之后进入ios目录重新执行pod install。
3. 彻底清理Pod缓存
执行以下命令清除所有Pod相关缓存和文件,重新安装:
cd ios pod deintegrate rm Podfile.lock rm -rf ~/Library/Caches/CocoaPods rm -rf Pods pod install
4. 检查本地依赖包
确认项目中的本地包visualtis-messaging-service没有引入对Fabric的依赖,避免与主项目冲突。
内容的提问来源于stack exchange,提问作者Juanpe318
相关产品推荐
相关产品推荐

