How to eject expo project to native code

2020-08-22 03:32发布

问题:

I eject project from expo with command npm run eject. It generates 2 folders ios and android. I tried to run the project by xcode but it still display this error. Maybe I'm not clear how to run project after eject, can you help me run it. I run some statements to install pod, but cannot work https://github.com/CocoaPods/CocoaPods/issues/2303

回答1:

So with ejecting, you should have been presented with two options:

? How would you like to eject from create-react-native-app? (Use arrow keys)
❯ React Native: I'd like a regular React Native project. 
  ExpoKit: I'll create or log in with an Expo account to use React Native and the Expo SDK. 
  Cancel: I'll continue with my current project structure. 

If you chose the first (React Native), then there should have been no issues with opening up your Xcode project and running the app (there would also be no pods to install). Since your error and comment indicates otherwise, I can presume that you chose option 2: Expokit.

For that, you should have been prompted with something about making an Expo account or using an existing one:

? How would you like to eject from create-react-native-app? 
  React Native: I'd like a regular React Native project. 
❯ ExpoKit: I'll create or log in with an Expo account to use React Native and the Expo SDK. 
  Cancel: I'll continue with my current project structure.

  An Expo account is required to proceed.
? It appears you're already logged in to Expo as ...

After that, you'll need to follow the steps in Developing With ExpoKit. Specifically to get iOS running, you need follow all of the steps in this section after running npm run eject.

If you've done all of that, then it should work fine when running in conjunction with Expo XDE or exp. I've just tested both right now and it works without error. Double check your steps to make sure you didn't miss something. Otherwise, please edit your question with more details on exactly what commands you ran, what other dependencies you have, etc. as I'm unable to reproduce the error you have.



回答2:

If you want to download new project without expo then try run:

react-native init ProjectNameHere

or , If you want to convert your own project without expo then try :

 1. rm -rf node_modules
 2. remove expo dependencies from package.json
 3. npm install
 4. react-native upgrade

(Note:This following step will create new ios and android folder and you have to redo the dependencies. I was struggling with the same issue so I posted my solution)