Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init with --package option #1111

Closed
OkancanCosar opened this issue Apr 13, 2020 · 27 comments
Closed

init with --package option #1111

OkancanCosar opened this issue Apr 13, 2020 · 27 comments

Comments

@OkancanCosar
Copy link

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 :)

@thymikee
Copy link
Member

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

@OkancanCosar
Copy link
Author

for setting android app package name and ios
ex. stackoverflow

@victorwpbastos
Copy link
Contributor

It is super necessary for Android apps.

@thymikee
Copy link
Member

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.

@victorwpbastos
Copy link
Contributor

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

@thymikee
Copy link
Member

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?

@arniu
Copy link

arniu commented Apr 28, 2020

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.

@thymikee
Copy link
Member

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

@artyorsh
Copy link

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

@thymikee
Copy link
Member

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.

@artyorsh
Copy link

@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 👍

@victorwpbastos
Copy link
Contributor

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

@deniskk12
Copy link

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

@stephan-nordnes-eriksen
Copy link

stephan-nordnes-eriksen commented Feb 2, 2021

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.

@thymikee
Copy link
Member

thymikee commented Feb 2, 2021

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.

@thymikee thymikee closed this as completed Feb 2, 2021
@plaa
Copy link

plaa commented Mar 16, 2021

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

@thymikee
Copy link
Member

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

@deniskk12
Copy link

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.

@plaa
Copy link

plaa commented Mar 16, 2021

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.

@Adnan-Bacic
Copy link

when creating a project through xcode and android studio, they both assume com.domain.appName syntax. while the react-native init uses a com.appName syntax. i believe on android this must be unique between every app published to play store, and i could imagine the same for ios.

i just tried, and the react-native cli doesnt support the dot(.) when creating a project. which means EVERY single react native project must use react-native-rename, if they want to change package name/applicationId/bundle identifier.

and anyone who doesnt know this can never change it after deploying.

and many others also report problems with react-native-rename. i can also still find references to the old name after renaming.

it would be very nice if we could just have this sorted out at the creation of the project, and not something you feel like you always have to do after creating the project.

@damusix
Copy link

damusix commented Jun 20, 2022

Can this be reopened? I have a case with a series of incoming white-label apps that need to be prefixed with a com.COMPANY.PROJECT ... Is there a way to do this without some community package that doesn't work?

@tinymobile
Copy link

The quickest way I did it was to open the project folder in my editor. Then, do a project wide search and replace from the default package name e.g. "com.newapp" - and replace with whatever package name you want e.g. "com.company.project".

That finds and replaces about 15 occurrences of the default package name to the required package name across a number of files.

Then, you have to rename the folder structure from project/android/app/src/main/java/com/newapp to match your new package name. e.g. project/android/app/src/main/java/com/company/project

(making sure you keep all the files in the bottom folder of that file structure)

Then, it works. But would be a million times easier if react-native init could just have a --package option.

@rosenpin

This comment was marked as abuse.

@billnbell
Copy link

Yeah com.companyname.appname - it should make the directories... java/com/companyname/appname

@felipermfalcao
Copy link

I can't believe you have to do this by hand! OMG!!!!

@fawaz-ahmed
Copy link

This is how to do it:

npx react-native@latest init GlowCalculator --package-name com.codebusterspro.glowcalculator --title "Glow calculator"

@youwhoyou
Copy link

This is how to do it:

npx react-native@latest init GlowCalculator --package-name com.codebusterspro.glowcalculator --title "Glow calculator"

this is the best answer here. Im not sure why they dont add this information into the getting started documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests