Skip to content

Commit 4a33bc6

Browse files
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>
1 parent bd64982 commit 4a33bc6

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

.changes/fix-pnpm-check.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri-cli": patch:bug
3+
"@tauri-apps/cli": patch:bug
4+
---
5+
6+
Fixes `pnpm` detection when initializing and running a mobile project.

tooling/cli/src/mobile/init.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ pub fn exec(
103103
if let Some(bin_stem) = bin_path.file_stem() {
104104
let r = regex::Regex::new("(nodejs|node)\\-?([1-9]*)*$").unwrap();
105105
if r.is_match(&bin_stem.to_string_lossy()) {
106-
if let Some(npm_execpath) = var_os("npm_execpath") {
106+
if var_os("PNPM_PACKAGE_NAME").is_some() {
107+
return ("pnpm".into(), build_args);
108+
} else if let Some(npm_execpath) = var_os("npm_execpath") {
107109
let manager_stem = PathBuf::from(&npm_execpath)
108110
.file_stem()
109111
.unwrap()

tooling/cli/src/mobile/ios/xcode_script.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub fn command(options: Options) -> Result<()> {
6161
}
6262

6363
// `xcode-script` is ran from the `gen/apple` folder when not using NPM.
64-
if var_os("npm_lifecycle_event").is_none() {
64+
if var_os("npm_lifecycle_event").is_none() && var_os("PNPM_PACKAGE_NAME").is_none() {
6565
set_current_dir(current_dir()?.parent().unwrap().parent().unwrap()).unwrap();
6666
}
6767

tooling/cli/src/mobile/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,15 @@ fn read_options(identifier: &str) -> CliOptions {
261261
let runtime = tokio::runtime::Runtime::new().unwrap();
262262
let options = runtime
263263
.block_on(async move {
264+
let addr_path = temp_dir().join(format!("{identifier}-server-addr"));
264265
let (tx, rx) = WsTransportClientBuilder::default()
265266
.build(
266267
format!(
267268
"ws://{}",
268-
read_to_string(temp_dir().join(format!("{identifier}-server-addr")))
269-
.expect("missing addr file")
269+
read_to_string(&addr_path).unwrap_or_else(|e| panic!(
270+
"failed to read missing addr file {}: {e}",
271+
addr_path.display()
272+
))
270273
)
271274
.parse()
272275
.unwrap(),

tooling/cli/templates/mobile/ios/project.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,9 @@ targets:
127127
name: Build Rust Code
128128
basedOnDependencyAnalysis: false
129129
outputFiles:
130-
- $(SRCROOT)/target/aarch64-apple-ios/${CONFIGURATION}/deps/lib{{app.lib-name}}.a
131-
- $(SRCROOT)/target/x86_64-apple-ios/${CONFIGURATION}/deps/lib{{app.lib-name}}.a
130+
- $(SRCROOT)/Externals/x86_64/${CONFIGURATION}/lib{{app.lib-name}}.a
131+
- $(SRCROOT)/Externals/arm64/${CONFIGURATION}/lib{{app.lib-name}}.a
132+
- $(SRCROOT)/Externals/arm64-sim/${CONFIGURATION}/lib{{app.lib-name}}.a
132133
{{~#if ios-post-compile-scripts}}
133134
postCompileScripts:
134135
{{~#each ios-post-compile-scripts}}{{#if this.path}}

0 commit comments

Comments
 (0)