Pārlūkot izejas kodu

chore(deps): update cargo-mobile2 to 0.15 (#10788)

* chore(deps): update cargo-mobile2 to 0.15

* fix ios build [skip ci]

* lock file

---------

Co-authored-by: Lucas Nogueira <lucas@tauri.app>
Amr Bashir 11 mēneši atpakaļ
vecāks
revīzija
72597a77f9

+ 2 - 2
tooling/cli/Cargo.lock

@@ -557,9 +557,9 @@ dependencies = [
 
 [[package]]
 name = "cargo-mobile2"
-version = "0.14.0"
+version = "0.15.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b37140c84631f1a416fff6a3f898db7bda1a2643335fdf14e3d5eb5af61bf2e3"
+checksum = "3b1baf430f92ddf6e492c9186e4e97dc3051366345b8aa7ffdc0e0f952c9a35b"
 dependencies = [
  "colored",
  "core-foundation 0.10.0",

+ 1 - 1
tooling/cli/Cargo.toml

@@ -39,7 +39,7 @@ name = "cargo-tauri"
 path = "src/main.rs"
 
 [dependencies]
-cargo-mobile2 = { version = "0.14", default-features = false }
+cargo-mobile2 = { version = "0.15", default-features = false }
 jsonrpsee = { version = "0.24", features = ["server"] }
 jsonrpsee-core = "0.24"
 jsonrpsee-client-transport = { version = "0.24", features = ["ws"] }

+ 4 - 4
tooling/cli/src/mobile/android/mod.rs

@@ -142,10 +142,10 @@ pub fn get_config(
   set_var("WRY_ANDROID_LIBRARY", app.lib_name());
   set_var("TAURI_ANDROID_PROJECT_PATH", config.project_dir());
 
-  let src_main_dir = config.project_dir().join("app/src/main").join(format!(
-    "java/{}",
-    app.reverse_identifier().replace('.', "/"),
-  ));
+  let src_main_dir = config
+    .project_dir()
+    .join("app/src/main")
+    .join(format!("java/{}", app.identifier().replace('.', "/"),));
   if config.project_dir().exists() {
     if src_main_dir.exists() {
       let _ = create_dir(src_main_dir.join("generated"));

+ 1 - 1
tooling/cli/src/mobile/android/project.rs

@@ -109,7 +109,7 @@ pub fn gen(
   );
   map.insert("windows", cfg!(windows));
 
-  let identifier = config.app().reverse_identifier().replace('.', "/");
+  let identifier = config.app().identifier().replace('.', "/");
   let package_path = format!("java/{}", identifier);
 
   map.insert("package-path", &package_path);

+ 0 - 30
tooling/cli/src/mobile/init.rs

@@ -175,11 +175,6 @@ fn handlebars(app: &App) -> (Handlebars<'static>, JsonMap) {
     Box::new(quote_and_join_colon_prefix),
   );
   h.register_helper("snake-case", Box::new(snake_case));
-  h.register_helper("reverse-domain", Box::new(reverse_domain));
-  h.register_helper(
-    "reverse-domain-snake-case",
-    Box::new(reverse_domain_snake_case),
-  );
   h.register_helper("escape-kotlin-keyword", Box::new(escape_kotlin_keyword));
   // don't mix these up or very bad things will happen to all of us
   h.register_helper("prefix-path", Box::new(prefix_path));
@@ -301,31 +296,6 @@ fn snake_case(
     .map_err(Into::into)
 }
 
-fn reverse_domain(
-  helper: &Helper,
-  _: &Handlebars,
-  _: &Context,
-  _: &mut RenderContext,
-  out: &mut dyn Output,
-) -> HelperResult {
-  out
-    .write(&util::reverse_domain(get_str(helper)))
-    .map_err(Into::into)
-}
-
-fn reverse_domain_snake_case(
-  helper: &Helper,
-  _: &Handlebars,
-  _: &Context,
-  _: &mut RenderContext,
-  out: &mut dyn Output,
-) -> HelperResult {
-  use heck::ToSnekCase as _;
-  out
-    .write(&util::reverse_domain(get_str(helper)).to_snek_case())
-    .map_err(Into::into)
-}
-
 fn escape_kotlin_keyword(
   helper: &Helper,
   _: &Handlebars,

+ 1 - 1
tooling/cli/src/mobile/ios/mod.rs

@@ -536,7 +536,7 @@ pub fn synchronize_project_config(
       });
     if let Some(profile_uuid) = profile_uuid {
       let mut provisioning_profiles = plist::Dictionary::new();
-      provisioning_profiles.insert(app.reverse_identifier(), profile_uuid.into());
+      provisioning_profiles.insert(app.identifier().to_string(), profile_uuid.into());
       export_options_list.insert(
         "provisioningProfiles".to_string(),
         provisioning_profiles.into(),

+ 2 - 8
tooling/cli/src/mobile/mod.rs

@@ -249,16 +249,10 @@ fn read_options(identifier: &str) -> CliOptions {
 }
 
 pub fn get_app(target: Target, config: &TauriConfig, interface: &AppInterface) -> App {
-  let identifier = config
-    .identifier
-    .rsplit('.')
-    .collect::<Vec<&str>>()
-    .join(".");
-
   let identifier = match target {
-    Target::Android => identifier.replace('-', "_"),
+    Target::Android => config.identifier.replace('-', "_"),
     #[cfg(target_os = "macos")]
-    Target::Ios => identifier.replace('_', "-"),
+    Target::Ios => config.identifier.replace('_', "-"),
   };
 
   if identifier.is_empty() {

+ 2 - 2
tooling/cli/templates/mobile/android/app/build.gradle.kts

@@ -17,10 +17,10 @@ val tauriProperties = Properties().apply {
 
 android {
     compileSdk = 34
-    namespace = "{{reverse-domain app.identifier}}"
+    namespace = "{{app.identifier}}"
     defaultConfig {
         manifestPlaceholders["usesCleartextTraffic"] = "false"
-        applicationId = "{{reverse-domain app.identifier}}"
+        applicationId = "{{app.identifier}}"
         minSdk = {{android.min-sdk-version}}
         versionCode = tauriProperties.getProperty("tauri.android.versionCode", "1").toInt()
         versionName = tauriProperties.getProperty("tauri.android.versionName", "1.0")

+ 1 - 1
tooling/cli/templates/mobile/android/app/src/main/MainActivity.kt

@@ -1,3 +1,3 @@
-package {{escape-kotlin-keyword (reverse-domain app.identifier)}}
+package {{escape-kotlin-keyword app.identifier}}
 
 class MainActivity : TauriActivity()

+ 2 - 2
tooling/cli/templates/mobile/ios/project.yml

@@ -1,6 +1,6 @@
 name: {{app.name}}
 options:
-  bundleIdPrefix: {{reverse-domain app.identifier}}
+  bundleIdPrefix: {{app.identifier}}
   deploymentTarget:
     iOS: {{apple.ios-version}}
 fileGroups: [{{join file-groups}}]
@@ -11,7 +11,7 @@ settingGroups:
   app:
     base:
       PRODUCT_NAME: {{app.stylized-name}}
-      PRODUCT_BUNDLE_IDENTIFIER: {{reverse-domain app.identifier}}
+      PRODUCT_BUNDLE_IDENTIFIER: {{app.identifier}}
       {{#if apple.development-team}}
       DEVELOPMENT_TEAM: {{apple.development-team}}
       {{/if}}