Brendonovich / swift-rs

Call Swift functions from Rust with ease!
Apache License 2.0
259 stars 30 forks source link

Failing to compile swift package Tauri, mismatched sdk target #57

Open Zack-Xb opened 1 year ago

Zack-Xb commented 1 year ago

running cargo tauri ios dev on tauri's side but I think this is an issue from swift-rs env setup.

Zack-Xb commented 1 year ago
error: failed to run custom build command for `tauri v2.0.0-alpha.14`

Caused by:
  process didn't exit successfully: `/Users/zack/SVC/Learn/AVL/avail_mobile/tauri_app/backend/target/debug/build/tauri-62bd3bdaacb764e9/build-script-build` (exit status: 101)
  --- stdout
  cargo:rustc-cfg=dev
  cargo:rustc-cfg=mobile
  cargo:rustc-cfg=ipc_custom_protocol
  cargo:rustc-link-search=native=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator
  cargo:rustc-link-search=native=/usr/lib/swift
  cargo:rustc-link-lib=clang_rt.iossim
  cargo:rustc-link-search=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin

  --- stderr
  error: 'ios-api': Invalid manifest (compiled with: ["/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc", "-vfsoverlay", "/var/folders/yt/x1hsmp_x0wl9rj_12qv77_zm0000gp/T/TemporaryDirectory.QOhESD/vfs.yaml", "-L", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/ManifestAPI", "-lPackageDescription", "-Xlinker", "-rpath", "-Xlinker", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/ManifestAPI", "-target", "arm64-apple-macosx13.0", "-sdk", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk", "-F", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks", "-I", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib", "-L", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib", "-swift-version", "5", "-I", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/ManifestAPI", "-sdk", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk", "-package-description-version", "5.3.0", "/Users/zack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tauri-2.0.0-alpha.14/mobile/ios-api/Package.swift", "-Xfrontend", "-disable-implicit-concurrency-module-import", "-Xfrontend", "-disable-implicit-string-processing-module-import", "-o", "/var/folders/yt/x1hsmp_x0wl9rj_12qv77_zm0000gp/T/TemporaryDirectory.ZXU4Br/ios-api-manifest"])
  sandbox-exec: sandbox_apply: Operation not permitted
  thread 'main' panicked at 'Failed to compile swift package Tauri', /Users/zack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swift-rs-1.0.6/src-rs/build.rs:276:17
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/panicking.rs:593:5
     1: core::panicking::panic_fmt
               at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/panicking.rs:67:14
     2: swift_rs::build::SwiftLinker::link
               at /Users/zack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swift-rs-1.0.6/src-rs/build.rs:276:17
     3: tauri_build::mobile::link_swift_library
               at /Users/zack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tauri-build-2.0.0-alpha.8/src/mobile.rs:104:3
     4: build_script_build::main
               at ./build.rs:135:7
     5: core::ops::function::FnOnce::call_once
               at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/ops/function.rs:250:5
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
       Error [tauri_cli] Failed to run `cargo build`: command ["cargo", "build", "--package", "avail_wallet", "--manifest-path", "/Users/zack/SVC/Learn/AVL/avail_mobile/tauri_app/backend/Cargo.toml", "--target", "aarch64-apple-ios-sim", "--features", "tauri/rustls-tls", "--lib", "--no-default-features"] exited with code 101

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 'avail_wallet_iOS' from project 'avail_wallet')
** BUILD FAILED **
Brendonovich commented 1 year ago

I'm curious whether this has something to do with #49, since ios-api was compiled with swiftc -target arm64-apple-macosx13.0. I'd think that should be arm64-apple-iosX.X?

Zack-Xb commented 1 year ago

Yes I think they are related, I'll look into how tauri invokes this maybe the target is wrong as you are saying. I don't know if swift-rs is evaluating this or tauri is I'll see. But I remember having this issue with swift-rs as mentoned is #49

Zack-Xb commented 1 year ago

Any update on this @Brendonovich ?