Przeglądaj źródła

fix(cli): fix template and Xcode script to work when running with Xcode (#6350)

Lucas Fernandes Nogueira 2 lat temu
rodzic
commit
971ad7ae06

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

@@ -142,7 +142,7 @@ fn run_dev(
   let target = Target::all()
     .values()
     .find(|t| t.triple == target_triple)
-    .unwrap_or(Target::all().values().next().unwrap());
+    .unwrap_or_else(|| Target::all().values().next().unwrap());
   target.build(config, metadata, &env, noise_level, true, Profile::Debug)?;
 
   let open = options.open;

+ 13 - 4
tooling/cli/src/mobile/ios/xcode_script.rs

@@ -134,13 +134,22 @@ pub fn command(options: Options) -> Result<()> {
 
     let tauri_config = get_config(None)?;
 
-    for arch in options.arches {
+    // when using Xcode, the arches will be ['Simulator', 'arm64'] instead of ['arm64-sim']
+    let arches = if options.arches.contains(&"Simulator".into()) {
+      vec![if cfg!(target_arch = "aarch64") {
+        "arm64-sim".to_string()
+      } else {
+        "x86_64".to_string()
+      }]
+    } else {
+      options.arches
+    };
+    for arch in arches {
       // Set target-specific flags
       let (env_triple, rust_triple) = match arch.as_str() {
         "arm64" => ("aarch64_apple_ios", "aarch64-apple-ios"),
         "arm64-sim" => ("aarch64_apple_ios_sim", "aarch64-apple-ios-sim"),
         "x86_64" => ("x86_64_apple_ios", "x86_64-apple-ios"),
-        "Simulator" => continue,
         _ => {
           return Err(anyhow::anyhow!(
             "Arch specified by Xcode was invalid. {} isn't a known arch",
@@ -196,13 +205,13 @@ pub fn command(options: Options) -> Result<()> {
         return Err(anyhow::anyhow!("Library not found at {}. Make sure your Cargo.toml file has a [lib] block with `crate-type = [\"staticlib\", \"cdylib\", \"rlib\"]`", lib_path.display()));
       }
       std::fs::create_dir_all(format!(
-        "gen/apple/Externals/{rust_triple}/{}",
+        "gen/apple/Externals/{}",
         profile.as_str()
       ))?;
       std::fs::copy(
         lib_path,
         format!(
-          "gen/apple/Externals/{rust_triple}/{}/lib{}.a",
+          "gen/apple/Externals/{}/lib{}.a",
           profile.as_str(),
           config.app().lib_name()
         ),

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

@@ -72,9 +72,9 @@ targets:
         ENABLE_BITCODE: false
         ARCHS: [{{join ios-valid-archs}}]
         VALID_ARCHS: {{~#each ios-valid-archs}} {{this}} {{/each}}
-        LIBRARY_SEARCH_PATHS[arch=x86_64]: $(inherited) $(PROJECT_DIR)/Externals/x86_64-apple-ios/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
-        LIBRARY_SEARCH_PATHS[arch=arm64]: $(inherited) $(PROJECT_DIR)/Externals/aarch64-apple-ios/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
-        LIBRARY_SEARCH_PATHS[arch=arm64-sim]: $(inherited) $(PROJECT_DIR)/Externals/aarch64-apple-ios-sim/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
+        LIBRARY_SEARCH_PATHS[arch=x86_64]: $(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
+        LIBRARY_SEARCH_PATHS[arch=arm64]: $(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
+        LIBRARY_SEARCH_PATHS[arch=arm64-sim]: $(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
         ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES: true
       groups: [app]
     dependencies: