Cli: init with --package option

Created on 13 Apr 2020  ·  19Comments  ·  Source: react-native-community/cli

First of all tool is great.
But react-native init has a option for packagename.
why npx react-native init getting --package option?
Thank you :)

feature request

Most helpful comment

I apologize for my rather harsh words, I should have elaborated more. I'm also sorry that I don't have enough free time to dig into the project to fix it myself.

Once published, the bundle ID cannot be changed. It's set for life. This means that the developers should take a moment to consider what it should be and not just take some auto-generated ID. The bundle IDs are traditionally recommended to be reverse-domain names – though it seems that Google & Apple have later removed this recommendation from their own documentation. In many cases you don't own the <projectname>.com domain (where the project name may even differ from the app name).

Based on these, I'd argue that the bundle ID should be a mandatory option, to force developers to take a moment to consider what a good bundle ID for them should be. Sure, keep an auto-generated option for Hello World projects, but at least provide an option to set it for those who care (which should be everyone planning to release the app).

Also, any rename tool is always playing catch-up with init. I was able to rename my bundle ID with it, but it missed one file – probably changed after the tool has been implemented/updated.

I completely understand if the maintainers don't have time to implement this, but closing this issue and asking everyone to use a separate somewhat-working tool (which isn't even mentioned in the documentation) to do the job is just ridiculous.

All 19 comments

Hey! Could you explain what do you expect from --package option?

for setting android app package name and ios
ex. stackoverflow

It is super necessary for Android apps.

I think it's only super necessary for you. There was close to zero interest in such request since a few years now. You can quickly find/replace the package name anyway.

@thymikee Is not a simple search/replace. You need to rename folders too. Is super annoying. BTW this feature was in CLI before and was removed.

I'm sorry, but I have no idea why it was removed (according to SO answer linked here, it was removed in RN 0.40+ and the CLI was extracted around RN 0.59, same time I started contributing), never used that. Maybe you could dig and find the rationale behind that?

I think it's only super necessary for you. There was close to zero interest in such request since a few years now. You can quickly find/replace the package name anyway.

There is a special tool react-native-rename for doing that, which has be downloaded 199k times for now.

I think it's a common requirement.

@arniu thanks, didn't know about this project! I feel we should embrace it and mention somewhere in the docs, what do you think?

@thymikee there is no need to mention a tool if you have it out of the box. Initializing projects with Android Studio have a step to input the package name, so I think this should be implemented in CLI, but maybe with another option (--packageName?). I'm free to contribute on this one if you want.

I still think it would be nice to give a shoutout to a tool that's helpful when one want to change it. @artyorsh Let's give it a shot then, hope it's not gonna add too much of maintenance burden.

@thymikee I think it's necessary to have it since it is officially supported by both IDEs when starting a new project. Also, since neither Android Studio nor Xcode has no package rename option, this shouldn't be included in CLI, but it's good to know there're community tools for that :)

Will try adding this option then 👍

BTW I did try to use react-native-rename and it didn't work. The last version is from one year ago.

React-native-rename sometimes didn't work. Please add this feature to CLI.

What is the status of this? I would imagine that this is a hard requirement for most people who release their apps, and it would be lovely to not have to resort to an external tool to do the renaming afterwards.

I think the status is we're closing it and your attention would be better used to make react-native-rename better :). We avoid reimplementing things.

Frankly it's ridiculous that there's even a need to have a separate react-native-rename tool because react-native init is missing such basic functionality. Every single production app will need to change the default package name to something proper. This is 101 app creation functionality: you choose an app name and an app bundle ID.

(Yes, there is the rare use-case where you need to later on change the package name and react-native-rename may be warranted then, but forcing every new init to use it is plain ridiculous.)

@plaa first of all, please stop being passive aggressive towards the project maintainers. Send a proposal if you're so certain this is a necessary feature. Code wins arguments :)

I disagree it's ridiculous to not have this functionality. The package name is created based on the required ProjectName argument and it works for the majority of use cases I suppose, never really bothered me as a user. I once needed a rename though.

Just wonder, if i only person who rename android package name each time i setup RN project?
Or other users never bother about it and upload apps to store with default com.ProjectName package name.

I apologize for my rather harsh words, I should have elaborated more. I'm also sorry that I don't have enough free time to dig into the project to fix it myself.

Once published, the bundle ID cannot be changed. It's set for life. This means that the developers should take a moment to consider what it should be and not just take some auto-generated ID. The bundle IDs are traditionally recommended to be reverse-domain names – though it seems that Google & Apple have later removed this recommendation from their own documentation. In many cases you don't own the <projectname>.com domain (where the project name may even differ from the app name).

Based on these, I'd argue that the bundle ID should be a mandatory option, to force developers to take a moment to consider what a good bundle ID for them should be. Sure, keep an auto-generated option for Hello World projects, but at least provide an option to set it for those who care (which should be everyone planning to release the app).

Also, any rename tool is always playing catch-up with init. I was able to rename my bundle ID with it, but it missed one file – probably changed after the tool has been implemented/updated.

I completely understand if the maintainers don't have time to implement this, but closing this issue and asking everyone to use a separate somewhat-working tool (which isn't even mentioned in the documentation) to do the job is just ridiculous.

Was this page helpful?
0 / 5 - 0 ratings