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 to AppRegistry.
  • Change the name and version accordingly on package.json
  • delete /ios and /android folders which are remaining from your older app as well as the app.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.

  1. Update displayName in app.json to the new name
  2. Delete ios/ and android/ directories in root project
  3. 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

  1. 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

  1. 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 in app.json file
  • Delete android and ios folders
  • Inside index.js change AppRegistry.registerComponent('NEW_NAME_OF_APP', () => App);
  • Run react-native eject to get the android and ios 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

Popular posts from this blog

Meaning of `{}` for return expression

Get current scroll position of ScrollView in React Native

Chart JS +ng2-charts not working on Angular+2