| Crates.io | tauri-swift-runtime |
| lib.rs | tauri-swift-runtime |
| version | 0.1.2 |
| created_at | 2025-08-10 14:45:11.707331+00 |
| updated_at | 2025-08-10 14:45:11.707331+00 |
| description | A runtime layer for executing Swift code in Tauri plugins on macOS and iOS |
| homepage | |
| repository | https://github.com/Choochmeque/tauri-swift-runtime |
| max_upload_size | |
| id | 1788971 |
| size | 153,538 |
A Swift runtime bridge for Tauri applications, enabling native Swift plugin development for macOS and iOS.
This library provides the infrastructure to write and execute Swift plugins within Tauri applications. It handles the FFI (Foreign Function Interface) between Rust and Swift, allowing developers to access native Apple APIs through Swift while maintaining the cross-platform benefits of Tauri.
Add to your Cargo.toml:
[dependencies]
tauri-swift-runtime = "0.1.0"
Add to your Package.swift:
dependencies: [
.package(url: "https://github.com/yourusername/tauri-swift-runtime", from: "0.1.0")
]
Extend the Plugin class and implement your methods:
import TauriSwiftRuntime
class MyPlugin: Plugin {
@objc func myMethod(_ invoke: Invoke) {
// Your Swift code here
invoke.success(["message": "Hello from Swift!"])
}
@objc func asyncMethod(_ invoke: Invoke, completionHandler: @escaping (NSError?) -> Void) {
// Async operations
DispatchQueue.main.async {
invoke.success(["result": "Async complete"])
completionHandler(nil)
}
}
}
Use the provided macros to bind your Swift plugin:
use tauri_swift_runtime::swift_plugin_binding;
swift_plugin_binding!(init_my_plugin);
// In your Tauri setup
app.setup(|app| {
// Initialize your Swift plugin
init_my_plugin();
Ok(())
});
Call your Swift plugin from JavaScript:
await invoke('plugin:myplugin|myMethod', {
arg1: 'value'
});
MIT License - see LICENSE file for details.
Copyright (c) 2025 Vladimir Pankratov