tauri-apps / tauri

Build smaller, faster, and more secure desktop applications with a web frontend.
https://tauri.app
Apache License 2.0
82.37k stars 2.47k forks source link

[bug] failing to run tauri2 with app extension on the iOS Simulator #10074

Closed mrguiman closed 1 month ago

mrguiman commented 3 months ago

Describe the bug

Trying to run a tauri 2 app on ios using cargo tauri ios dev fails when adding an extension to the app, with the following error:

...
<unknown>:0: error: unable to load standard library for target 'arm64-apple-ios13.0-simulator-sim'

I haven't been able to track down the origin of the error, although I have successfuly been able to build an ipa out of a similar project. Changing the deployment target to a higher iOS version produces a similar result. The target triplet seems a bit off as I wasn't able to identify similar targets on other projects

Reproduction

  1. Clone https://github.com/mrguiman/tauri2-test/tree/app-extension
  2. git checkout app-extension
  3. cargo tauri ios init
  4. cargo tauri ios dev

This should produce the same output. Please note that gen/apple/project.yml has been modified to introduce the app extension, and gen/apple/tauri2-test_iOS_shareExt has been commited as a basic boilerplate for a share extension (copied from an extension generated by xcode) but similar behavior happens when adding the extension through xcode itself.

Expected behavior

iOS apps built with tauri should be able to build with extensions to provide more capabilities and access to the iOS platform.

Full tauri info output

~/code/tauri2-test ❖  cargo tauri info                                                                                                                                                     

[✔] Environment
    - OS: Mac OS 14.5.0 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.78.0 (9b00956e5 2024-04-29)
    ✔ cargo: 1.78.0 (54d8815d0 2024-03-26)
    ✔ rustup: 1.27.0 (2024-03-08)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (environment override by RUSTUP_TOOLCHAIN)
    - node: 22.0.0
    - npm: 10.5.1

[-] Packages
    - tauri [RUST]: 2.0.0-beta.22
    - tauri-build [RUST]: 2.0.0-beta.17
    - wry [RUST]: 0.40.1
    - tao [RUST]: 0.28.1
    - tauri-cli [RUST]: 2.0.0-beta.20
    - @tauri-apps/api [NPM]: 2.0.0-beta.13
    - @tauri-apps/cli [NPM]: 2.0.0-beta.20

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: Svelte
    - bundler: Vite

[-] iOS
    - Developer Teams: xxxx (ID: Uxxxx), xxxx (ID: Cxxxx)

Stack trace

No response

Additional context

Playing around with the project's Build Settings around xcode, if I set ARCHS to by ARCH_STANDARD on the project and both targets the "arm64-sim" architecture still seems to be pushed by the command line, as explicited by part of the output log:

Build settings from command line:
    ARCHS = arm64-sim
    SDKROOT = iphonesimulator17.4

but raises an interesting warning which again points to the "arch64-sim" arch being fishy:

warning: None of the architectures in ARCHS (arm64-sim) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, arm64e, i386, x86_64) which is not in EXCLUDED_ARCHS (arm64).
dev-blc commented 3 months ago

I had this error with the simulator a while back, check versions of your Xcode application and also the CLI tools Update if it's an old version If not, go to `Xcode Settings -> Platforms -> {Choose the iOS mobile simulator} and delete and download again.

I am just trying to help, I don't know if this is the silver bullet for your issue here

mrguiman commented 3 months ago

Unfortunately it isn't, I appreciate that the error can come from multiple sources though, but in this case I've tried installing countless other platforms and changing the deployment target within the xcodeproject without success

mrguiman commented 3 months ago

Quick update with new results:

I'm still investigating on my previous suspicion that the arch64-sim might be the culprit somehow, because i had a feeling that the arm64-apple-ios13.0-simulator-sim target is assembled together and that the "-sim" suffix shouldn't be there. (I might be missing some important knowledge here though).

So what i did was manually invoke the command behind cargo tauri ios dev, but replacing the "arm64-sim" arch with just arm64:

/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -scheme tauri2-test_iOS -workspace /Users/gman/code/tauri2-test/src-tauri/gen/apple/tauri2-test.xcodeproj/project.xcworkspace/ -sdk iphonesimulator -configuration debug -arch arm64 -allowProvisioningUpdates build

This requires a few changes to the project, because the arm64 arch is set as excluded for the iphonesimulator. Removing this exclusion and running the command again does produce a different result, and as expected, the target now is arm64-apple-ios13.0-simulator and I no longer have the previous error, but something new:

thread 'main' panicked at /Users/gman/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tauri-cli-2.0.0-beta.20/src/mobile/mod.rs:282:6:
failed to read CLI options: Error when opening the TCP socket: Connection refused (os error 61)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Command PhaseScriptExecution failed with a nonzero exit code

Unfortunately I'm suffering from a severe lack of knowledge here and running entirely off of assumptions (this might very well be a red herring), so any insight would be appreciated.

mrguiman commented 2 months ago

So after talking to @lucasfernog, we figured out a way to run inside the simulator, from xcode, by running cargo tauri ios dev --open Thank you for having a look and providing information !

For future reference, the cleanest way I found to go about this would be to:

  1. Keep project.yml in source control (this allows to run cargo tauri ios init, which will use the existing project.yml for generate the project with xcodegen)
  2. Add the extension to project.yml.
  3. Run, from xcode, by starting xcode with cargo tauri ios dev --open

This branch provides a working example.