Renaming a React Native project?
Are there instructions for what needs to be changed in order to rename a React Native project? I have an app called something along the lines of MyAppIOS and I want to rename it to simply MyApp (now that Android support is out)
The way I did this for android (hacky, but it works) is just changed the string app_name field in
android/app/src/main/res/values/strings.xml
It will change the name of your installed android app to whatever you put as the value.
You can change the name attribute in package.json
, run 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);
To:
AppRegistry.registerComponent('MyApp', () => MyApp);
What simply works for me several times is instructed below;
- First copy the directory which your to-be-name-changed application exists. And go to your newly cloned directory.
- Change the name at
index.ios/android.js
file which is given as a parameter toAppRegistry
. - Change the name and version accordingly on
package.json
- delete
/ios
and/android
folders which are remaining from your older app as well as theapp.json
file if you have. - run
$react-native upgrade
to generate/ios
and/android
folders again. - run
$react-native link
for any external dependency. - finally run
$react-native run-ios
or anything you want.
For iOS, the way to change xcodeproj settings is also available.
Show <your app name> -> Info.plist and add Bundle display name.
changing iOS app name:
I am probably a bit late, but for the people looking for a solid solution, there is a react-native-rename npm package which can do the magic.
You might also want to check out npm package (react-native-rename):
Usage:
react-native-rename < newName >
It works fine for my project.
As mentioned here (https://github.com/facebook/react-native/issues/4227), you don't need to add a Bundle display name
key, as said by @janus_wel.
You can simply update Bundle name
from $(PRODUCT_NAME)
to My App
.
- Update displayName in app.json to the new name
- Delete ios/ and android/ directories in root project
At command line Run:
react-native eject react-native link
You can use react-native-rename
npm package.
npm install react-native-rename
react-native-rename [newName]
https://www.npmjs.com/package/react-native-rename
- For IOS app, change in xcodeproj settings is also available.
Open Info.plist file from your project directory/ios/(appname) directory and change Bundle display name. CFBundleDisplayName NEW APP NAME
For android app, you can change in android folder of your project directory.
cd android/app/src/main/res/values/
open strings.xml file and change you app name in
<string name="app_name">NEW APP NAME</string>
Try to use react-native-rename library from npm. Works like a charm
- Update
displayName
inapp.json
file - Delete
android
andios
folders - Inside
index.js
changeAppRegistry.registerComponent('NEW_NAME_OF_APP', () => App);
- Run
react-native eject
to get theandroid
andios
folders back
First of all copy the address which your want to-be-name-changed application exists. And go to your newly cloned directory.
Replace the name at the index.ios/android.js file which is given as a parameter to AppRegistry.
update the name and version accordingly on package.json remove /ios and /android folders which are remaining from your older app and from the
run $react-native upgrade to generate /ios and /android folders again. and run $react-native link for any external dependency.
finally, run $react-native run-ios or else.
Comments
Post a Comment