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

[GH-257] Android Application ID と iOS Bundle ID を別々にリネームできるようにする #258

Merged
merged 5 commits into from
Jun 17, 2024

Conversation

daichikuwa0618
Copy link
Member

@daichikuwa0618 daichikuwa0618 commented Jun 13, 2024

概要

resolve #257

設定をまとめたファイルを作ってパースさせる案もあったが、一回限りのスクリプトに割くには見合っていないということで最小限の変更で対応。
#203 の対応時にあらためて検討されたい。

レビュー観点

  • 実行後の変更箇所・変更内容に過不足がないか

レビューレベル

  • Lv1: ぱっとみて違和感がないかチェックして Approve する
  • Lv2: 仕様レベルまで理解して、仕様通りに動くかある程度検証して Approve する
  • Lv3: 実際に環境で動作確認したうえで Approve する

レビュー優先度

  • すぐに見てもらいたい ( hotfix など ) 🚀
  • 今日中に見てもらいたい 🚗
  • 今日〜明日中で見てもらいたい 🚶
  • 数日以内で見てもらいたい 🐢

確認したこと

  • 引数が 0, 1 のときはエラーが出ること
  • 修正前後のスクリプト実行後差分に差異がないこと (以下参照)
参考: 修正前の実行後
diff --git a/apps/app/android/app/src/main/kotlin/jp/co/yumemi/flutter_app/MainActivity.kt b/apps/app/android/app/src/main/kotlin/jp/co/yumemi/flutter_app/MainActivity.kt
deleted file mode 100644
index ccc7325..0000000
--- a/apps/app/android/app/src/main/kotlin/jp/co/yumemi/flutter_app/MainActivity.kt
+++ /dev/null
@@ -1,5 +0,0 @@
-package jp.co.yumemi.flutter_app
-
-import io.flutter.embedding.android.FlutterActivity
-
-class MainActivity: FlutterActivity()
diff --git a/apps/app/flavor/dev.json b/apps/app/flavor/dev.json
index 5ba9ec3..bf98f95 100644
--- a/apps/app/flavor/dev.json
+++ b/apps/app/flavor/dev.json
@@ -1,6 +1,6 @@
 {
     "flavor": "dev",
     "appName": "dev-Template",
-    "appId": "jp.co.yumemi.template",
+    "appId": "com.example.rename",
     "appIdSuffix": ".dev"
 }
diff --git a/apps/app/flavor/prd.json b/apps/app/flavor/prd.json
index c6dcb85..2929e00 100644
--- a/apps/app/flavor/prd.json
+++ b/apps/app/flavor/prd.json
@@ -1,6 +1,6 @@
 {
     "flavor": "prd",
     "appName": "Template",
-    "appId": "jp.co.yumemi.template",
+    "appId": "com.example.rename",
     "appIdSuffix": ""
 }
diff --git a/apps/app/flavor/stg.json b/apps/app/flavor/stg.json
index 0e7698c..d3722da 100644
--- a/apps/app/flavor/stg.json
+++ b/apps/app/flavor/stg.json
@@ -1,6 +1,6 @@
 {
     "flavor": "stg",
     "appName": "stg-Template",
-    "appId": "jp.co.yumemi.template",
+    "appId": "com.example.rename",
     "appIdSuffix": ".stg"
 }

修正後の実行後差分

cd tools
sh rename-application-id.sh com.example.android.rename com.example.ios.rename
diff --git a/apps/app/android/app/src/main/kotlin/jp/co/yumemi/flutter_app/MainActivity.kt b/apps/app/android/app/src/main/kotlin/jp/co/yumemi/flutter_app/MainActivity.kt
deleted file mode 100644
index ccc7325..0000000
--- a/apps/app/android/app/src/main/kotlin/jp/co/yumemi/flutter_app/MainActivity.kt
+++ /dev/null
@@ -1,5 +0,0 @@
-package jp.co.yumemi.flutter_app
-
-import io.flutter.embedding.android.FlutterActivity
-
-class MainActivity: FlutterActivity()
diff --git a/apps/app/flavor/dev.json b/apps/app/flavor/dev.json
index a1c7dae..42c02b6 100644
--- a/apps/app/flavor/dev.json
+++ b/apps/app/flavor/dev.json
@@ -1,7 +1,7 @@
 {
     "flavor": "dev",
     "appName": "dev-Template",
-    "appIdAndroid": "jp.co.yumemi.template",
-    "appIdIos": "jp.co.yumemi.template",
+    "appIdAndroid": "com.example.android.rename",
+    "appIdIos": "com.example.ios.rename",
     "appIdSuffix": ".dev"
 }
