Skip to content

swift: SwiftUI @State fails on Darwin since 6.4 (SwiftUIMacros plugin not found) #590363

Closed

Description

@kleinbem

Nixpkgs version

  • Unstable (26.11)

Describe the bug

Since Swift 6.4 (#574002), swift propagates apple-sdk_27 instead of apple-sdk_26. In the 27.0 SDK, SwiftUICore declares State as an external macro as well as the property wrapper:

@attached(accessor, names: named(init), named(get), named(set)) @attached(peer, names: prefixed(`_`), prefixed(__), prefixed(`$`)) public macro State() = #externalMacro(module: "SwiftUIMacros", type: "StateMacro")

The SwiftUIMacros plugin comes with Xcode, not with the open-source toolchain, so SwiftUI code that uses @State no longer compiles. The 26.5 SDK only has the property wrapper, so it worked before. Asking for apple-sdk_26 in the package doesn't help, since the build still picks up the propagated 27.0 SDK.

Steps to reproduce

  1. On aarch64-darwin, build a SwiftUI package that uses @State with swift/swiftpm, e.g. block-catch from block-catch: init at 0.5.1 #580909.
  2. It fails on current master and on every unstable eval since the Swift 6.4 staging-next merge.

I narrowed it down with Hydra-built nixpkgs/unstable evals (block-catch callPackage'd from #580909 at each one):

  • 57e9810e4733a7ba99f8885acf98818e81c8b4ea (Swift 6.3.3): builds, 73/73 tests pass
  • 5e7788fd2ced82eb31da7f5329b55e49dc1587c8 (Swift 6.4.0): fails
  • 54020e34612d3905b97ec1ed45953e21d0b4411a, 8c9852de0834ee201b5723da4c5fe0bd5bc0afe9 and current master: fail the same way

Expected behaviour

SwiftUI code using @State builds with nixpkgs' Swift on Darwin, like it did with 6.3.3 and the 26.5 SDK.

Relevant log output

block-catch> Sources/Catch/Views/MainView.swift:15:24: error: external macro implementation type 'SwiftUIMacros.StateMacro' could not be found for macro 'State()'; plugin for module 'SwiftUIMacros' not found
block-catch> 145: note: 'State()' declared here
block-catch> 1 | @attached(accessor, names: named(init), named(get), named(set)) @attached(peer, names: prefixed(`_`), prefixed(__), prefixed(`$`)) public macro State() = #externalMacro(module: "SwiftUIMacros", type: "StateMacro")

Additional context

The builds ran on GitHub's macOS arm64 runners with sandbox = relaxed. Claude Code (claude-fable-5-2 and claude-opus-5-5) helped me bisect this and draft the report; I reviewed it.

System metadata

Not from a local Mac: the builds ran on GitHub Actions macos arm64 runners with Nix, against the nixpkgs revisions above.

Are you using nix-darwin?

No, I am not using nix-darwin.

Notify maintainers

@reckenrode @Samasaur @stephank

I assert that this issue is relevant for Nixpkgs

Activity

  1. added
    0.kind: bug
    6.topic: darwin
    on Nov 19, 2026
  2. reckenrode commented on Nov 19, 2026

    @reckenrode
    Contributor

    It should be sufficient to add open-apple-macros to your package’s buildInputs, but it’s not working. (The documentation says depsBuildBuild, but that doesn’t work either.)

    I’m looking into why it’s not working. We already have a few packages using these macros, but they’re not using SwiftPM. They use their own build systems, which are manually injecting the correct -external-plugin-path for the macros.

  3. reckenrode commented on Nov 19, 2026

    @reckenrode
    Contributor

    I see why. I’ll comment in the respective PRs.

  4. reckenrode commented on Nov 19, 2026

    @reckenrode
    Contributor

    I was able to build Berd and Catch with the suggested changes. I opened #590486 to update the documentation.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bug6.topic: darwin

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions