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

Ability to change the app name #123

Closed
chernodub opened this issue Nov 16, 2022 · 7 comments
Closed

Ability to change the app name #123

chernodub opened this issue Nov 16, 2022 · 7 comments

Comments

@chernodub
Copy link
Contributor

Would be amazing if we could also set the application name in config.yml file

@chernodub
Copy link
Contributor Author

chernodub commented Nov 16, 2022

Currently, we're using this tooling along with Capacitor for configuring the apps for different environments. It feels that the feature would be very useful for this scenario.

p.s: I understand that for Capacitor, the app name is configured via capacitor.config.ts, and maybe this lies a bit outside of the trapeze scope. I would really appreciate it if you guys could share your perspective on that. Thanks! :)

@chernodub chernodub changed the title Change app name Ability to change the app name Nov 16, 2022
@chernodub
Copy link
Contributor Author

chernodub commented Nov 16, 2022

I figured that it is also achievable by replacing the native resource files directly:

vars:
  BUNDLE_ID:
    default: com.example.app
  PACKAGE_NAME:
    default: $BUNDLE_ID
+ APP_NAME:
+   default: test-app-name

platforms:
  ios:
    targets:
      App:
        bundleId: $BUNDLE_ID
+       plist:
+         - replace: true
+           entries:
+             - CFBundleDisplayName:
+                 $APP_NAME

  android:
      packageName: $BUNDLE_ID
+     xml:
+     - resFile: values/strings.xml
+       target: resources/string[@name="app_name"]
+       replace: |
+         <string name="app_name">$APP_NAME</string>
+     - resFile: values/strings.xml
+       target: resources/string[@name="title_activity_main"]
+       replace: |
+         <string name="title_activity_main">$APP_NAME</string>

But, probably, it would make sense to make it more human-readable by having some convenient property. Something like the following:

vars:
  BUNDLE_ID:
    default: com.example.app
  PACKAGE_NAME:
    default: $BUNDLE_ID
+ APP_NAME:
+   default: test-app-name

platforms:
  ios:
    targets:
      App:
        bundleId: $BUNDLE_ID
+       appName: $APP_NAME

  android:
      packageName: $BUNDLE_ID
+     appName: $APP_NAME

@mlynch
Copy link
Contributor

mlynch commented Nov 16, 2022

For iOS there's displayName https://trapeze.dev/docs/configuration-tool#displayname this sets CFBundleDisplayName

However, for Android there's nothing built in but I think I can pretty easily add something that reads the <application android:label field and then resolves the right file or strings entry to modify. It's just a little more complicated

@mlynch
Copy link
Contributor

mlynch commented Nov 16, 2022

Added android support in 6.0.3. Having issues building the docs at the moment but you can use the new appName command:

android:
  appName: My App Name

@mlynch mlynch closed this as completed Nov 16, 2022
@mlynch
Copy link
Contributor

mlynch commented Nov 16, 2022

https://trapeze.dev/docs/configuration-tool#appname

@chernodub
Copy link
Contributor Author

Thank you @mlynch 🙏

@trinitiwowka
Copy link

@mlynch Hi! Can you help me please? I have a problem.

My application name consists only of numbers, I get a runtimeError when i build & run ios
I get
CFBundleDisplayName 1999

but need
CFBundleDisplayName 1999

image

When $APP_NAME = '1999'

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

No branches or pull requests

3 participants