From 5264c1f222123867535bbeb39fdfffd5c281fe34 Mon Sep 17 00:00:00 2001 From: Feodor Fitsner Date: Sun, 9 Feb 2025 15:02:03 -0800 Subject: [PATCH] Introduce bundle_id and project_name --- cookiecutter.json | 7 ++++--- .../android/app/build.gradle | 2 +- .../MainActivity.kt | 2 +- .../ios/Runner.xcodeproj/project.pbxproj | 21 ++++++------------- {{cookiecutter.out_dir}}/linux/CMakeLists.txt | 2 +- .../macos/Runner.xcodeproj/project.pbxproj | 6 +++--- .../macos/Runner/Configs/AppInfo.xcconfig | 2 +- 7 files changed, 17 insertions(+), 25 deletions(-) diff --git a/cookiecutter.json b/cookiecutter.json index c8698eb..5dbdf02 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -5,14 +5,15 @@ "project_name_slug": "", "project_description": "", "product_name": "{{ cookiecutter.project_name }}", - "org_name": "com.flet", + "org_name": "{{ cookiecutter.org_name if cookiecutter.org_name else cookiecutter.bundle_id.rsplit('.', 1)[0] if cookiecutter.bundle_id else 'com.flet' }}", "company_name": "Your Company", "copyright": "Copyright (c) 2023 Your Company", "flutter": null, "sep": "/", - "kotlin_dir": "{{ cookiecutter.org_name.replace('.', cookiecutter.sep) }}{{ cookiecutter.sep }}{{ cookiecutter.project_name }}{{ cookiecutter.sep }}", "hide_loading_animation": true, - "team_id": "", + "bundle_id": "{{ cookiecutter.bundle_id if cookiecutter.bundle_id else cookiecutter.org_name + '.' + cookiecutter.project_name }}", + "package_name": "{{ cookiecutter.bundle_id.rsplit('.', 1)[-1].replace('-', '_') if cookiecutter.bundle_id else cookiecutter.project_name }}", + "kotlin_dir": "{{ cookiecutter.org_name.replace('.', cookiecutter.sep) }}{{ cookiecutter.sep }}{{ cookiecutter.package_name }}{{ cookiecutter.sep }}", "base_url": "/", "route_url_strategy": "path", "web_renderer": "canvaskit", diff --git a/{{cookiecutter.out_dir}}/android/app/build.gradle b/{{cookiecutter.out_dir}}/android/app/build.gradle index 9203e8e..7ac30b3 100644 --- a/{{cookiecutter.out_dir}}/android/app/build.gradle +++ b/{{cookiecutter.out_dir}}/android/app/build.gradle @@ -50,7 +50,7 @@ android { } defaultConfig { - applicationId "{{ cookiecutter.org_name }}.{{ cookiecutter.project_name }}" + applicationId "{{ cookiecutter.bundle_id }}" minSdkVersion flutter.minSdkVersion targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() diff --git a/{{cookiecutter.out_dir}}/android/app/src/main/kotlin/{{ cookiecutter.kotlin_dir }}/MainActivity.kt b/{{cookiecutter.out_dir}}/android/app/src/main/kotlin/{{ cookiecutter.kotlin_dir }}/MainActivity.kt index 475f684..aa1cf92 100644 --- a/{{cookiecutter.out_dir}}/android/app/src/main/kotlin/{{ cookiecutter.kotlin_dir }}/MainActivity.kt +++ b/{{cookiecutter.out_dir}}/android/app/src/main/kotlin/{{ cookiecutter.kotlin_dir }}/MainActivity.kt @@ -1,4 +1,4 @@ -package {{ cookiecutter.org_name }}.{{ cookiecutter.project_name }} +package {{ cookiecutter.org_name }}.{{ cookiecutter.package_name }} import io.flutter.embedding.android.FlutterActivity diff --git a/{{cookiecutter.out_dir}}/ios/Runner.xcodeproj/project.pbxproj b/{{cookiecutter.out_dir}}/ios/Runner.xcodeproj/project.pbxproj index 8ff0a98..f7b9ef9 100644 --- a/{{cookiecutter.out_dir}}/ios/Runner.xcodeproj/project.pbxproj +++ b/{{cookiecutter.out_dir}}/ios/Runner.xcodeproj/project.pbxproj @@ -362,9 +362,6 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; -{% if cookiecutter.team_id %} - DEVELOPMENT_TEAM = "{{ cookiecutter.team_id }}"; -{% endif %} {% if cookiecutter.provisioning_profile %} PROVISIONING_PROFILE_SPECIFIER = "{{ cookiecutter.provisioning_profile }}"; {% endif %} @@ -374,7 +371,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = {{ cookiecutter.org_name }}.{{ cookiecutter.project_name_slug }}; + PRODUCT_BUNDLE_IDENTIFIER = {{ cookiecutter.bundle_id }}; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; @@ -391,7 +388,7 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = {{ cookiecutter.org_name }}.{{ cookiecutter.project_name_slug }}.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = {{ cookiecutter.bundle_id }}.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -409,7 +406,7 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = {{ cookiecutter.org_name }}.{{ cookiecutter.project_name_slug }}.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = {{ cookiecutter.bundle_id }}.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; @@ -425,7 +422,7 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = {{ cookiecutter.org_name }}.{{ cookiecutter.project_name_slug }}.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = {{ cookiecutter.bundle_id }}.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; @@ -547,9 +544,6 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; -{% if cookiecutter.team_id %} - DEVELOPMENT_TEAM = "{{ cookiecutter.team_id }}"; -{% endif %} {% if cookiecutter.provisioning_profile %} PROVISIONING_PROFILE_SPECIFIER = "{{ cookiecutter.provisioning_profile }}"; {% endif %} @@ -559,7 +553,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = {{ cookiecutter.org_name }}.{{ cookiecutter.project_name_slug }}; + PRODUCT_BUNDLE_IDENTIFIER = {{ cookiecutter.bundle_id }}; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -576,9 +570,6 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; -{% if cookiecutter.team_id %} - DEVELOPMENT_TEAM = "{{ cookiecutter.team_id }}"; -{% endif %} {% if cookiecutter.provisioning_profile %} PROVISIONING_PROFILE_SPECIFIER = "{{ cookiecutter.provisioning_profile }}"; {% endif %} @@ -588,7 +579,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = {{ cookiecutter.org_name }}.{{ cookiecutter.project_name_slug }}; + PRODUCT_BUNDLE_IDENTIFIER = {{ cookiecutter.bundle_id }}; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; diff --git a/{{cookiecutter.out_dir}}/linux/CMakeLists.txt b/{{cookiecutter.out_dir}}/linux/CMakeLists.txt index 1bc35a9..7fd9a43 100644 --- a/{{cookiecutter.out_dir}}/linux/CMakeLists.txt +++ b/{{cookiecutter.out_dir}}/linux/CMakeLists.txt @@ -7,7 +7,7 @@ project(runner LANGUAGES CXX) set(BINARY_NAME "{{ cookiecutter.project_name }}") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID -set(APPLICATION_ID "{{ cookiecutter.org_name }}.{{ cookiecutter.project_name }}") +set(APPLICATION_ID "{{ cookiecutter.bundle_id }}") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. diff --git a/{{cookiecutter.out_dir}}/macos/Runner.xcodeproj/project.pbxproj b/{{cookiecutter.out_dir}}/macos/Runner.xcodeproj/project.pbxproj index 45c4d7f..a044226 100644 --- a/{{cookiecutter.out_dir}}/macos/Runner.xcodeproj/project.pbxproj +++ b/{{cookiecutter.out_dir}}/macos/Runner.xcodeproj/project.pbxproj @@ -384,7 +384,7 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = {{ cookiecutter.org_name }}.{{ cookiecutter.project_name_slug }}.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = {{ cookiecutter.bundle_id }}.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/{{ cookiecutter.project_name }}.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/{{ cookiecutter.project_name }}"; @@ -398,7 +398,7 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = {{ cookiecutter.org_name }}.{{ cookiecutter.project_name_slug }}.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = {{ cookiecutter.bundle_id }}.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/{{ cookiecutter.project_name }}.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/{{ cookiecutter.project_name }}"; @@ -412,7 +412,7 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = {{ cookiecutter.org_name }}.{{ cookiecutter.project_name_slug }}.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = {{ cookiecutter.bundle_id }}.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/{{ cookiecutter.project_name }}.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/{{ cookiecutter.project_name }}"; diff --git a/{{cookiecutter.out_dir}}/macos/Runner/Configs/AppInfo.xcconfig b/{{cookiecutter.out_dir}}/macos/Runner/Configs/AppInfo.xcconfig index e90e552..673a8f3 100644 --- a/{{cookiecutter.out_dir}}/macos/Runner/Configs/AppInfo.xcconfig +++ b/{{cookiecutter.out_dir}}/macos/Runner/Configs/AppInfo.xcconfig @@ -8,7 +8,7 @@ PRODUCT_NAME = {{ cookiecutter.product_name }} // The application's bundle identifier -PRODUCT_BUNDLE_IDENTIFIER = {{ cookiecutter.org_name }}.{{ cookiecutter.project_name_slug }} +PRODUCT_BUNDLE_IDENTIFIER = {{ cookiecutter.bundle_id }} // The copyright displayed in application information PRODUCT_COPYRIGHT = {{ cookiecutter.copyright }}. All rights reserved.