Skip to content

Commit

Permalink
Add Minimum Supported Swift Version Policy (#316)
Browse files Browse the repository at this point in the history
This commit introduces a
"Minimum Supported Swift Version" policy to help users understand
whether their code is guaranteed to work on a particular version of
Swift.

As a starting point, we are supporting Swift 6.0+ .

Starting at `6.0` allows us to begin leveraging Swift's new ownership
features in order to automatically enforce certain safety requirements.

See the `Safety` chapter in the internal book for more information about
safety requirements that, by leveraging Swift 6.0, we will be able to
automatically enforce.
  • Loading branch information
chinedufn authored Feb 2, 2025
1 parent a661800 commit c15279c
Show file tree
Hide file tree
Showing 26 changed files with 43 additions and 24 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,25 @@ to see if any peak your interest.

These issues come with step-by-step instructions that should help guide you towards implementing your first patch.

## Minimum Supported Swift Version (MSSV)

`swift-bridge` currently guarantees that the Swift code that it generates will work on Swift `6.0` and later.
This is known the project's "Minimum Supported Swift Version" (MSSV).

`swift-bridge`'s current policy is that the minimum required Swift version can be increased at any time to
any Swift version that is at least one month old.

For instance, if Swift `9.10.11` is released on April 5, 2035, then on May 5, 2035 the `swift-bridge` project is allowed
to begin emitting Swift code that relies on Swift `9.10.11`.

We will increase our support windows when one or both of the following happen:

- We are no longer waiting for Swift features that increase the safety, performance and ergonomics of the Swift code that `swift-bridge` emits.
- For instance, Swift recently introduced the `~Copyable` protocol, which we plan to use enforce ownership when Swift code uses opaque Rust types.

- The short support window is disrupting projects that use `swift-bridge` today.
- Please open an issue if our MSSV policy impacts your project

## Acknowledgements

- [cxx](https://github.com/dtolnay/cxx) inspired the idea of using a bridge module to describe the FFI boundary.
Expand Down
48 changes: 24 additions & 24 deletions crates/swift-bridge-ir/src/codegen/codegen_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,30 @@ use crate::test_utils::{
assert_trimmed_generated_equals_trimmed_expected, parse_ok,
};

mod already_declared_attribute_codegen_tests;
mod argument_label_codegen_tests;
mod async_function_codegen_tests;
mod boxed_fnonce_codegen_tests;
mod built_in_tuple_codegen_tests;
mod c_header_declaration_order_codegen_tests;
mod conditional_compilation_codegen_tests;
mod derive_attribute_codegen_tests;
mod derive_struct_attribute_codegen_tests;
mod extern_rust_function_opaque_rust_type_argument_codegen_tests;
mod extern_rust_function_opaque_rust_type_return_codegen_tests;
mod extern_rust_method_swift_class_placement_codegen_tests;
mod function_attribute_codegen_tests;
mod generic_opaque_rust_type_codegen_tests;
mod opaque_rust_type_codegen_tests;
mod opaque_swift_type_codegen_tests;
mod option_codegen_tests;
mod result_codegen_tests;
mod return_into_attribute_codegen_tests;
mod single_representation_type_elision_codegen_tests;
mod string_codegen_tests;
mod transparent_enum_codegen_tests;
mod transparent_struct_codegen_tests;
mod vec_codegen_tests;
mod already_declared_attribute;
mod argument_label;
mod async_function;
mod boxed_fnonce;
mod built_in_tuple;
mod c_header_declaration_order;
mod conditional_compilation;
mod derive_attribute;
mod derive_struct_attribute;
mod extern_rust_function_opaque_rust_type_argument;
mod extern_rust_function_opaque_rust_type_return;
mod extern_rust_method_swift_class_placement;
mod function_attribute;
mod generic_opaque_rust_type;
mod opaque_rust_type;
mod opaque_swift_type;
mod option;
mod result;
mod return_into_attribute;
mod single_representation_type_elision;
mod string;
mod transparent_enum;
mod transparent_struct;
mod vec;

struct CodegenTest {
bridge_module: BridgeModule,
Expand Down

0 comments on commit c15279c

Please sign in to comment.