Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Xcode 16 + address Swift concurrency issues #116

Merged
merged 9 commits into from
Oct 2, 2024

Conversation

jessesquires
Copy link
Owner

@jessesquires jessesquires commented Jul 2, 2024

The only issue with adopting Swift 6 right now is that apply(_:animatingDifferences:completion:) is incorrectly marked as @MainActor, which becomes an error in Swift 6.

@jessesquires jessesquires changed the title [Fixes and updates for Xcode 16 Fixes and updates for Xcode 16 + Swift 6.0 Jul 2, 2024
@jessesquires jessesquires force-pushed the xcode-16-main branch 4 times, most recently from 9ca7f41 to 1e5c224 Compare July 13, 2024 21:31
@jessesquires jessesquires force-pushed the xcode-16-main branch 2 times, most recently from 7fd1638 to 1cdcb56 Compare July 26, 2024 21:14
@jessesquires jessesquires self-assigned this Jul 27, 2024
@jessesquires jessesquires changed the title Fixes and updates for Xcode 16 + Swift 6.0 Update to Xcode 16 + address Swift concurrency issues Oct 2, 2024
@jessesquires jessesquires modified the milestone: NEXT Oct 2, 2024
@jessesquires jessesquires merged commit 8083642 into main Oct 2, 2024
4 checks passed
@jessesquires jessesquires deleted the xcode-16-main branch October 2, 2024 20:32
jessesquires added a commit that referenced this pull request Oct 14, 2024
This re-works `DiffableDataSource` to perform more operations on a
background thread — namely building the initial snapshot and searching
for items that need to be reconfigured.

In extremely large collections, performing these operations on the main
thread can produce noticeable lag.

### `Sendable` changes

This also makes `DiffableViewModel` inherit from `Sendable`, which means
this also applies to `CellViewModel`, `SupplementaryViewModel`,
`SectionViewModel`, and `CollectionViewModel`.

Early in development, I avoided doing this because I did not want to
place the burden of `Sendable` on clients. Instead, I opted to make
everything `@MainActor` (which is also a burden, in different ways).
However, that was changed in #135. After the performance improvements in
faabe72, making these types `Sendable`
is more necessary.

However, I think we can justify making all view models `Sendable`
because all the view models _should_ be stateless / immutable. If you
want to update the collection view, then you need to apply a new view
model via `update(viewModel:)` — so it's not as if you could be mutating
view model state outside of the `Driver` because those changes would not
be reflected anyway.

### Swift 6

The only issue with adopting Swift 6 right now is that
[`apply(_:animatingDifferences:completion:)`](https://developer.apple.com/documentation/uikit/uicollectionviewdiffabledatasource/3375795-apply)
is incorrectly marked as `@MainActor`, which becomes an error in Swift
6. See #116.

Otherwise, the library compiles successfully with Swift 6 and complete
concurrency checking. 🎉
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant