So most common and also the toughest question is can we rename the existing react native project? A simple answer is YES YOU CAN. There are many RIGHT ways to achieve this. but if you miss some minor details then the mistake cost goes very high. You need to follow any method listed right below.
You can change the name attribute in
react-native upgrade, and just let react overwrite the android/ios files. Don't overwrite your index files if there is unsaved code, however.
Then change your Appregistry line from
AppRegistry.registerComponent('MyAppIOS', () => MyAppIOS);
AppRegistry.registerComponent('MyApp', () => MyApp);
What simply works for me several times is instructed below;
- First copy the directory in which your to-be-name-changed application exists. And go to your newly cloned directory.
- Change the name at
index.ios/android.jsfile which is given as a parameter to
- Change the name and version accordingly on
/androidfolders which are remaining from your older app as well as the
app.jsonfile if you have.
$react-native upgradeto generate
$react-native linkfor any external dependency.
- finally, run
$react-native run-iosor anything you want.
Method-3 [Onlt For Android]
The way I did this for android (hacky, but it works) is just changed the string app_name field in
It will change the name of your installed android app to whatever you put as the value. After this change re-run the app.
Now the time comes what you need to take care or YOU SHOULD NOT DO
You might also hear about the npm package (react-native-rename):
react-native-rename < newName >
It works fine but……it will ruin your project. Never use this
Hope this helps someday! ❤