#ios #react-native #expo #cocoapods
Вопрос:
Я пытаюсь создать версию проекта react native для ios, работает версия для Android. Я не могу заставить версию ios работать на mac, пытаясь использовать expo или просто с помощью симулятора. После запуска expo запускаются следующие ошибки:
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)
Это мой пакет.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
Ответ №1:
cd ios // from your main directory pod install
кроме того, RNFirebase прокомментирован в вашем подфайле здесь:
#pod 'RNFirebase', :path => '../node_modules/react-native-firebase'
Ошибка говорит вам, что этот модуль не установлен, и это может быть причиной
Комментарии:
1. это не проблема, мне посоветовали изменить файл модуля на: платформа :ios, «11.0» require_relative «../node_modules/react-native-унимодули/cocoapods.rb» require_relative «../node_modules/react-native/скрипты/react_native_pods» require_relative «../node_modules/@react-native-сообщество/cli-платформа-ios/native_modules» целевые «лидеры» используют unimodules! конфигурация=use_native_модули! use_react_native! (:путь=>конфигурация[«Реактивный путь»]) конец
2. @shai и RNFirebase, и RNFBMessaging закомментированы в вашем подфайле, поэтому они никогда не устанавливаются в pod install.