Brendonovich / swift-rs

Call Swift functions from Rust with ease!
Apache License 2.0
246 stars 28 forks source link

feat: add iOS support #20

Closed lucasfernog closed 1 year ago

lucasfernog commented 1 year ago

I've been exploring swift-rs for Tauri. We want to move some Objective C code to Swift in the future, but this weekend I've been checking if we could offer a mobile plugin interface with this (similar to Capacitor plugins). I think it could work, but this is the first step to get swift-rs on iOS.

Basically this PR changes the build script to check if the target OS is iOS and whether it is a simulator target or not so adjust the target string (previously a fixed value of ${ARCH}-apple-macosx${MIN_VERSION}.

I've been using the 2.0 Tauri alpha to test this, though you could also use cargo-mobile or tauri-mobile.

It works perfectly when running on a device, but I'm not sure why it is failing for a simulator (it gives me this error: unable to load standard library for target 'arm64-apple-ios11.0-simulator', but it might be something with the project configuration).