tauri-apps / tauri

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

[bug] compile the Plugin using sysroot for 'iPhoneOS' but targeting 'MacOSX' #10717

Closed rdlabo closed 2 weeks ago

rdlabo commented 3 weeks ago

Describe the bug

swift-rs run with producing the wrong target: https://github.com/Brendonovich/swift-rs/issues/49

When compiling Objective-C, certain code (such as requestLocation and kCLAuthorizationStatusAuthorizedWhenInUse for location information not supported by MacOS) will stop the build with an error.


Note: This can be corrected by adding the following to Cargo.toml. This is a patch created by guillemcordoba.

[patch.crates-io]
swift-rs = { git = "https://github.com/guillemcordoba/swift-rs", branch = "main" }

Reproduction

I had this happen when I loaded Stripe with the plugin SPM.

// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "tauri-plugin-stripe-payment",
    platforms: [
        .iOS(.v13),
    ],
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "tauri-plugin-stripe-payment",
            type: .static,
            targets: ["tauri-plugin-stripe-payment"]),
    ],
    dependencies: [
        .package(name: "Tauri", path: "../.tauri/tauri-api"),
        .package(url: "https://github.com/stripe/stripe-ios-spm", .upToNextMajor(from: "23.0.0"))
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages this package depends on.
        .target(
            name: "tauri-plugin-stripe-payment",
            dependencies: [
                .byName(name: "Tauri"),
                .product(name: "StripePaymentSheet", package: "stripe-ios-spm"),
                .product(name: "StripeApplePay", package: "stripe-ios-spm"),
            ],
            path: "Plugin")
    ]
)

Expected behavior

No response

Full tauri info output

[✔] Environment
    - OS: Mac OS 14.4.1 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.80.1 (3f5fd8dd4 2024-08-06)
    ✔ cargo: 1.80.1 (376290515 2024-07-16)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 22.6.0
    - pnpm: 8.9.0
    - yarn: 1.17.3
    - npm: 10.8.2

[-] Packages
    - tauri [RUST]: 2.0.0-rc.3
    - tauri-build [RUST]: 2.0.0-rc.3
    - wry [RUST]: 0.42.0
    - tao [RUST]: 0.29.0
    - tauri-cli [RUST]: 2.0.0-alpha.7
    - @tauri-apps/api [NPM]: 2.0.0-rc.1
    - @tauri-apps/cli [NPM]: 2.0.0-rc.3

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

[-] iOS
    - Developer Teams: ****************


### Stack trace

_No response_

### Additional context

_No response_
lucasfernog commented 3 weeks ago

interesting.. I think I couldn't fix this issue so I added #9843 instead.. if this fixes the issue I also found, that would be amazing

rdlabo commented 3 weeks ago

Thank you. I tried a couple of packages and the compilation worked fine. However, on iOS, I cannot access the Resource and the process itself does not work (e.g. image assets).

@lucasfernog I don't understand xcodebuild well, but does access to resources seem to work here? I would be glad to get some tips.

lucasfernog commented 2 weeks ago

can you share an example to reproduce the issue?

rdlabo commented 2 weeks ago

Payment: https://github.com/rdlabo-team/tauri-plugin-stripe/tree/main/packages/payment identity: https://github.com/rdlabo-team/tauri-plugin-stripe/tree/main/packages/identity

It is only a basic implementation. Also, it is iOS only.