Skip to content

Releases: chinedufn/swift-bridge

0.1.37

15 Sep 16:31
2ad1757
Compare
Choose a tag to compare
  • Support passing callbacks from Rust -> Swift #110
    // For example, the following is now possible:
    #[swift_bridge::bridge]
    mod ffi {
        extern "Swift" {
            type StripeTerminalSingleton;
    
            #[swift_bridge(init)]
            fn new() -> StripeTerminalSingleton;
    
            fn retrieve_payment_intent(
                &self,
                client_secret: &str,
                callback: Box<dyn FnOnce(Result<PaymentIntentWrapper, String>)>,
            );
    
            fn collect_payment_method(
                &self,
                payment_intent: PaymentIntentWrapper,
                callback: Box<dyn FnOnce(Result<PaymentIntentWrapper, String>)>,
            );
    
            fn process_payment(
                &self,
                payment_intent: PaymentIntentWrapper,
                callback: Box<dyn FnOnce(Result<PaymentIntentWrapper, ProcessPaymentError)>,
            );
        }
    }

0.1.36

23 Aug 17:14
4c5fe2d
Compare
Choose a tag to compare
  • Support returning opaque Swift types from Swift -> Rust #109
    // For example, the following is now possible:
    #[swift_bridge::bridge]
    mod ffi {
        extern "Swift" {
            type SomeType;
    
            fn some_function(arg: SomeType) -> SomeType;
            fn some_method(&self, arg: SomeType) -> SomeType;
        }
    }

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)