Skip to content

v4.0.0

Compare
Choose a tag to compare
@krishnavarma1 krishnavarma1 released this 14 Jan 19:53
· 2 commits to master since this release
104917c

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.

In Atom 4.0, we utilized the compile-time data race safety checks as a guiding principle to rewrite the underlying implementation of the networking code and access token refresh logic.

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, allowed us to update our implementation to throw an AtomError where errors could occur within the package implementation.
This means the client no longer needs to check the type of error returned by AtomNetworking, as it will always be an AtomError.

Moving to Swift 6 is really compelling if you're looking to future-proof your applications. We’ve rewritten AtomNetworking to make full use of these Swift 6 features.

Proposed Solution

As part of our move to Swift 6, we are implementing a series of significant upgrades to the AtomNetworking 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 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 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 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.

  • 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"]),
  • Clean up code: This involves removing outdated code, fixing minor issues, and generally tidying up the codebase to improve maintainability and performance.

  • Conform all 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.

  • Move away from Retryable: We moved away from Retryable operations by transitioning both Atom and Service to actors, which ensured more robust and predictable system behavior.

  • Remove unnecessary availability checks: After updating our deployment target to iOS 15, we removed unnecessary availability checks to streamline our codebase and improve development efficiency.

  • Rename the Atom package to AtomNetworking: This renaming clarifies the package's purpose. It also addresses the compiler warning where the public class Atom was shadowing the module Atom, which could cause failures when importing Atom in some configurations.

  • Rewrite the AtomResponse object: By rewriting the AtomResponse object to support the new concurrency model, we ensure propert integration with Swift's async/await, enhancing both performance and developer experience.

  • Rewrite BaseURL and BaseURLScheme, and all internal types to throw typed errors: Updating BaseURL, BaseURLScheme, and our internal types to throw AtomError types enhances error management, making it easier to pinpoint and resolve issues without the need to check for error type first.

  • 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.

  • 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 the Example application: We've enhanced the Example application to demonstrate improved performance and stability.

  • 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 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 AtomNetworking Swift package not just compatible with Swift 6 but also more efficient, safer, and easier to use, setting a good 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.

  • Add support for Swift tools version 6.0.
  • Add support for Swift language version 6.0.
  • Enable the BUILD_LIBRARY_FOR_DISTRIBUTION flag.
  • Move away from Retryable.
  • Remove completion-based APIs.
  • Remove unnecessary availability checks.
  • Rename the Atom package to AtomNetworking to adress the compiler warning where the public class Atom was shadowing the module Atom.
  • Rewrite the AtomResponse object to support the new concurrency model.
  • Rewrite BaseURL and BaseURLScheme, and all internal types to throw typed errors.
  • Update the copyright headers.
  • Update the deployment targets to iOS 15.
  • Update the documentation script.
  • Update the Example application.
  • Update MARK markers.
  • Update the project to recommended settings.
  • Update the UNIT tests.