简体   繁体   English

React Native - XCode(RNTextDetector)上的应用程序构建失败

[英]React Native - App Build Failed on XCode (RNTextDetector)

I am working on my company's old React Native project and trying to run the app on the simulator.我正在处理我公司的旧 React Native 项目并尝试在模拟器上运行该应用程序。

These are the steps what I have done in order:这些是我按顺序执行的步骤:

  1. I checked out the code from git我检查了 git 的代码
  2. Run command npm install to install node_modules运行命令npm install安装 node_modules
  3. go into ios folder and run pod install to create Pods folder go 进入 ios 文件夹并运行pod install创建 Pods 文件夹
  4. Open XCode and run the app打开 XCode 并运行应用程序

At the 4th step, the app was almost successfully built but then the errors occured in file RNTextDetector.m (the path is {Root}/node_modules/rn-text-detector/ios/RNTextDetector.m ).在第 4 步,应用程序几乎成功构建,但文件RNTextDetector.m中出现错误(路径为{Root}/node_modules/rn-text-detector/ios/RNTextDetector.m )。 Most of them are "Use of undeclared identifier 'xxx'".其中大多数是“使用未声明的标识符'xxx'”。 Here are the errors:以下是错误:

在此处输入图像描述

Here is my package.json:这是我的 package.json:

{
  "name": "xxx",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@notifee/react-native": "^3.0.4",
    "@react-native-community/art": "^1.2.0",
    "@react-native-community/async-storage": "^1.11.0",
    "@react-native-community/datetimepicker": "^3.5.2",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-native-community/progress-bar-android": "^1.0.3",
    "@react-native-community/progress-view": "^1.0.3",
    "@react-native-community/toolbar-android": "0.2.1",
    "@react-native-firebase/app": "^12.9.0",
    "@react-native-firebase/messaging": "^12.9.0",
    "@react-native-picker/picker": "^2.2.1",
    "@react-navigation/material-top-tabs": "^6.2.1",
    "@react-navigation/native": "^6.0.1",
    "@react-navigation/stack": "^6.2.1",
    "axios": "^0.24.0",
    "babel-preset-react-native": "^4.0.1",
    "expo-local-authentication": "^12.1.1",
    "flow-bin": "^0.137.0",
    "jest": "^26.6.3",
    "jwt-decode": "^3.1.2",
    "moment": "^2.29.3",
    "moment-timezone": "^0.5.34",
    "native-base": "^2.13.12",
    "react": "^17.0.1",
    "react-native": "^0.64.2",
    "react-native-biometrics": "^2.1.4",
    "react-native-calendars": "^1.1267.0",
    "react-native-camera": "^3.35.0",
    "react-native-chart-kit": "^6.12.0",
    "react-native-elements": "^2.0.4",
    "react-native-file-viewer": "^2.1.1",
    "react-native-fs": "^2.16.6",
    "react-native-gesture-handler": "^1.10.3",
    "react-native-image-crop-picker": "^0.32.2",
    "react-native-image-picker": "^4.8.3",
    "react-native-keyboard-aware-scroll-view": "^0.9.1",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-modal": "^11.5.6",
    "react-native-pager-view": "^5.4.24",
    "react-native-pdf": "^6.2.0",
    "react-native-picker-select": "^8.0.0",
    "react-native-pie-chart": "^2.0.2",
    "react-native-reanimated": "^1.9.0",
    "react-native-rename": "^2.9.0",
    "react-native-render-html": "^6.3.4",
    "react-native-safe-area-context": "^3.0.2",
    "react-native-screens": "^3.13.1",
    "react-native-simple-toast": "^1.1.2",
    "react-native-svg": "^12.1.1",
    "react-native-swipe-list-view": "^3.2.9",
    "react-native-tab-view": "^3.1.1",
    "react-native-vector-icons": "^7.0.0",
    "react-navigation": "^4.4.0",
    "react-query": "^3.34.2",
    "react-redux": "^7.2.0",
    "redux": "^4.0.5",
    "redux-devtools-extension": "^2.13.8",
    "redux-thunk": "^2.3.0",
    "rn-fetch-blob": "^0.12.0",
    "rn-text-detector": "0.0.8",
    "toggle-switch-react-native": "^3.3.0",
    "typescript": "^3.9.7"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "babel-jest": "^26.6.3",
    "babel-plugin-root-import": "^6.5.0",
    "babel-plugin-styled-components": "^1.10.7",
    "eslint": "^7.14.0",
    "metro-react-native-babel-preset": "^0.64.0",
    "react-test-renderer": "^17.0.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

After I looked into RNTextDetector's original repository (rn-text-detector), I found this thread and try following their code and it works!在查看了 RNTextDetector 的原始存储库 (rn-text-detector) 之后,我找到了这个线程并尝试按照他们的代码进行操作,它可以工作!

The solution is to add @import MLKitTextRecognitionCommon;解决方法是添加@import MLKitTextRecognitionCommon; in file RNTextDetector.m as shown below:在文件RNTextDetector.m中,如下所示:

#import "RNTextDetector.h"

#import <React/RCTBridge.h>
#import <React/RCTLog.h>

@import MLKitTextRecognitionCommon;
@import MLKitTextRecognition;
@import MLKitVision;

@implementation RNTextDetector
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM