如何更改“捆绑包标识符"(Bundle Identifier).在React Native中? [英] How to change the "Bundle Identifier" within React Native?
问题描述
启动一个新的react-native项目,xcode-project获得了捆绑包标识符"org.reactjs.native.example.XYZApp".XYZ是我真实项目名称的占位符.
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.
有什么方法可以在反应本地更改此捆绑包标识符吗?当然,我可以在XCode中更改它.但这是不安全的,因为当react-native重新创建xcode-project时,它可以被覆盖,这可以随时发生,并且在重建项目时也可以被覆盖.
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.
推荐答案
基于您使用的react-native版本,在两个平台(android和ios)上都必须更改一堆文件
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)
- [application_build_scheem] .plist(这是一个dict/xml文件,其中包含默认情况下未更改使用的键的键(react-native-cli项目的初始类型)
- [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)
机器人
- strings.xml(更改 app_name 键值)
- manifest.xml(更改 package 属性)
- build.gradle(更改 applicationId 值)
- MainActivity.java(更改Java类 package )
- MainApplication.java(更改Java类 package )
- strings.xml (change app_name key value)
- manifest.xml (change package attribute)
- build.gradle (change applicationId value)
- MainActivity.java (change java class package)
- MainApplication.java (change java class package)
值得一提的是,这里有一个npm模块( https://www.npmjs.com/package/react-native-ci-tools )来完成上述所有操作;使用它并使生活变得轻松.
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.
更新文件夹路径:
我们还需要更改文件夹路径以匹配新名称-将 com.oldName
更改为 com.newname.mobile
,然后从更改文件夹路径app/src/java/com/oldName/
到 app/src/java/com/newname/mobile/
.
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/
.
这篇关于如何更改“捆绑包标识符"(Bundle Identifier).在React Native中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!