Skip to content

MistDemoApp fails to build: NoteEditView/RecordDetailView have no accessible initializers (Swift 6.3) #419

Closed

Description

@leogdion

Summary

The MistDemoApp target in Examples/MistDemo fails to compile. This is pre-existing on v1.0.0-beta.3 (not introduced by any in-flight feature branch) and reproduces on every branch based on it. It surfaced with the Swift 6.3.2 toolchain; it may not appear on older toolchains, which is likely why CI hasn't flagged it.

MistDemoApp is a separate SwiftPM product from MistDemoKit, so MistDemoKit/MistDemoTests still build and test fine. But a plain swift build / swift test from Examples/MistDemo builds the whole package graph and therefore fails on MistDemoApp.

Environment

  • Apple Swift 6.3.2 (swift-6.3.2-RELEASE), target arm64-apple-macosx28.0 (macOS 26/Darwin 27)
  • Examples/MistDemo package, target MistDemoApp

Errors (clean build of the MistDemoApp target)

Sources/MistDemoApp/Views/QueryView.swift:52:9:  error: 'RecordDetailView' cannot be constructed because it has no accessible initializers
Sources/MistDemoApp/Views/QueryView.swift:69:9:  error: 'NoteEditView' cannot be constructed because it has no accessible initializers
Sources/MistDemoApp/Views/QueryView.swift:69:29: error: cannot infer contextual base in reference to member 'create'
Sources/MistDemoApp/Views/RecordDetailView.swift:78:9:  error: 'NoteEditView' cannot be constructed because it has no accessible initializers
Sources/MistDemoApp/Views/RecordDetailView.swift:78:29: error: cannot infer contextual base in reference to member 'edit'

The cannot infer contextual base in reference to member 'create'/'edit' errors are cascades: because NoteEditView(...) can't be constructed, the compiler can't infer the Mode type for the .create / .edit(note) argument.

Root cause

Both views declare non-private stored properties and @State private var stored properties:

Views/NoteEditView.swift

internal struct NoteEditView: View {
  internal enum Mode { case create; case edit(Note) }
  internal let mode: Mode
  internal let onSaved: (Note) -> Void
  @Environment(CloudKitStore.self) private var service
  @State private var title: String = ""
  @State private var indexText: String = "0"
  // …several more @State private var…
}

Views/RecordDetailView.swift

internal struct RecordDetailView: View {
  @State internal var note: Note
  internal let onChange: () -> Void
  @State private var showEditSheet = false
  // …several more @State private var…
}

