Releases: chinedufn/swift-bridge
0.1.35: Add example of Rust linking in Swift (#104)
- Users no longer need to specify a
SWIFT_BRIDGE_OUT_DIR
environment variable. #104
0.1.34: Generate public initializers for shared structs (#101)
0.1.33
This release brings support for bridging Rust generic types such as
SomeType<String, u32>
, as well as a couple new function attributes
that make certain use cases a bit more ergonomic.
For example, the following is now possible:
#[swift_bridge::bridge]
mod ffi {
extern "Rust" {
// Declare the generic type once.
#[swift_bridge(declare_generic)]
type MyType<A, B>;
}
extern "Rust" {
// Bridge as many monomorphic types as you like.
type MyType<u32, String>;
fn some_function(arg: MyType<u32, String>) -> &str;
type MyType<i8, Vec<u8>>;
}
}
pub struct MyType<T, U> {
my_field1: T,
my_field2: U
}
fn some_function(arg: MyType<u32, String>) -> &str {
unimplemented!()
}
-
Support bridging generic opaque Rust types such as
MyType<u32>
#81 -
Support Option generic opaque Rust types such as
Option<MyType<u32>>
#87 -
Support bridging generic opaque Rust Copy types such as
chrono::DateTime<Utc>
#84 -
Support Option opaque Rust copy types such as
Option<MyCopyType>
#85 -
Introduce
get
andget_with
attributes to directly access a field without going through a function #82 -
Better compile time errors for unrecognized attributes #83
-
Deprecate
into_return_type
attribute in favor ofreturn_into
#73 #95 (thanks @Pouria-007)
0.1.32
- Introduce the
#[swift_bridge(Copy)]
attribute for efficiently passing opaqueCopy
types between Rust and Swift #63#[swift_bridge::bridge] mod ffi { extern "Rust" { #[swift_bridge(Copy(16))] type UserId; #[swift_bridge(Copy(16))] type OrganizationId; } } #[derive(Copy, Clone)] struct UserId(uuid::Uuid); #[derive(Copy, Clone)] struct OrganizationId(uuid::Uuid);
0.1.31
0.1.30
0.1.29
-
Add
swift_bridge_build::create_package
API for creating a Swift Package from a Rust library #36 (Thanks @Jomy10) -
Add
swift-bridge create-package
CLI command for creating a Swift Package from a Rust library #38 (Thanks @Jomy10) -
Update the Swift Package book chapter with the new API and CLI command for creating swift packages (Thanks @Jomy10)
0.1.28
0.1.27
This release starts adding support for defining and passing enums between Swift and Rust.
Enums where variants have data are not yet supported, but will be in a future release.
0.1.26
- Add support for
Option<T>
shared struct fields #24
For example, the following is now possible:
#[swift_bridge::bridge]
mod ffi {
#[swift_bridge(swift_repr = "struct")]
struct SomeStruct {
field: Option<u8>,
another_field: Option<f32>,
}
}
- Add a
return_with = path::to::function
attribute #25
For example, the following is now possible:
#[swift_bridge::bridge]
mod ffi {
extern "Rust" {
#[swift_bridge(return_with = some_module::convert_str_to_u32)]
fn get_str_value_return_with() -> u32;
}
}
fn get_str_value_return_with() -> &'static str {
"123"
}
mod some_module {
pub fn convert_str_to_u32(val: &str) -> u32 {
val.parse().unwrap()
}
}