Skip to content

Conversation

@Cartisim
Copy link

@Cartisim Cartisim commented Nov 3, 2025

Add Package trait to bypass the use of CryptoKit in order to use all of the API's on all available Apple operating systems

Checklist

  • I've run tests to see all new and existing tests pass
  • I've followed the code style of the rest of the project
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary

If you've made changes to gyb files

  • [ N/A] I've run ./scripts/generate_boilerplate_files_with_gyb.sh and included updated generated files in a commit of this pull request

Motivation:

_MLKEM is a power tool that SwiftCrypto has made available to the community. Unfortunately on Apple Platforms it is only support on Apple Operating Systems 26 and up. SwiftCrypto however is much more flexible. Ideally it would be nice to use CryptoKit on 26 and up for Apple systems and Swift Crypto bellow 26; however the design of SwiftCrypto makes that a bit difficult without a chunk of work. A compromise is to add a package trait that will force build the SwiftCrypto API on all Apple Operating Systems. This is also an attractive feature for those who do not want to rely on the Apple specific implementation of CryptoKit alleviating concerns of potential bugs in 2 different implementations, consumers can trust 1 source of truth as an alternative if they so choose. _

Modifications:

In Package.swift if the device can import Darwin we pass the needed trait to the swiftSettings:[] and the needed define() blocks

Result:

When passing the trait in the consuming product to swift-crypt, the trait influences to build only the SwiftCrypto API

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