Skip to content

v3.0.0

Latest
Compare
Choose a tag to compare
@krishnavarma1 krishnavarma1 released this 07 Jan 02:07
59cd317

Introduction & Motivation

Swift 6 introduces several pivotal enhancements that significantly elevate its capabilities over previous versions, focusing on safety, performance, and broader platform support. One of the standout features is the introduction of compile-time data race safety in its concurrency model. This allows developers to catch potential data races at compile time, making concurrent programming safer and more reliable.

Swift 6 includes various compiler optimizations that enhance the efficiency of common operations, from collection handling to memory management.

In terms of language structure, Swift 6 brings improvements in error handling by allowing functions to specify exact error types, leading to more precise error management. This, combined with the introduction of noncopyable types, offers developers more control over data ownership, enhancing code safety and clarity.

The move to Swift 6 is compelling for developers looking to future-proof their applications. The enhancements in safety, performance, cross-platform capabilities, and developer tools make Swift 6 not just an update but a strategic advancement, ensuring that software development can keep pace with evolving technological demands and standards.

Proposed Solution

As part of our move to Swift 6, we are implementing a series of significant upgrades to the Keychain Swift package to ensure it aligns with the latest language features and standards. Here's a detailed look at the changes we're making:

  • Add support for Swift tools version to 6.0: We're updating our toolchain to take advantage of the new features and improvements in Swift 6, ensuring compatibility and leveraging the latest compiler optimizations.
swift-tools-version:6.0
  • Add support for Swift language version to 6.0: This change not only includes adopting the new syntax and features of Swift 6 but also ensures our code benefits from the enhanced type safety and compile-time checks introduced in this version.
.swiftLanguageMode(.v6)
  • Enable library evolution: By turning this on, we're allowing our library to evolve over time without breaking ABI compatibility, which is crucial for maintaining stability when updating or extending the library's functionality.
.unsafeFlags(["-enable-library-evolution", "-O"]),
  • Conform necessary types to Sendable protocol: With the new concurrency model in Swift 6, we're making sure our types can be safely used in concurrent contexts, reducing the risk of data races and improving the robustness of our package in multi-threaded environments.
public struct AccessLevel: Sendable {}
public struct SetupOption: Sendable {}
public struct Storage: Sendable {}

public struct Configuration: Sendable {}
public struct Manager: Sendable {}

public struct Keychain: Sendable {}
  • Deprecate keychain access options: To streamline the API and reduce redundancy, we're phasing out older access options, promoting a cleaner, more modern interface for developers. These access options have been removed to ensure we promote secure access to the keychain data.
enum AccessLevel {
    /// ...

    /// The data in the keychain item can always be accessed regardless of whether the device is locked.
    case always

    /// The data in the keychain item can always be accessed regardless of whether the device is locked.
    case alwaysThisDeviceOnly

    /// ...
}
  • Enable BUILD_LIBRARY_FOR_DISTRIBUTION flag: This flag is set to prepare our library for distribution, ensuring it can be used across different platforms or within larger frameworks with optimal performance.

  • Rename Access type to AccessLevel for clarity: We're refining our terminology to make the code more intuitive. AccessLevel better describes the functionality, improving readability and developer experience.

// Previous type.
enum Access {}

// New type.
enum AccessLevel {}
  • Rename Keychain package to KeychainAccess: This renaming clarifies the package's purpose. It also addresses the compiler warning where the public class Keychain.Keychain was shadowing the module Keychain, which could cause failures when importing Keychain in some configurations.

  • Update copyright headers: We're refreshing these headers to reflect the current year and to ensure all intellectual property aspects are up to date.

// Copyright (c) 2025 Alaska Airlines
  • Update deployment targets to iOS 15: By setting this target, we ensure our package leverages the latest capabilities of iOS while still being accessible to a broad user base on newer devices.

  • Clean up code: This involves removing outdated code, fixing minor issues, and generally tidying up the codebase to improve maintainability and performance.

  • Update documentation script & documentation: New features and changes in Swift 6 necessitate updated documentation. We're enhancing our documentation tools and content to reflect these changes accurately.

  • Update MARK markers: We're organizing our code with updated MARK comments, which help in navigating the codebase more efficiently, especially in larger projects.

  • Update projects to recommended settings: We're aligning our project settings with Apple's latest recommendations for Swift 6, which includes settings for debugging, testing, and code signing.

  • Update README file: To reflect all these changes, we're updating our README to provide clear, current information about installation, usage, and new features.

  • Update UNIT tests: Testing is critical, especially with such significant updates. We're revising our unit tests to ensure they cover all new functionalities and conform to Swift 6's testing environment, ensuring our package remains robust and reliable.

    These changes collectively aim to make the Keychain Swift package not just compatible with Swift 6 but also more efficient, safer, and easier to use, setting a strong foundation for future development and broader platform support.

Detailed Design

See files changed.

Source compatibility

This implementation introduces a breaking change and will affect compatibility with existing source code.

Summary by Sourcery

Update Keychain Swift package to Swift 6.

New Features:

  • Add support for Swift tools version 6.0.
  • Add support for Swift language version 6.0.
  • Conform to Sendable protocol.
  • Enable library evolution.
  • Enable BUILD_LIBRARY_FOR_DISTRIBUTION flag.
  • Update deployment targets to iOS 15.

Tests:

  • Update UNIT tests.