tauri-apps / tauri

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

[bug] [ios] Cannot build for iOS (building for 'iOS', but linking in object file built for 'zippered(macOS/Catalyst)') #9292

Open venkr opened 4 months ago

venkr commented 4 months ago

Describe the bug

I'm trying to build an existing macOS + Windows Tauri app for iOS as well. I did this by running pnpm tauri ios init and pnpm tauri ios dev.

However, I run into:

Error: Cannot find module '/Users/venki/src/r2/apps/limitless/ts/src-tauri/gen/apple/tauri'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.10.0
Command PhaseScriptExecution failed with a nonzero exit code

note: Run script build phase 'Build Rust Code' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'limitless-app_iOS' from project 'limitless-app')
** BUILD FAILED **

The following build commands failed:
    PhaseScriptExecution Build\ Rust\ Code /Users/venki/src/r2/apps/limitless/ts/src-tauri/gen/apple/build/limitless-app.build/debug-iphonesimulator/limitless-app_iOS.build/Script-856DF6B869FD769F10065C61.sh (in target 'limitless-app_iOS' from project 'limitless-app')
(1 failure)
    Error command ["xcodebuild"] exited with code 65

One note is: I tried to start a new sample iOS app with create-tauri-app and that works fine. So there's definitely something odd about this project. I'll try to work on some more of the differences, and figure out a repro, but I'd love any debugging advice to point me to the right direction on how to add iOS to an existing project.

More details about exactly what I ran:

Overall, I'd also appreciate any pointers into the Tauri repo I could investigate better. I don't really get what's trying to access gen/apple/tauri that doesn't seem like a real module to me.

Reproduction

No response

Expected behavior

No response

Full tauri info output

[✔] Environment
    - OS: Mac OS 14.4.1 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.76.0 (07dca489a 2024-02-04)
    ✔ cargo: 1.76.0 (c84b36747 2024-01-18)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 20.10.0
    - pnpm: 8.11.0
    - yarn: 1.22.19
    - npm: 8.1.2

[-] Packages
    - tauri [RUST]: 2.0.0-beta.12
    - tauri-build [RUST]: 2.0.0-beta.10
    - wry [RUST]: 0.37.0
    - tao [RUST]: 0.26.0
    - @tauri-apps/api [NPM]: 2.0.0-beta.0
    - @tauri-apps/cli [NPM]: 2.0.0-beta.11

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: http://localhost:5173/
    - devUrl: http://localhost:5173/
    - framework: React
    - bundler: Vite

Stack trace

No response

Additional context

No response

venkr commented 3 months ago

I've gotten past this error, not sure if I recall what I did anymore though..

I'm now stuck at an error that seems to be this one: https://github.com/tauri-apps/cargo-mobile2/issues/291

venkr commented 3 months ago

May also be related to this one: https://github.com/tauri-apps/cargo-mobile2/issues/252

venkr commented 3 months ago

Alright, more details incoming:

I'm able to successfully tauri ios init - but tauri ios dev fails with: Error [tauri_cli] Failed to run cargo build: command ["cargo", "build", "--package", "limitless-app", "--manifest-path", "/Users/venki/src/r2/apps/limitless/ts/src-tauri/Cargo.toml", "--target", "aarch64-apple-ios", "--features", "tauri/rustls-tls", "--lib", "--no-default-features"] exited with code 101

In order to further diagnose it, I manually run the cargo build command: cargo build --package limitless-app --manifest-path Cargo.toml --target aarch64-apple-ios --features tauri/rustls-tls --lib --no-default-features

Then, I get a more informative set of errors:

error: linking withccfailed: exit status: 1 The specific error seems to be: ld: building for 'iOS', but linking in object file (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftCompatibility51.a[arm64][6](Overrides.cpp.o)) built for 'zippered(macOS/Catalyst)'

Which is the same as (https://github.com/tauri-apps/cargo-mobile2/issues/252, https://github.com/tauri-apps/cargo-mobile2/issues/291)

Here are more details of my exact flow:

So, I decided to try out the potential fix from: https://github.com/tauri-apps/cargo-mobile2/pull/272

I ran the following steps:

That did not fix anything either, I still run into the same issue: ld: building for 'iOS', but linking in object file (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswiftCompatibility51.a[arm64][6](Overrides.cpp.o)) built for 'zippered(macOS/Catalyst)

Open to any further ideas on how I'd get this working on iOS - looks like the place I'm stuck at is it seems to incorrectly be linking in something from my host platform.