Skip to content

Updates to allow building using Swift 6#14

Open
mlink wants to merge 1 commit intojamf:mainfrom
mlink:main
Open

Updates to allow building using Swift 6#14
mlink wants to merge 1 commit intojamf:mainfrom
mlink:main

Conversation

@mlink
Copy link
Contributor

@mlink mlink commented Mar 18, 2026

Updates to allow building with Swift 6 and updating the minimum Swift version to 5.10 in order to use nonisolated(unsafe) when necessary. Proposing marking as version 1.4.0 as that seemed to be the next logical step in the CHANGELOG. Specifically this PR focused on surgical updates for Swift 6 compatibility without any changes to API behavior or usage while maintaining compatibility to build with Swift 5. In order to maintain Swift 5 compatibility certain Swift 6 features were avoided (i.e. sending, @isolated(any), et al) and the more strict Sendable conformance is used. The most major change is that the *Entity types were changed from classes to structs since alternative options would introduce even more complex changes (e.g mutex, actor, etc) that are required for Sendable conformance in reference types. Due to this change there may be cases in existing code that use this package that will need to be updated, specifically since the mentioned types are no longer classes their mutability is determined by their declaration (now must use var instead of let to mutate the instance).

    let myHaversack = Haversack()

    // updating to this version of the package will now require this declaration change to use `var` instead of `let`
    var newPassword = InternetPasswordEntity()

    newPassword.protocol = .HTTPS
    newPassword.server = "test.example.com"
    newPassword.account = "mine"
    newPassword.passwordData = "top secret".data(using: .utf8)
    let savedPassword = try myHaversack.save(newPassword, itemSecurity: .standard, updateExisting: true)

This seems like a pretty minor inconvenience, but could also be considered a breaking change since it introduces potential build failures. To avoid breaking any code that automatically updates to this version the proposed version could be updated to 2.0.0 for a major release following SemVer.

There are a few places where NSLock is used to protect mutable state, since the minimum version supported is still < macOS 13 OSAllocatedUnfairLock is not available, but it could be used instead in a future version when the minimum supported OS versions are updated.

The only significant changes to unit tests were changing the declaration of *Entity types to be var for mutability, the rest of the API is essentially unchanged.

API and Type System Changes

  • Converted entity types (CertificateEntity, GenericPasswordEntity, InternetPasswordEntity, IdentityEntity, KeyEntity) from classes to structs for improved value semantics and thread safety. ([1], [2], [3], [4])
  • Refactored PasswordBaseEntity from a base class to a protocol with default implementations, and updated conforming types accordingly. ([1], [2])
  • Added Sendable conformance to all public types, protocols, and enums, including closure properties and completion handlers, to support Swift concurrency. ([1], [2], [3])
  • Made the KeychainStorable protocol require Equatable conformance. (CHANGELOG.mdR8-R22)

Swift Version and Build System

  • Updated minimum Swift tools version to 5.10 and added explicit support for Swift 6 in Package.swift. ([1], [2])
  • Updated the project to build with Swift 6, including migration of internal CFString dictionary keys to String for Sendable compatibility. (CHANGELOG.mdR8-R22)

Concurrency and Thread Safety

  • Updated query and configuration properties to use NSLock for thread-safe access. (CHANGELOG.mdR8-R22)
  • Marked all completion handlers and closure properties as @Sendable. (CHANGELOG.mdR8-R22)

CI/CD and Infrastructure

  • Updated GitHub Actions workflow to use newer macOS runners, Xcode simulators, and actions/checkout versions for better compatibility and future-proofing. (.github/workflows/swift.ymlL14-R37)
  • Updated copyright years and license headers to 2026 across the codebase. ([1], [2], [3], [4], [5], [6], [7], [8])

Documentation

  • Updated CHANGELOG.md and README.md to reflect the new version, changes, and contributors. ([1], [2], [3])

These changes collectively modernize the codebase for Swift 6, enhance concurrency safety, and improve maintainability and developer experience.

@team-adder team-adder bot requested review from tsvoboda-wandera and watkyn March 18, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant