【问题标题】:react native can not build ios app Error: RNFirebase core module was not found natively on iOSreact native can't build ios app Error: RNFirebase core module was not found native on iOS
【发布时间】:2021-12-02 17:11:03
【问题描述】:

我正在尝试构建 ios 版本的 react native 项目, 安卓版本正在运行。 我无法让 ios 版本在 mac 上运行,尝试使用 expo 或仅通过模拟器。 运行 expo start 后出现以下错误:

Error: RNFirebase core module was not found natively on iOS, ensure you have correctly included the RNFirebase pod in your projects `Podfile` and have run `pod install`.
Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.

当我运行 react-native run-ios 时出现以下错误:

The following build commands failed:
        CompileC /Users/agam/Library/Developer/Xcode/DerivedData/leaders-dwqehxydbohqcgbabuncaztlrzsn/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RNFirebase.build/Objects-normal/x86_64/RNFirebaseFirestore.o /Users/agam/Desktop/theleadersapp/node_modules/react-native-firebase/ios/RNFirebase/firestore/RNFirebaseFirestore.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'RNFirebase' from project 'Pods')
(1 failure)

这是我的 package.json

    {
  "scripts": {
    "start": "react-native start",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "web": "expo start --web",
    "postinstall": "jetify"
  },
  "dependencies": {
    "@expo/vector-icons": "^12.0.0",
    "@react-native-async-storage/async-storage": "~1.15.0",
    "@react-native-community/picker": "^1.8.1",
    "@react-native-community/push-notification-ios": "^1.10.1",
    "@react-native-firebase/app": "^12.9.1",
    "@react-native-firebase/messaging": "^12.9.1",
    "@react-native-picker/picker": "1.16.1",
    "@unimodules/react-native-adapter": "~6.3.4",
    "axios": "^0.19.2",
    "expo": "^42.0.0",
    "expo-cli": "^4.8.1",
    "expo-font": "~9.2.1",
    "hashmap": "^2.4.0",
    "i18n-js": "^3.5.1",
    "lodash.memoize": "^4.1.2",
    "moment": "^2.24.0",
    "pod-install": "^0.1.27",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "0.63.4",
    "react-native-calendar-picker": "^6.0.5",
    "react-native-datepicker": "^1.7.2",
    "react-native-dropdown": "0.0.6",
    "react-native-fbsdk": "^1.1.2",
    "react-native-firebase": "^5.6.0",
    "react-native-gesture-handler": "~1.10.2",
    "react-native-htmlview": "^0.15.0",
    "react-native-icon-badge": "^1.1.3",
    "react-native-image-picker": "^2.3.0",
    "react-native-instagram-login": "^2.0.0",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-localize": "^1.3.1",
    "react-native-modal": "^12.1.0",
    "react-native-modal-picker": "0.0.16",
    "react-native-multiple-select-list": "^1.0.4",
    "react-native-paper": "^2.16.0",
    "react-native-picker-module": "^2.0.4",
    "react-native-picker-select": "^6.5.0",
    "react-native-push-notification": "^7.4.0",
    "react-native-reanimated": "~2.2.0",
    "react-native-safe-area-context": "3.2.0",
    "react-native-screens": "~3.4.0",
    "react-native-simple-radio-button": "^2.7.4",
    "react-native-ui-xg": "0.0.6",
    "react-native-unimodules": "~0.14.5",
    "react-native-vector-icons": "^6.6.0",
    "react-native-webview": "11.6.2",
    "react-navigation": "^3.11.1",
    "react-navigation-header-buttons": "^3.0.1",
    "react-navigation-material-bottom-tabs": "^1.0.0",
    "react-redux": "^7.1.3",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0",
    "unimodules-app-loader": "~2.2.0",
    "watchman": "^1.0.0"
  },
  "devDependencies": {
    "@babel/core": "~7.9.0",
    "@types/react": "~16.9.35",
    "@types/react-native": "~0.63.2",
    "babel-jest": "~24.9.0",
    "babel-preset-expo": "8.3.0",
    "jest": "~24.9.0",
    "jetifier": "~1.6.4",
    "metro-react-native-babel-preset": "~0.56.0",
    "react-native-dotenv": "^0.2.0",
    "react-test-renderer": "~16.9.0",
    "redux-devtools-extension": "^2.13.8",
    "typescript": "~4.0.0"
  },
  "private": true
}

这是我的 pod 文件:

     platform :ios, '11.0'
require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'


target 'leaders' do
#  rnPrefix = "../node_modules/react-native"
    use_unimodules!
    config=use_native_modules!
    use_react_native!(:path=>config["reactNativePath"])
end

【问题讨论】:

    标签: ios react-native expo cocoapods


    【解决方案1】:
    cd ios // from your main directory
    pod install
    

    此外,RNFirebase 已在您的 podFile 中被注释掉:

    #pod 'RNFirebase', :path => '../node_modules/react-native-firebase'
    

    错误提示您未安装此 pod,这可能是原因

    【讨论】:

    • 这不是问题,建议我将 pod 文件更改为:platform :ios, '11.0' require_relative '../node_modules/react-native-unimodules/cocoapods.rb' require_relative ' ../node_modules/react-native/scripts/react_native_pods'require_relative'../node_modules/@react-native-community/cli-platform-ios/native_modules'目标'领导者'使用_unimodules!配置=use_native_modules! use_react_native!(:path=>config["reactNativePath"]) end
    • @shai RNFirebase 和 RNFBMessaging 在你的 podfile 中都被注释掉了,所以它们永远不会安装在 pod install 中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-06-10
    • 1970-01-01
    • 1970-01-01
    • 2022-06-16
    • 1970-01-01
    • 2022-08-15
    • 2019-12-23
    相关资源
    最近更新 更多