Skip to content

Update TransactionState.swift - build fix for Xcode 26 toolchain #194

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

majda107
Copy link

@majda107 majda107 commented Jun 29, 2025

Pull Request Type

  • Bug fix
  • New feature
  • Refactoring
  • Documentation update
  • Chore

Description

As the new Xcode 26 uses a newer toolchain, it introduces stricter type inference that cannot be disabled (this stricter inference applies to both Swift 5 and Swift 6, and to my knowledge, cannot be bypassed using any compiler flag).

This stricter behavior causes a severe build error for which I couldn’t find any compilation workaround. For reference, I have tried several compilation flags and custom Swiftly toolchains, but the issue lies somewhere deep in the Xcode 26 built-in toolchain.

The fix has been tested on Xcode 26 beta 2 and will most likely be required for the upcoming stable release as well.

Motivation

The motivation for this fix was to ensure that projects written in Swift 5 / Swift 6, which currently build successfully in Xcode 18, also build cleanly in newer versions of Xcode 26.

Please take a look and consider merging this fix — or suggest an alternative solution — as soon as possible, since many users will likely want to use the library with Xcode 26.

Issue, fix, and the impact on existing code

The issue lies in assigning the body closure to a member with a slightly different type. The fix wraps the body closure in another closure that calls the original, ensuring proper type alignment.

This change should not have any significant effect on the existing code. However, please verify this — especially if the change interacts with the @mainactor annotation in a non-obvious way.

I'm not entirely sure if this is the best way to resolve the issue — it may be possible to adjust the member's type instead. However, as I'm not deeply familiar with the project's domain, I'm leaving that decision to the author.

Personally, I believe this closure assignment was more likely an oversight or leftover code that happened to compile due to the more permissive type inference in the Xcode 18 (or earlier) toolchain, rather than a deliberate design choice.

As Xcode 26 has stricter type inference, the body closure needs to be re-wrapped in another closure to ensure type inference. Tested on Xcode 26 beta 2.
@kntkymt
Copy link
Contributor

kntkymt commented Jul 7, 2025

@majda107 Hi, I'm not owner of this repository but could you try it again with latest release/6.2 toolchain? I tried it on the 6.2 July 4, 2025 toolchain and compilation has been successfully passed.

https://www.swift.org/install/macos/

it introduces stricter type inference

actually this was not a new behavior of type inference, but a bug of the swift compiler. Since the fix has been merged a few weeks ago, the fix should be included in the latest 6.2 toolchain.
(plus I believe the fix will be included in the toolchain of Xcode 26.0 beta 3.)

ref:

swiftlang/swift#82397
swiftlang/swift#82430

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.

2 participants