Skip to content

Split FoundationEssentials extensions from NIOFoundationCompat - #3567

Merged
Lukasa merged 3 commits into
apple:mainfrom
Cyberbeni:foundation-essentials-compat
Apr 21, 2026
Merged

Lukasa merged 3 commits into
apple:mainfrom
Cyberbeni:foundation-essentials-compat

Conversation

@Cyberbeni

@Cyberbeni Cyberbeni commented Apr 2, 2026 •

Copy link
Copy Markdown
Contributor

Split FoundationEssentials extensions from NIOFoundationCompat

Motivation:

Resolves #3038

Modifications:

Split NIOFoundationCompat into two and only import FoundationEssentials and NIOFoundationEssentialsCompat where appropriate.

Result:

ByteBuffer/Codable extensions can be used without vendoring the code or linking to Foundation.

@weissi
weissi requested review from FranzBusch and glbrntt April 21, 2026 14:47

@FranzBusch FranzBusch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks like a straight forward change to me to enable the FoundationEssentials migration across the ecosystem.

@weissi

weissi commented Apr 21, 2026

Copy link
Copy Markdown
Member

@glbrntt / @Lukasa Could I request accelerating this? This is a pretty small and good pull request.

I'm being asked (in swift-profile-recorder) to work around this because NIO doesn't seem to offer a way to use the ByteBuffer <-> Data bridge without also bringing in full Foundation :\

(https://github.com/apple/swift-profile-recorder/pull/63/changes#r3118271068)

@fabianfett fabianfett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks good to me.

@fabianfett

Copy link
Copy Markdown
Member

These are false positives, as those are readded through the @_exported dance:

32 breaking changes detected in NIOFoundationCompat:
  πŸ’” API breakage: enum ByteBufferFoundationError has been removed
  πŸ’” API breakage: enum ByteBuffer.ByteTransferStrategy has been removed
  πŸ’” API breakage: func ByteBuffer.readData(length:) has been removed
  πŸ’” API breakage: func ByteBuffer.readData(length:byteTransferStrategy:) has been removed
  πŸ’” API breakage: func ByteBuffer.getData(at:length:) has been removed
  πŸ’” API breakage: func ByteBuffer.getData(at:length:byteTransferStrategy:) has been removed
  πŸ’” API breakage: func ByteBuffer.peekData(length:byteTransferStrategy:) has been removed
  πŸ’” API breakage: func ByteBuffer.getString(at:length:encoding:) has been removed
  πŸ’” API breakage: func ByteBuffer.readString(length:encoding:) has been removed
  πŸ’” API breakage: func ByteBuffer.writeString(_:encoding:) has been removed
  πŸ’” API breakage: func ByteBuffer.setString(_:encoding:at:) has been removed
  πŸ’” API breakage: constructor ByteBuffer.init(data:) has been removed
  πŸ’” API breakage: func ByteBuffer.writeContiguousBytes(_:) has been removed
  πŸ’” API breakage: func ByteBuffer.setContiguousBytes(_:at:) has been removed
  πŸ’” API breakage: func ByteBuffer.writeData(_:) has been removed
  πŸ’” API breakage: func ByteBuffer.setData(_:at:) has been removed
  πŸ’” API breakage: func ByteBuffer.getUUIDBytes(at:) has been removed
  πŸ’” API breakage: func ByteBuffer.setUUIDBytes(_:at:) has been removed
  πŸ’” API breakage: func ByteBuffer.readUUIDBytes() has been removed
  πŸ’” API breakage: func ByteBuffer.writeUUIDBytes(_:) has been removed
  πŸ’” API breakage: func ByteBuffer.peekUUIDBytes() has been removed
  πŸ’” API breakage: func ByteBuffer.getJSONDecodable(_:decoder:at:length:) has been removed
  πŸ’” API breakage: func ByteBuffer.readJSONDecodable(_:decoder:length:) has been removed
  πŸ’” API breakage: func ByteBuffer.setJSONEncodable(_:encoder:at:) has been removed
  πŸ’” API breakage: func ByteBuffer.writeJSONEncodable(_:encoder:) has been removed
  πŸ’” API breakage: func ByteBufferAllocator.buffer(data:) has been removed
  πŸ’” API breakage: typealias ByteBufferView.Regions has been removed
  πŸ’” API breakage: var ByteBufferView.regions has been removed
  πŸ’” API breakage: constructor Data.init(buffer:byteTransferStrategy:) has been removed
  πŸ’” API breakage: func JSONDecoder.decode(_:from:) has been removed
  πŸ’” API breakage: func JSONEncoder.encode(_:into:) has been removed
  πŸ’” API breakage: func JSONEncoder.encodeAsByteBuffer(_:allocator:) has been removed

But we will need an admin (paging @Lukasa) to merge those anyway.

@Lukasa
Lukasa merged commit 3800079 into apple:main Apr 21, 2026
98 of 109 checks passed
@Cyberbeni

Copy link
Copy Markdown
Contributor Author

Cool, now only transport services is missing for me: apple/swift-nio-transport-services#251

@Cyberbeni

Copy link
Copy Markdown
Contributor Author

@Lukasa Is historicalNIOPosixDependencyRequired about import leaks? If yes then that dependency should be moved back to NIOFoundationCompat since NIOFoundationEssentialsCompat doesn't have any historical dependency on NIOPosix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

πŸ†• semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can we make NIOFoundationCompat depend on FoundationEssentials?

5 participants