2

How can I regenerate ios and android folder in React Native project?

react-native-cli: 2.0.1 react-native: 0.61.2

❯ react-native eject error Unrecognized command "eject". info Run "react-native --help" to see a list of all available commands.

❯ react-native upgrade --legacy true error: unknown option `--legacy'

Walid
  • 700
  • 2
  • 10
  • 29

2 Answers2

2

You can init a new project that's named the same in another folder and copy ios dir over:

inside YourProjectName directory

npx react-native init YourProjectName
mv YourProjectName/ios ios
rm -rf YourProjectName

Make sure you have clean git history before doing so, in case you need to revert

Ahmad Khani
  • 850
  • 2
  • 10
  • 15
-1

To Regenerate ios and android folder in React Native project?

1.If you are using react-native <=0.59.0 Then react-native eject

React-native had this command in the previous version. Running this command will check if the ios and android directories exist and then rebuild whichever one is missing.

sudo rm -rf android/ ios/

react-native eject // Will create new Android and IOS folder.

react-native link

react-native run-android

2.If you are using react-native >=0.60.0 Then react-native upgrade --legacy true

Now you should use the react-native upgrade --legacy true command to back up your android folders or ios as the case may be as this command will replace your files.

Ravi Sharma
  • 507
  • 6
  • 21
  • 6
    OP already tried to use `react-native upgrade --legacy true` but gets the error `react-native upgrade --legacy true error: unknown option `--legacy'` – Simon Jan 10 '20 at 15:39