Browse Source

fix(cli): pnpm detection on mobile init and xcode-script (#9553)

* fix(cli): pnpm detection on mobile init

* small outputFiles fix

* same check for xcode-script

* Discard changes to tooling/cli/node/index.js

* Discard changes to tooling/cli/node/index.d.ts

---------

Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
Lucas Fernandes Nogueira 1 năm trước cách đây
mục cha
commit
4a33bc6a62

+ 6 - 0
.changes/fix-pnpm-check.md

@@ -0,0 +1,6 @@
+---
+"tauri-cli": patch:bug
+"@tauri-apps/cli": patch:bug
+---
+
+Fixes `pnpm` detection when initializing and running a mobile project.

+ 3 - 1
tooling/cli/src/mobile/init.rs

@@ -103,7 +103,9 @@ pub fn exec(
       if let Some(bin_stem) = bin_path.file_stem() {
         let r = regex::Regex::new("(nodejs|node)\\-?([1-9]*)*$").unwrap();
         if r.is_match(&bin_stem.to_string_lossy()) {
-          if let Some(npm_execpath) = var_os("npm_execpath") {
+          if var_os("PNPM_PACKAGE_NAME").is_some() {
+            return ("pnpm".into(), build_args);
+          } else if let Some(npm_execpath) = var_os("npm_execpath") {
             let manager_stem = PathBuf::from(&npm_execpath)
               .file_stem()
               .unwrap()

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

@@ -61,7 +61,7 @@ pub fn command(options: Options) -> Result<()> {
   }
 
   // `xcode-script` is ran from the `gen/apple` folder when not using NPM.
-  if var_os("npm_lifecycle_event").is_none() {
+  if var_os("npm_lifecycle_event").is_none() && var_os("PNPM_PACKAGE_NAME").is_none() {
     set_current_dir(current_dir()?.parent().unwrap().parent().unwrap()).unwrap();
   }
 

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

@@ -261,12 +261,15 @@ fn read_options(identifier: &str) -> CliOptions {
   let runtime = tokio::runtime::Runtime::new().unwrap();
   let options = runtime
     .block_on(async move {
+      let addr_path = temp_dir().join(format!("{identifier}-server-addr"));
       let (tx, rx) = WsTransportClientBuilder::default()
         .build(
           format!(
             "ws://{}",
-            read_to_string(temp_dir().join(format!("{identifier}-server-addr")))
-              .expect("missing addr file")
+            read_to_string(&addr_path).unwrap_or_else(|e| panic!(
+              "failed to read missing addr file {}: {e}",
+              addr_path.display()
+            ))
           )
           .parse()
           .unwrap(),

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

@@ -127,8 +127,9 @@ targets:
         name: Build Rust Code
         basedOnDependencyAnalysis: false
         outputFiles:
-          - $(SRCROOT)/target/aarch64-apple-ios/${CONFIGURATION}/deps/lib{{app.lib-name}}.a
-          - $(SRCROOT)/target/x86_64-apple-ios/${CONFIGURATION}/deps/lib{{app.lib-name}}.a
+          - $(SRCROOT)/Externals/x86_64/${CONFIGURATION}/lib{{app.lib-name}}.a
+          - $(SRCROOT)/Externals/arm64/${CONFIGURATION}/lib{{app.lib-name}}.a
+          - $(SRCROOT)/Externals/arm64-sim/${CONFIGURATION}/lib{{app.lib-name}}.a
     {{~#if ios-post-compile-scripts}}
     postCompileScripts:
       {{~#each ios-post-compile-scripts}}{{#if this.path}}