Skip to content

Use Array(data) instead of Data.bytes for CryptoSwift 1.9+ compatibility#78

Merged
marionbarker merged 1 commit into
loopandlearn:loop-next-devfrom
loopkitdev:fix/cryptoswift-1.9-rawspan
Jun 12, 2026
Merged

Use Array(data) instead of Data.bytes for CryptoSwift 1.9+ compatibility#78
marionbarker merged 1 commit into
loopandlearn:loop-next-devfrom
loopkitdev:fix/cryptoswift-1.9-rawspan

Conversation

@loopkitdev

Copy link
Copy Markdown

Problem

On Xcode 26 with CryptoSwift ≥ 1.9.0, every crypto call site fails to compile:

Cannot convert value of type 'RawSpan' to expected argument type 'Array<UInt8>'
Value of type 'RawSpan' has no member 'toHexString'

…30+ errors across EnDecrypt, O5LTKExchanger, DashKeyExchange, O5KeyExchange, and Milenage.

Cause

CryptoSwift 1.9.0 removed its extension Data { public var bytes: [UInt8] } (renamed to byteArray). With that extension gone, data.bytes resolves to Foundation's new native Data.bytes, which returns a RawSpan on the Xcode 26 SDK — not [UInt8].

Builds pinned to CryptoSwift ≤ 1.8.5 still have the old extension and are unaffected, so this only bites once a project's package resolution floats up to 1.9.0 / 1.10.0 (e.g. after Update to Latest Package Versions).

Fix

Replace <data>.bytes with Array(<data>). It produces the identical [UInt8], compiles against every CryptoSwift version, and doesn't depend on CryptoSwift at all (vs. switching to .byteArray, which would require CryptoSwift ≥ 1.9.0). Data.toHexString() calls that were already on Data are left untouched.

39 sites across 5 files; no behavior change.

Verification

Built OmnipodKit against CryptoSwift 1.10.0 on Xcode 26.5 → build succeeds, zero RawSpan errors. Also builds against the currently-pinned 1.7.1 (Array(Data) is long-standing API).

CryptoSwift 1.9.0 removed its `Data.bytes -> [UInt8]` extension (renamed
to `byteArray`). On the Xcode 26 SDK, `data.bytes` then resolves to
Foundation's new native `Data.bytes`, which returns a `RawSpan` -
breaking every crypto call site with errors like:

  Cannot convert value of type 'RawSpan' to expected argument type 'Array<UInt8>'
  Value of type 'RawSpan' has no member 'toHexString'

Builds pinned to CryptoSwift <= 1.8.5 are unaffected, so this only bites
users whose package resolution floats up to 1.9.0/1.10.0 (e.g. after
'Update to Latest Package Versions').

Replace `<data>.bytes` with `Array(<data>)`, which yields the same
[UInt8] and compiles against every CryptoSwift version (and doesn't
depend on CryptoSwift at all). Verified building OmnipodKit against
CryptoSwift 1.10.0 on Xcode 26.5.
@yurique

yurique commented Jun 11, 2026

Copy link
Copy Markdown

Should I close this one - #76 ?

One difference I'm seeing is that in this PR, in project.pbxproj, the minimum version is still 1.4.1 (minimumVersion = 1.4.1;)

(see: https://github.com/loopandlearn/OmnipodKit/pull/76/changes#diff-4b61108c13e1933f1c294dbd33b80a79c3a28de0baed313a06d84684c0adace3R997)

@marionbarker

Copy link
Copy Markdown
Contributor

See this testing done in PR #79

@marionbarker marionbarker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code modification was tested in PR #79.
Approve by code review and test

@marionbarker marionbarker merged commit 7090c60 into loopandlearn:loop-next-dev Jun 12, 2026
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.

4 participants