web-dev-qa-db-fra.com

React Échec de la construction native: fichier 'React / RCTBridge.h' introuvable.

J'essaie de construire une React application native avec la structure de fichier suivante:

Kurts-MacBook-Pro-2:lucy-app kurtpeek$ tree -L 1
.
├── README.md
├── __tests__
├── Android
├── app.json
├── assets
├── index.js
├── ios
├── node_modules
├── package.json
├── src
└── yarn.lock

Le package.json est

{
    "name": "app",
    "version": "0.0.1",
    "private": true,
    "scripts": {
        "Android": "concurrently 'emulator @Nexus_5X_API_27_x86' 'yarn Android-noavd'",
        "Android-noavd": "react-native run-Android",
        "Android-px": "concurrently 'emulator @Pixel_2_API_27' 'yarn Android-noavd'",
        "Android:release": "cross-env ENVFILE=.env.release yarn run Android",
        "Android:staging": "cross-env ENVFILE=.env.staging yarn run Android",
        "build:Android:dev": "cross-env ENVFILE=.env ./Android/gradlew assembleRelease -p ./Android/",
        "build:Android:release": "cross-env ENVFILE=.env.release ./Android/gradlew assembleRelease -p ./Android/",
        "build:Android:staging": "cross-env ENVFILE=.env.staging ./Android/gradlew assembleRelease -p ./Android/",
        "clean": "concurrently 'rimraf ./Android/build/' 'rimraf ./ios/build/' 'rimraf node_modules/' 'yarn cache clean'",
        "codepush": "yarn codepush:ios; yarn codepush:Android",
        "codepush:Android": "code-Push release-react Lucy-Eng/LucyApp-Android android",
        "codepush:ios": "code-Push release-react Lucy-Eng/LucyApp-iOS ios --plistFile ios/LucyApp/Info.plist",
        "codepush:ls:apps": "code-Push app ls",
        "codepush:ls:deploys": "echo iOS && code-Push deployment ls Lucy-Eng/LucyApp-iOS; echo Android && code-Push deployment ls Lucy-Eng/LucyApp-Android",
        "codepush:promote:Android": "code-Push promote Lucy-Eng/LucyApp-Android Staging Production",
        "codepush:promote:ios": "code-Push promote Lucy-Eng/LucyApp-iOS Staging Production",
        "ios": "react-native run-ios --simulator='iPhone 7'",
        "ios8": "react-native run-ios --simulator='iPhone 8'",
        "ios:release": "cross-env ENVFILE=.env.release yarn run ios",
        "ios:staging": "cross-env ENVFILE=.env.staging yarn run ios",
        "iosx": "react-native run-ios --simulator='iPhone X'",
        "lint": "eslint .",
        "log:Android": "react-native log-Android",
        "log:ios": "react-native log-ios",
        "react-devtools": "react-devtools",
        "start": "./node_modules/react-native/local-cli/cli.js start",
        "test": "jest"
    },
    "dependencies": {
        "analytics-react-native": "^1.2.0",
        "immutability-helper": "^2.5.0",
        "libphonenumber-js": "^1.1.10",
        "lodash": "^4.17.4",
        "moment": "^2.19.0",
        "moment-timezone": "^0.5.14",
        "prop-types": "^15.6.0",
        "querystring": "^0.2.0",
        "raven-for-redux": "^1.3.0",
        "react": "^16.2.0",
        "react-native": "^0.53.3",
        "react-native-Android-keyboard-adjust": "^1.1.1",
        "react-native-code-Push": "^5.3.2",
        "react-native-config": "^0.11.5",
        "react-native-country-picker-modal": "^0.5.1",
        "react-native-datepicker": "^1.6.0",
        "react-native-intercom": "^8.0.0",
        "react-native-keyboard-aware-scroll-view": "^0.4.4",
        "react-native-markdown-renderer": "^3.1.0",
        "react-native-material-kit": "git://github.com/xinthink/react-native-material-kit#95b0980",
        "react-native-material-menu": "^0.2.3",
        "react-native-modal": "^4.1.1",
        "react-native-onesignal": "^3.0.6",
        "react-native-phone-input": "^0.2.1",
        "react-native-router-flux": "4.0.0-beta.27",
        "react-native-sentry": "^0.35.3",
        "react-native-smart-splash-screen": "^2.3.5",
        "react-native-snackbar": "^0.4.3",
        "react-native-swiper": "^1.5.13",
        "react-native-vector-icons": "^4.4.0",
        "react-navigation": "^1.5.11",
        "react-redux": "^5.0.6",
        "redux": "^3.7.2",
        "redux-devtools-extension": "^2.13.2",
        "redux-form": "^7.3.0",
        "redux-logger": "^3.0.6",
        "redux-persist": "^4.10.1",
        "redux-thunk": "^2.2.0",
        "reselect": "^3.0.1",
        "validator": "^10.2.0"
    },
    "devDependencies": {
        "babel-core": "^6.26.3",
        "babel-eslint": "^8.0.1",
        "babel-jest": "21.2.0",
        "babel-preset-react-native": "4.0.0",
        "code-Push-cli": "^2.1.6",
        "concurrently": "^3.5.1",
        "cross-env": "^5.1.4",
        "enzyme": "^3.1.1",
        "enzyme-adapter-react-16": "^1.0.4",
        "eslint": "^4.8.0",
        "eslint-config-airbnb": "^15.1.0",
        "eslint-import-resolver-reactnative": "^1.0.2",
        "eslint-plugin-import": "^2.7.0",
        "eslint-plugin-jsx-a11y": "^5.1.1",
        "eslint-plugin-react": "^7.4.0",
        "eslint-plugin-react-native": "^3.1.0",
        "jest": "21.2.1",
        "react-devtools": "^3.1.0",
        "react-dom": "^16.0.0",
        "react-test-renderer": "16.0.0-beta.5",
        "rimraf": "^2.6.2"
    },
    "jest": {
        "preset": "react-native",
        "setupTestFrameworkScriptFile": "<rootDir>src/test-config/enzyme-config.js"
    },
    "rnpm": {
        "assets": [
            "./assets/fonts/"
        ]
    }
}

