Skip to content

Fix Xcode 27 linker crash by co-locating ChatView's init with its @State properties - #302

Merged
f3dm76 merged 1 commit into
exyte:mainfrom
nezhyborets:macpaw-xcode27-init-fix
Sep 19, 2026
Merged

f3dm76 merged 1 commit into
exyte:mainfrom
nezhyborets:macpaw-xcode27-init-fix

Conversation

@nezhyborets

Copy link
Copy Markdown
Contributor

Summary

Building any app that uses ChatView currently fails to link on Xcode 27 (tested on 27.0 RC, build 27A266a) with errors like:

Undefined symbols for architecture arm64:
  "variable initialization expression of ExyteChat.ChatView.(__chatSize in ...) : SwiftUI.LazyState<__C.CGSize>", referenced from: ...
  "variable initialization expression of ExyteChat.ChatView.(__cellFrames in ...) : SwiftUI.LazyState<[Swift.String : __C.CGRect]>", referenced from: ...
  ... (one per @State property on ChatView)
ld: symbol(s) not found for architecture arm64

This is a Swift 6.4/Xcode 27 compiler bug (swiftlang/swift#91700): the compiler fails to link a @State property's default-value symbol when the type's initializer is declared in a different file than the property. ChatView's @State properties (chatSize, cellFrames, isShowingMenu, giphyConfigured, pendingScrollTo, isScrolledToBottom, selectedGiphyMedia, tableContentHeight) are declared in ChatView.swift, while the designated public init(messages:...) is declared in ChatBuilderParameters.swift.

Fix

Moves the designated initializer from ChatBuilderParameters.swift into ChatView.swift, alongside the @State declarations it doesn't explicitly assign. No behavior change — just relocating one extension ChatView { public init(...) } block into the same file as the properties it's implicitly initializing. Everything else in ChatBuilderParameters.swift (the builder parameter structs, typealiases) stays put, since those don't have this issue.

Confirmed by reproducing the failure against main, applying this change, and rebuilding clean with zero linker errors.

Test plan

  • swift build for the package
  • Full clean build of a consumer app (MacPaw/OpenAI's Demo app) against this branch on Xcode 27, previously failing with the linker error above, now succeeds
  • Installed and launched the consumer app in the iOS Simulator to confirm no regression at runtime

 properties

Xcode 27's Swift 6.4 compiler fails to link the default-value symbol for a
@State property when the type's initializer is declared in a different file
(swiftlang/swift#91700). ChatView's designated init lived in
ChatBuilderParameters.swift while its @State properties are declared in
ChatView.swift, so any app linking against ChatView failed with:

  Undefined symbols for architecture arm64:
    "variable initialization expression of ExyteChat.ChatView.(__chatSize ...)"

Moving the init into ChatView.swift (same file as the @State declarations)
resolves it, per the workaround described in the upstream issue.
nezhyborets added a commit to MacPaw/OpenAI that referenced this pull request Sep 18, 2026
Demo/Demo.xcodeproj fails to link on Xcode 27 because ExyteChat's ChatView
declares its @State properties in one file and its designated initializer
in another, which trips a Swift 6.4/Xcode 27 compiler bug
(swiftlang/swift#91700): the linker can't find the "variable initialization
expression" symbol for each @State property's default value.

- Bump exyte/Chat from 2.5.7 to 3.3.0, which required three follow-up fixes:
  - drop .messageUseMarkdown(true): ChatView 3.x always applies markdown
    attributes to message text now, the modifier no longer exists
  - drop Hashable from ResponsesStore.ConversationTurn: ExyteChat.Message
    lost Hashable in 3.x (Equatable only), and the conformance was unused
  - pin exyte/AnchoredPopup to >=1.2.2 explicitly: MediaPicker 3.4.x calls
    PopupParameters.displayMode(_:), added in AnchoredPopup 1.2.0, but
    MediaPicker's manifest still understates its own requirement as
    `from: "1.1.3"`, so SwiftPM could otherwise resolve an incompatible
    1.1.3 and fail to build
- Point Chat at a fork branch (nezhyborets/Chat@macpaw-xcode27-init-fix)
  that moves ChatView's designated init into the same file as its @State
  declarations, working around the Xcode 27 linker bug. Upstreamed as
  exyte/Chat#302. Revert to the tagged release once that lands and a fixed
  Xcode toolchain ships.

Verified with a full clean build (not incremental) and by installing and
launching Demo in the iOS Simulator.

Fixes #444

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@f3dm76
f3dm76 merged commit 60ff30b into exyte:main Sep 19, 2026
@f3dm76

f3dm76 commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

Thank you @nezhyborets, have a wonderful day!

nezhyborets added a commit to MacPaw/OpenAI that referenced this pull request Sep 19, 2026
exyte/Chat#302 merged and shipped in 3.3.3, so the fork branch used as a
stopgap is no longer needed. Point back at the upstream package.

Verified with a full clean build of Demo on Xcode 27.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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