So a while ago I deleted the /ios directory in my react native app (let\'s call it X). I\'ve been developing and testing using the android emulator but now I\'d like to make
As @Alok mentioned in the comments, you can do react-native eject
to generate the ios
and android
folders. But you will need an app.json
in your project first.
{"name": "example", "displayName": "Example"}
The process you need to follow is so similar to renaming a react native app. Basically you just need to run react-native upgrade
in your root project directory. For further info you can check another question here. The instructions below explains how to create another react native project based on a copied one with a new name.
index.ios/android.js
file which is given as a parameter to AppRegistry.package.json
/ios
and /android
folders which are remaining from your older app.$react-native upgrade
to generate /ios
and /android
folders again.$react-native link
for any native dependency.$react-native run-ios
or anything you want.PS: Take backup of your code in case it changes App.js
I just found myself with this problem too, but I just solved it.
Surely when running the "react-native upgrade" command, it gave them the message that it was not necessary to update or with the command "react-native eject" that the command is not recognized.
react-native upgrade
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.
react-native upgrade --legacy true
Now it's just telling you not to replace your package.json
It seems like react-native eject
is no more available. The only way I could find for recreating the ios folder was to generate it from scratch.
Take a backup of your ios folder
mv /path_to_your_old_project/ios /path_to_your_backup_dir/ios_backup
Navigate to a temporary directory and create a new project with the same name as your current project
react-native init project_name
mv project_name/ios /path_to_your_old_project/ios
Install the pod dependencies inside the ios folder within your project
cd /path_to_your_old_project/ios
pod install
If you are lost with errors like module not found there is noway other the than following method if you have used react native CLI.I had faced similar issue as a result of openning xcode project from .xcodeproj file instead of .xcworkspace. Also please note that react-native eject only for Expo project.
The only workaround to regenarate ios and android folders within a react native project is the following.
Now your problem should be solved