npx pod-install returns "CocoaPods is not supported in this project"

Xaver Fleer picture Xaver Fleer · Jun 17, 2020 · Viewed 9.6k times · Source

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

Running:

npx pod-install

Returns:

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

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.

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


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
}

Answer

Andrew picture Andrew · Jun 17, 2020

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

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.

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.

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.

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