Swift derives the access level of the synthesized memberwise initializer from the most restrictive stored property. The @State private var members drop the synthesized init to private, so it is only visible within the same file. NoteEditView is constructed from QueryView.swift and RecordDetailView.swift, and RecordDetailView from QueryView.swift — different files — hence "no accessible initializers". (This is consistent with the repo's explicit-ACL policy: these views should be declaring their inits explicitly.)

Call sites for reference:

  • QueryView.swift:52 RecordDetailView(note: note, onChange: { … })
  • QueryView.swift:69 NoteEditView(mode: .create) { _ in … }
  • RecordDetailView.swift:78 NoteEditView(mode: .edit(note)) { updated in … }

Proposed fix

Add an explicit internal init to each view exposing only the non-@State inputs (the @State vars keep their in-line defaults). Mirror the existing pattern in Views/CompositionDisclosure.swift:75.

NoteEditView (plain let properties → direct assignment):

internal init(mode: Mode, onSaved: @escaping (Note) -> Void) {
  self.mode = mode
  self.onSaved = onSaved
}

RecordDetailView (note is @State → initialize the backing store):

internal init(note: Note, onChange: @escaping () -> Void) {
  self._note = State(initialValue: note)
  self.onChange = onChange
}

Check the other MistDemoApp views for the same pattern (any internal/public view with @State private var members that is constructed from another file) and give them explicit inits too.

Reproduce

cd Examples/MistDemo
swift package clean
swift build --target MistDemoApp   # fails with the errors above

Verify the fix

cd Examples/MistDemo
swift build            # whole package, including MistDemoApp
swift build --target MistDemoApp
swift test             # should now build & run without removing the App target

Notes

  • Not caused by the current feature branches — git diff origin/v1.0.0-beta.3 <branch> -- Examples/MistDemo/Sources/MistDemoApp/ is empty for refactor/cyclomatic-complexity-encoding, fix/fieldvalue-timestamp, and feature/openapi-request-options.
  • Because this blocks a full swift test, unrelated MistDemo test work has been verified by building MistDemoKit/MistDemoTests directly (they don't depend on MistDemoApp).

Activity

  1. added this to the v1.0.0-beta.4 milestone on Aug 20, 2026
  2. leogdion commented on Aug 20, 2026

    @leogdion
    MemberAuthor

    Verified on v1.0.0-beta.4 (d295c30): both explicit initializers proposed here are already present.

    • Examples/MistDemo/Sources/MistDemoApp/Views/NoteEditView.swift:150 — internal init(mode:onSaved:)
    • Examples/MistDemo/Sources/MistDemoApp/Views/RecordDetailView.swift:149 — internal init(note:onChange:) (initializes the _note backing store, as proposed)

    git log attributes both to 5a58120 ("v1.0.0 beta.3", #408), so this landed before the beta.4 branch was cut. This matches the follow-up note in #424.

    Remaining to close: a swift build --target MistDemoApp on macOS with Swift 6.3.2 to confirm the build actually succeeds — not reproducible on Linux (no SwiftUI). No further code change appears needed.

    🤖 Generated with Claude Code

  3. leogdion commented on Aug 20, 2026

    @leogdion
    MemberAuthor

    Ran the missing verification step on macOS.

    $ swift --version
    Apple Swift version 6.3.2 (swift-6.3.2-RELEASE)
    Target: arm64-apple-macosx28.0
    
    $ cd Examples/MistDemo && swift build --target MistDemoApp
    ...
    [1424/1424] Compiling MistDemoApp ZoneListView.swift
    Build of target: 'MistDemoApp' complete! (46.28s)
    

    Built against v1.0.0-beta.4 @ d295c30 — the exact toolchain and target triple this issue reports against (Swift 6.3.2, arm64-apple-macosx28.0). None of the five reported errors reproduce; the build succeeds.

    Only warnings remain, and they are unrelated to this issue: CKShare.Metadata.rootRecordID/rootRecord deprecated in macOS 13 (Services/CloudKitStore+Records.swift:114). Worth a separate ticket if you want those cleaned up, but they do not block the build.

    This issue is resolved by 5a58120 and can be closed.

    🤖 Generated with Claude Code

  4. added a commit that references this issue on Aug 20, 2026
  5. leogdion commented on Aug 20, 2026

    @leogdion
    MemberAuthor

    One unrelated finding from the verification build

    The swift build --target MistDemoApp run above succeeded, but emitted deprecation warnings that are not related to this issue and will outlive it:

    Examples/MistDemo/Sources/MistDemoApp/Services/CloudKitStore+Records.swift:114:32:
      warning: 'rootRecordID' was deprecated in macOS 13.0
    Examples/MistDemo/Sources/MistDemoApp/Services/CloudKitStore+Records.swift:115:
      warning: 'rootRecord' was deprecated in macOS 13.0
    

    Both are CKShare.Metadata members deprecated in macOS 13. They don't block the build and are out of scope here, but they're the kind of thing that becomes a hard error on a future toolchain — the same way this issue's own breakage only surfaced on Swift 6.3.2.

    Not opening a separate issue unless you want one; recording it here so it's discoverable when someone next touches CloudKitStore+Records.swift. Say the word and I'll file it properly.

    🤖 Generated with Claude Code

  6. leogdion commented on Aug 28, 2026

    @leogdion
    MemberAuthor

    Fixed by #420, merged into v1.0.0-beta.3 and present in v1.0.0-beta.4. NoteEditView and RecordDetailView both carry explicit internal inits; verified in the branch tree.

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions