1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-06 03:33:30 +00:00

Use swift in desktop native

This commit is contained in:
Bernd Schoolmann
2025-10-06 09:32:00 +02:00
parent 727689d827
commit 2bf692d07b
7 changed files with 104 additions and 5 deletions

View File

@@ -368,6 +368,12 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf"
[[package]]
name = "base64"
version = "0.21.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
[[package]]
name = "base64"
version = "0.22.1"
@@ -445,7 +451,7 @@ dependencies = [
"aes-gcm",
"anyhow",
"async-trait",
"base64",
"base64 0.22.1",
"cbc",
"hex",
"homedir",
@@ -889,7 +895,7 @@ dependencies = [
"anyhow",
"arboard",
"ashpd",
"base64",
"base64 0.22.1",
"bitwarden-russh",
"byteorder",
"bytes",
@@ -916,6 +922,7 @@ dependencies = [
"sha2",
"ssh-encoding",
"ssh-key",
"swift-rs",
"sysinfo",
"thiserror 2.0.12",
"tokio",
@@ -937,7 +944,7 @@ version = "0.0.0"
dependencies = [
"anyhow",
"autotype",
"base64",
"base64 0.22.1",
"bitwarden_chromium_importer",
"desktop_core",
"hex",
@@ -2897,9 +2904,9 @@ dependencies = [
[[package]]
name = "security-framework"
version = "3.4.0"
version = "3.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60b369d18893388b345804dc0007963c99b7d665ae71d275812d828c6f089640"
checksum = "cc198e42d9b7510827939c9a15f5062a0c913f3371d765977e586d2fe6c16f4a"
dependencies = [
"bitflags",
"core-foundation",
@@ -3162,6 +3169,17 @@ version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "swift-rs"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4057c98e2e852d51fdcfca832aac7b571f6b351ad159f9eda5db1655f8d0c4d7"
dependencies = [
"base64 0.21.7",
"serde",
"serde_json",
]
[[package]]
name = "syn"
version = "2.0.101"

View File

@@ -46,6 +46,7 @@ ssh-key = { workspace = true, features = [
"rsa",
"getrandom",
] }
swift-rs = { version = "1.0.7", features = ["build"] }
sysinfo = { workspace = true, features = ["windows"] }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["io-util", "sync", "macros", "net"] }
@@ -88,5 +89,9 @@ ashpd = { workspace = true }
zbus = { workspace = true, optional = true }
zbus_polkit = { workspace = true, optional = true }
[build-dependencies]
swift-rs = { version = "1.0.5", features = ["build"] }
[lints]
workspace = true

View File

@@ -0,0 +1,14 @@
use swift_rs::SwiftLinker;
const PACKAGE_NAME: &str = "MacTest";
const PACKAGE_PATH: &str = "./src/MacTest";
fn build() {
SwiftLinker::new("10.13")
.with_package(PACKAGE_NAME, PACKAGE_PATH)
.link();
}
fn main() {
build();
}

View File

@@ -0,0 +1,14 @@
{
"pins" : [
{
"identity" : "swift-rs",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Brendonovich/swift-rs",
"state" : {
"revision" : "f64a4514de07f450ec5b6aa297624cd3479d9579",
"version" : "1.0.7"
}
}
],
"version" : 2
}

View File

@@ -0,0 +1,31 @@
// swift-tools-version: 5.8
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "MacTest",
platforms: [
.macOS(.v12)
],
products: [
.library(
name: "MacTest",
type: .static,
targets: ["MacTest"]),
],
dependencies: [
.package(url: "https://github.com/Brendonovich/swift-rs", from: "1.0.5")
],
targets: [
.target(
name: "MacTest",
dependencies: [
.product(
name: "SwiftRs",
package: "swift-rs"
),
]),
]
)

View File

@@ -0,0 +1,6 @@
// hello world from swift
@_cdecl("hello_world")
public func hello_world() {
print("Hello, world!")
}

View File

@@ -14,3 +14,14 @@ use zeroizing_alloc::ZeroAlloc;
#[global_allocator]
static ALLOC: ZeroAlloc<std::alloc::System> = ZeroAlloc(std::alloc::System);
#[cfg(test)]
mod tests {
use swift_rs::swift;
#[test]
fn swift() {
swift!(fn hello_world());
unsafe { hello_world() }
}
}