Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
299 views
in Technique[技术] by (71.8m points)

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

Starting a new react-native project, the xcode-project gots the bundle-identifier "org.reactjs.native.example.XYZApp". XYZ is the placeholder here for my real project name.

Is there any way to change this bundle identifier on react-native side? Sure, I can change it in XCode. But this is not safe because it can be overriden when react-native will recreate the xcode-project, which could happen at any time, as well es when rebuilding the project.

question from:https://stackoverflow.com/questions/36119754/how-to-change-the-bundle-identifier-within-react-native

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...