diff --git a/apps/app/flavor/prd.json b/apps/app/flavor/prd.json
index 189021c..3d18465 100644
--- a/apps/app/flavor/prd.json
+++ b/apps/app/flavor/prd.json
@@ -1,7 +1,7 @@
 {
     "flavor": "prd",
     "appName": "Template",
-    "appIdAndroid": "jp.co.yumemi.template",
-    "appIdIos": "jp.co.yumemi.template",
+    "appIdAndroid": "com.example.android.rename",
+    "appIdIos": "com.example.ios.rename",
     "appIdSuffix": ""
 }
diff --git a/apps/app/flavor/stg.json b/apps/app/flavor/stg.json
index 00f0eea..d4a2a7c 100644
--- a/apps/app/flavor/stg.json
+++ b/apps/app/flavor/stg.json
@@ -1,7 +1,7 @@
 {
     "flavor": "stg",
     "appName": "stg-Template",
-    "appIdAndroid": "jp.co.yumemi.template",
-    "appIdIos": "jp.co.yumemi.template",
+    "appIdAndroid": "com.example.android.rename",
+    "appIdIos": "com.example.ios.rename",
     "appIdSuffix": ".stg"
 }

動作確認手順

cd tools
sh rename-application-id.sh com.example.android.rename com.example.ios.rename

備考

@github-actions github-actions bot added the @apps/app Application development label Jun 13, 2024
@yumemi-team-review-requester yumemi-team-review-requester bot requested review from a team, Aosanori and morikann and removed request for a team June 13, 2024 07:07
Copy link

Ready for review 🚀

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

差分も確認いただきたいですが、 https://github.com/yumemi-inc/flutter-mobile-project-template/blob/feature/GH-257/.github/initialization/RENAME_APPLICATION_ID.md で完成後のドキュメントが問題ないかも見ていただきたいです。

Comment on lines -4 to +5
"appId": "jp.co.yumemi.template",
"appIdAndroid": "jp.co.yumemi.template",
"appIdIos": "jp.co.yumemi.template",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ios はかなり気持ち悪いが、、、、

  • androidAppId / iosAppId はアルファベット順で並べたときに離れてしまう
  • lower camel case 遵守

ということでこの命名を採用してます。

Comment on lines -19 to -20
readonly NEW_APPLICATION_ID=$1
readonly OLD_APPLICATION_ID="jp.co.yumemi.template"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

削除した 2 変数が使われてないことは grep で確認済み

