Skip to content

Releases: chinedufn/swift-bridge

0.1.35: Add example of Rust linking in Swift (#104)

27 Jul 03:25
23d60fe
Compare
Choose a tag to compare
  • Users no longer need to specify a SWIFT_BRIDGE_OUT_DIR environment variable. #104

0.1.34: Generate public initializers for shared structs (#101)

06 Jun 20:15
a207c24
Compare
Choose a tag to compare
  • Generate public initializers for shared structs #101 (thanks @samnm)

0.1.33

10 May 22:39
08893c9
Compare
Choose a tag to compare

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 and get_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 of return_into #73 #95 (thanks @Pouria-007)

0.1.32

24 Apr 04:31
6444543
Compare
Choose a tag to compare
  • Introduce the #[swift_bridge(Copy)] attribute for efficiently passing opaque Copy 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

21 Apr 12:23
f2e8586
Compare
Choose a tag to compare
  • Adjust how we generate Swift Packages to work in Xcode 13.3+ #57 (Thanks @simlay)

  • Support returning String from async Rust functions #59

0.1.30

20 Apr 01:55
6b3cb07
Compare
Choose a tag to compare
  • Add support for arguments in async Rust functions/methods #51.

  • Add support for async Rust methods #52.

0.1.29

12 Mar 15:18
bef79f6
Compare
Choose a tag to compare
  • 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

17 Feb 02:22
ecc6704
Compare
Choose a tag to compare
  • You can now call async Rust functions from Swift (#31)

  • You can now use `Option in function arg and return types (#32)

0.1.27

09 Feb 01:05
390c2ee
Compare
Choose a tag to compare

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.

  • Add support for defining shared enums #27

  • Add support for passing shared enums across the FFI boundary #28

  • Add support for passing Option<Shared Enum> across the FFI boundary #29

0.1.26

02 Feb 15:49
239b789
Compare
Choose a tag to compare
  • 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()
    }
}