apple/swift-collections

SortedCollections is missing is when using fixed versions

Closed this issue · 5 comments

When using this package as a dependency with a fixed version, the SortedCollection target (and the actual directory in the Sources directory) is missing. If the main branch is used instead – everything works as expected.

Information

  • Package version: 1.1.x tags and the main branch
  • Platform version: macOS 14.6.1
  • Swift version: swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4) Target: arm64-apple-macosx14.0

Checklist

  • If possible, I've reproduced the issue using the main branch of this package.
  • I've searched for existing GitHub issues.

Steps to Reproduce

Test case 1:

  1. Create an empty Swift package (I used the executable type as a parameter)
  2. Update the Package.swift to include the Collections package with any exact version starting from 1.1.0
  3. Update the main.swift to import the SortedCollections and the print(SortedDictionary<String, String>())

Test case 2:

  1. Open any 1.1.x tag in the Github interface.
  2. Download the archive with the package source code.

Expected behavior

Test case 1:
After calling the swift run command package compiles without any errors and produces [:] as an output.
When inspecting the .build/checkouts/swift-collections/Sources directory the SortedCollections directory is present.

Test case 2:
When inspecting the Sources directory the SortedCollections directory is present.

Actual behavior

Test case 1:
Compilation error no such module 'SortedCollections'.
When inspecting the .build/checkouts/swift-collections/Sources directory the SortedCollections directory is not present.

Test case 2:
When inspecting the Sources directory the SortedCollections directory is not present.

The implementation for sorted collections is not yet ready for production use, and it isn't part of any Swift Collections release. This is very intentional -- the SortedSet and SortedDictionary API surface and implementation is experimental and unstable. These types have some known correctness issues. I do not recommend using them in their current state.

Issue #1 tracks the task of productizing and shipping these types. This will require considerable effort.

The project's current focus is on prototyping noncopyable/nonescapable container variants for Swift's Roadmap for Performance Predictability. Sorted collections isn't part of that, so it is currently on the backburner.

Oh, sorry, I initially missed that it was an experimental API. That said, it might be helpful if the README and changelog elaborated a bit more on its availability in the release. In any case, thank you so much for the clarifications and for sharing the future plans ❤️

I also ran into this issue when just desiring to do some experiments. Could it be exposed via _SortedCollections that Collections does not depend on? (Checking out locally isn't the end of the world, but ya know, lazy).

xlc commented

I don't mind to use unstable API. It is better than nothing. Besides, if people can't opt-in to use experimental API then we won't be able to provide feedbacks.