Browse Source

feat(cli): enhance iOS build task arguments (#4987)

Lucas Fernandes Nogueira 3 years ago
parent
commit
e55d96acc1

+ 6 - 6
tooling/cli/src/mobile/init.rs

@@ -134,9 +134,6 @@ pub fn exec(
   map.insert("tauri-binary", tauri_binary.to_string_lossy());
   let mut build_args = Vec::new();
   for arg in args {
-    if arg == "android" {
-      break;
-    }
     let path = PathBuf::from(&arg);
     if path.exists() {
       if let Ok(dir) = current_dir() {
@@ -146,10 +143,13 @@ pub fn exec(
       }
     }
     build_args.push(arg.to_string_lossy().into_owned());
+    if arg == "android" || arg == "ios" {
+      break;
+    }
   }
-  build_args.push("android".into());
-  build_args.push("build".into());
-  map.insert("tauri-binary-args", build_args);
+  build_args.push(target.ide_build_script_name().into());
+  map.insert("tauri-binary-args", &build_args);
+  map.insert("tauri-binary-args-str", build_args.join(" "));
 
   // Generate Android Studio project
   let android_env = if target == Target::Android {

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

@@ -78,6 +78,14 @@ impl Target {
       Self::Ios => "ios",
     }
   }
+
+  fn ide_build_script_name(&self) -> &'static str {
+    match self {
+      Self::Android => "build",
+      #[cfg(target_os = "macos")]
+      Self::Ios => "xcode-script",
+    }
+  }
 }
 
 #[derive(Debug, Default, Serialize, Deserialize)]

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

@@ -267,7 +267,7 @@ targets:
       VALID_ARCHS: {{~#each ios-valid-archs}} {{this}} {{/each}}
     legacy:
       toolPath: {{ tauri-binary }}
-      arguments: ios xcode-script -v --platform ${PLATFORM_DISPLAY_NAME:?} --sdk-root ${SDKROOT:?} --configuration ${CONFIGURATION:?} ${FORCE_COLOR} ${ARCHS:?}
+      arguments: {{ tauri-binary-args-str }} -v --platform ${PLATFORM_DISPLAY_NAME:?} --sdk-root ${SDKROOT:?} --configuration ${CONFIGURATION:?} ${FORCE_COLOR} ${ARCHS:?}
       passSettings: false # prevents evil linker errors
       workingDirectory: $(SRCROOT)/../..
   lib_{{app.name}}_macOS:
@@ -275,6 +275,6 @@ targets:
     platform: macOS
     legacy:
       toolPath: {{ tauri-binary }}
-      arguments: ios xcode-script -v --platform ${PLATFORM_DISPLAY_NAME:?} --sdk-root ${SDKROOT:?} --configuration ${CONFIGURATION:?} ${FORCE_COLOR} ${ARCHS:?}
+      arguments: {{ tauri-binary-args-str }} -v --platform ${PLATFORM_DISPLAY_NAME:?} --sdk-root ${SDKROOT:?} --configuration ${CONFIGURATION:?} ${FORCE_COLOR} ${ARCHS:?}
       passSettings: false
       workingDirectory: $(SRCROOT)/../..