Comment on lines -19 to -20
```bash
bash rename-application-id.sh "com.example.rename"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macOS のデフォルトは zsh だし、シェルスクリプトのシバンも /bin/sh なので bash に限定しなくてもいいかなと。

Copy link
Contributor

@K9i-0 K9i-0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修正に関してはLGTM
既存がおかしいのでSlackにコメントしました
https://yumemi.slack.com/archives/C0585H2BG9L/p1718275216573499

@daichikuwa0618
Copy link
Member Author

@K9i-0 さんに Slack にて指摘してもらった点:

  1. 既存の Doc の日本語がおかしい部分がある
  2. jp 始まりの ID に replace しようとすると新しい MainActivity.kt も削除されてしまう
    • path の全てに一致させないで、 jp 配下すべて削除していたため

でした。

1 については bf4d290 に混ぜて修正しました (分けると良くわからないまとまりになりそうだったので)。
2 については 0f63f12 にて修正しました。Step 3 と 4 を入れ替えて、先に削除 → 追加という手順に変更しています。
動作確認として、 jp 始まりの ID に replace したときの before / after の diff です。

diff before
diff --git a/apps/app/android/app/src/main/kotlin/jp/co/yumemi/flutter_app/MainActivity.kt b/apps/app/android/app/src/main/kotlin/jp/co/yumemi/flutter_app/MainActivity.kt
deleted file mode 100644
index ccc7325..0000000
--- a/apps/app/android/app/src/main/kotlin/jp/co/yumemi/flutter_app/MainActivity.kt
+++ /dev/null
@@ -1,5 +0,0 @@
-package jp.co.yumemi.flutter_app
-
-import io.flutter.embedding.android.FlutterActivity
-
-class MainActivity: FlutterActivity()
diff --git a/apps/app/flavor/dev.json b/apps/app/flavor/dev.json
index 5ba9ec3..6b06e89 100644
--- a/apps/app/flavor/dev.json
+++ b/apps/app/flavor/dev.json
@@ -1,6 +1,6 @@
 {
     "flavor": "dev",
     "appName": "dev-Template",
-    "appId": "jp.co.yumemi.template",
+    "appId": "jp.example.replaced",
     "appIdSuffix": ".dev"
 }
diff --git a/apps/app/flavor/prd.json b/apps/app/flavor/prd.json
index c6dcb85..6b0ff02 100644
--- a/apps/app/flavor/prd.json
+++ b/apps/app/flavor/prd.json
@@ -1,6 +1,6 @@
 {
     "flavor": "prd",
     "appName": "Template",
-    "appId": "jp.co.yumemi.template",
+    "appId": "jp.example.replaced",
     "appIdSuffix": ""
 }
diff --git a/apps/app/flavor/stg.json b/apps/app/flavor/stg.json
index 0e7698c..857f27b 100644
--- a/apps/app/flavor/stg.json
+++ b/apps/app/flavor/stg.json
@@ -1,6 +1,6 @@
 {
     "flavor": "stg",
     "appName": "stg-Template",
-    "appId": "jp.co.yumemi.template",
+    "appId": "jp.example.replaced",
     "appIdSuffix": ".stg"
 }
diff after
diff --git a/apps/app/android/app/src/main/kotlin/jp/co/yumemi/flutter_app/MainActivity.kt b/apps/app/android/app/src/main/kotlin/jp/co/yumemi/flutter_app/MainActivity.kt
deleted file mode 100644
index ccc7325..0000000
--- a/apps/app/android/app/src/main/kotlin/jp/co/yumemi/flutter_app/MainActivity.kt
+++ /dev/null
@@ -1,5 +0,0 @@
-package jp.co.yumemi.flutter_app
-
-import io.flutter.embedding.android.FlutterActivity
-
-class MainActivity: FlutterActivity()
diff --git a/apps/app/android/app/src/main/kotlin/jp/example/and/MainActivity.kt b/apps/app/android/app/src/main/kotlin/jp/example/and/MainActivity.kt
index e69de29..a719307 100644
--- a/apps/app/android/app/src/main/kotlin/jp/example/and/MainActivity.kt
+++ b/apps/app/android/app/src/main/kotlin/jp/example/and/MainActivity.kt
@@ -0,0 +1,5 @@
+package jp.example.and
+
+import io.flutter.embedding.android.FlutterActivity
+
+class MainActivity: FlutterActivity()
diff --git a/apps/app/flavor/dev.json b/apps/app/flavor/dev.json
index a1c7dae..c87ba18 100644
--- a/apps/app/flavor/dev.json
+++ b/apps/app/flavor/dev.json
@@ -1,7 +1,7 @@
 {
     "flavor": "dev",
     "appName": "dev-Template",
-    "appIdAndroid": "jp.co.yumemi.template",
-    "appIdIos": "jp.co.yumemi.template",
+    "appIdAndroid": "jp.example.and",
+    "appIdIos": "jp.example.ios",
     "appIdSuffix": ".dev"
 }
diff --git a/apps/app/flavor/prd.json b/apps/app/flavor/prd.json
index 189021c..0809680 100644
--- a/apps/app/flavor/prd.json
+++ b/apps/app/flavor/prd.json
@@ -1,7 +1,7 @@
 {
     "flavor": "prd",
     "appName": "Template",
-    "appIdAndroid": "jp.co.yumemi.template",
-    "appIdIos": "jp.co.yumemi.template",
+    "appIdAndroid": "jp.example.and",
+    "appIdIos": "jp.example.ios",
     "appIdSuffix": ""
 }
diff --git a/apps/app/flavor/stg.json b/apps/app/flavor/stg.json
index 00f0eea..b0743a9 100644
--- a/apps/app/flavor/stg.json
+++ b/apps/app/flavor/stg.json
@@ -1,7 +1,7 @@
 {
     "flavor": "stg",
     "appName": "stg-Template",
-    "appIdAndroid": "jp.co.yumemi.template",
-    "appIdIos": "jp.co.yumemi.template",
+    "appIdAndroid": "jp.example.and",
+    "appIdIos": "jp.example.ios",
     "appIdSuffix": ".stg"
 }

Copy link
Contributor

@K9i-0 K9i-0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

PRと関係ない修正までありがとうございます 🙇

@K9i-0 K9i-0 merged commit 5e56257 into main Jun 17, 2024
9 checks passed
@K9i-0 K9i-0 deleted the feature/GH-257 branch June 17, 2024 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@apps/app Application development
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improve]: Android / iOS で Application ID / Bundle ID を別々に設定できるようにしてはどうか
2 participants