et il y a un ios/Podfile ainsi:

target 'LucyApp' do
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'BatchedBridge',
    'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket', # needed for debugging
    # 'RCTBridge',
    # Add any other subspecs you want to use in your project
  ]
  # Explicitly include Yoga if you are using RN >= 0.42.0
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  # Third party deps podspec link
  pod 'Intercom'
  pod 'CodePush', :path => '../node_modules/react-native-code-Push'
  pod 'SentryReactNative', :path => '../node_modules/react-native-sentry'

  # Add new pods below this line

end

Lorsque j'essaie de créer cette application dans Xcode, une erreur d'importation survient de SentryReactNative:

enter image description here

De même, lorsque j'essaie de lancer le simulateur en utilisant yarn ios, Je reçois l’erreur suivante:

In file included from /Users/kurtpeek/Documents/Dev/lucy/lucy-app/node_modules/react-native-sentry/ios/RNSentry.m:1:
In file included from /Users/kurtpeek/Documents/Dev/lucy/lucy-app/node_modules/react-native-sentry/ios/RNSentry.h:4:
/Users/kurtpeek/Documents/Dev/lucy/lucy-app/node_modules/react-native/React/Base/RCTBridge.h:12:9: fatal error: 'React/RCTBridgeDelegate.h' file not found
#import <React/RCTBridgeDelegate.h>
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~



** BUILD FAILED **


The following commands produced analyzer issues:

    Analyze Base/RCTModuleMethod.mm normal x86_64
(1 command with analyzer issues)

The following build commands failed:
    CompileC /Users/kurtpeek/Documents/Dev/lucy/lucy-app/ios/build/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/SentryReactNative.build/Objects-normal/x86_64/RNSentryEventEmitter.o /Users/kurtpeek/Documents/Dev/lucy/lucy-app/node_modules/react-native-sentry/ios/RNSentryEventEmitter.m normal x86_64 objective-c com.Apple.compilers.llvm.clang.1_0.compiler
(1 failure)

Installing build/Build/Products/Debug-iphonesimulator/LucyApp.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist

Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/LucyApp.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist


error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Après https://facebook.github.io/react-native/docs/integration-with-existing-apps.html#configuring-cocoapods-dependencies , j'ai d'abord pensé que je pourrais avoir besoin d'ajouter 'RCTBridge' au subspecs de 'React', qui est la raison de la ligne commentée dans le Podfile. Cependant, si je supprime le commentaire de cette ligne et essaie de pod install, Je reçois une erreur "CocoaPods n’a pas trouvé de versions compatibles":

enter image description here

Comment puis-je mettre à jour les importations pour que l'application soit construite?

11
Kurt Peek

Suivez les étapes ci-dessous. Cela a fonctionné pour moi.

  1. Ouvrez terminal
  2. Allez dans le dossier ios
  3. Quitter Xcode
  4. courir pod install
  5. Ouvrir .xcworkspace fichier.
  6. Nettoyer (cmd+shift+k) et construire (cmd+b) le projet.

C'est ça. Bonne codage :)

6
Manish

Essaye ça -

  • Dans Xcode, accédez au schéma de projet (Produit -> Schéma -> Gérer le schéma -> double-cliquez sur votre projet).
  • Cliquez sur l'option 'Construire' dans le volet de gauche.
  • Décochez la case 'Paralléliser la construction' sous Options de construction.
  • Ensuite, dans la section Cibles, cliquez sur le bouton "+" puis recherchez "Réagir". Sélectionnez-le et cliquez sur 'Ajouter'.
  • "Réagir" devrait maintenant apparaître sous la section Cibles. Cliquez dessus et faites-le glisser vers le haut pour qu'il s'agisse du premier élément de la liste (avant votre projet).
  • Nettoyez le projet et construisez.

Pour plus d'options, consultez le problème sur RN repo - https://github.com/facebook/react-native/issues/12042

5
akshay gore

Travaillé pour moi, pas de bidouillage (conseillé uniquement si vous n'utilisez pas Swift):

  1. Fichier> Paramètres du projet
  2. Sur le système construit, choisissez> Système de construction hérité (les deux)
  3. Dans la même fenêtre, ouvrez et nettoyez votre répertoire DerivedData
  4. Nettoyer votre produit> Nettoyer Enregistrez tout et redémarrez le Xcode. Bon codage!
1
Marcio Prudencio