How to change the "Bundle Identifier" within React Native? How to change the "Bundle Identifier" within React Native? xcode xcode

How to change the "Bundle Identifier" within React Native?


Based on the react-native version you are using there are bunch of files that have to be changed on both platforms (android and ios)

List of files to edit:

IOS

  1. [application_build_scheem].plist (this is a dict/xml file that contains keys that are used by default if no changes added to project (react-native-cli init type of project)

ANDROID

  1. strings.xml (change app_name key value)
  2. manifest.xml (change package attribute)
  3. build.gradle (change applicationId value)
  4. MainActivity.java (change java class package)
  5. MainApplication.java (change java class package)

It's worth mentioning that there is an an npm module (https://www.npmjs.com/package/react-native-ci-tools) that does all of the above; use it and make life easy.

Update (6/Mar/2019)

Update Folder Paths:

We also need to change the folder paths to match new name -- change com.oldName to com.newname.mobile, then change folder paths from app/src/java/com/oldName/ to app/src/java/com/newname/mobile/.


For those who want a simple way to do exactly this I create react-native-app-id, It'll basically edit the files mentioned. react-native-ci-tools actually forked my code to produce a now outdated react-native-app-id-fixed , which won't work with the latest react native. Mine however will..

https://github.com/kyle-ssg/react-native-app-id

usage is as easy as react-native-app-id com.foo.bar


To update iOS bundle id -

  • From terminal or command prompt navigate to react-native project folder and then go inside iOS folder.
  • enter command Open ProjectName.xcodeproj

This command will open the project in Xcode where you need to update bundle identifier information of the app

To update android package name follow below steps -

  • Update folder structure inside “android/app/src/main/java/” folderbased on your new package name e.g "com/companyName/appName"
  • Update package name inside MainActivity.java file
  • Update package name inside MainApplication.java file
  • Update package name inside /android/app/src/main/AndroidManifest.xmlfile
  • Update package name inside /android/app/BUCK file
  • Update package name inside /android/app/build.gradle file