npx pod-install返回“此项目不支持CocoaPods". [英] npx pod-install returns "CocoaPods is not supported in this project"

查看:662
本文介绍了npx pod-install返回“此项目不支持CocoaPods".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文:我正在尝试使用react-native-video创建一个React Native应用程序. iOs安装说明以npx pod-install开头.

Context: I'm trying to create a React Native App with react-native-video. The iOs installation instruction starts with npx pod-install.

运行:

npx pod-install

返回:

npx: installed 1 in 1.113s
Scanning for pods...
CocoaPods is not supported in this project

输出消息尚未对我有帮助.因此,我去了 npm pod-install .看起来它抽象了CocoaPods和宝石的复杂性.

The output message is not yet helpful to me. So I went to npm pod-install. Looks like it abstracts CocoaPods and gem complexity away.

有比学习CocoaPods和gem更简单的方法来解决此问题了吗?

Is there an easier way to resolve this issue than learning CocoaPods and gem?

package.json

package.json

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "expo": "~37.0.3",
    "react": "~16.9.0",
    "react-dom": "~16.9.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz",
    "react-native-video": "^4.4.5",
    "react-native-web": "~0.11.7"
  },
  "devDependencies": {
    "babel-preset-expo": "~8.1.0",
    "@babel/core": "^7.8.6"
  },
  "private": true
}

推荐答案

出现错误的原因是因为您正在使用Expo构建自己的React-Native项目.

The reason you are getting the error is because you are building your React-Native project with Expo.

Expo将本机代码推算在远离您的地方,因此您不必处理本机代码.另外,Expo项目不允许您编辑本机代码. Cocoapods将本机代码添加到您的应用程序中,因此这就是您遇到错误的原因.

Expo extrapolates the native code away from you so that you don't have to deal with native code. Also an Expo project does not allow you to edit native code. Cocoapods add native code to your app, so this is why you are getting your error.

如果您希望在Expo项目中使用视频,则应查看Expo附带的内容,视频文档为

If you wish to use video in an Expo project then you should look at what is provided with Expo, the documentation for video is here.

如果这不符合您的需求,并且您需要使用react-native-video,那么您将需要从Expo中获取项目eject,以使其成为完整的React-Native项目.这不是您应该轻而易举地采取的步骤,而无需首先进行充分研究.

If this doesn't suit your needs and you need to use react-native-video then you will need to eject your project from Expo so that it becomes a full React-Native project. This is not a step that you should do lightly, and without fully researching it first.

我还建议您熟悉此 SO问题解释了Expo和React-Native之间的区别

I would also suggest you familiarise yourself with the answers to this SO question that explains the differences between Expo and React-Native

这篇关于npx pod-install返回“此项目不支持CocoaPods".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