Skip to content

XCode 16 throws error message ion Defaults code #190

Open
@sarensw

Description

@sarensw

Since updating to XCode 16, the following error is thrown in the Defaults package: "Accessing StateObject's object without being installed on a View. This will create a new instance each time."

image

I'm using the package in one view only:

public let extensionDefaults = UserDefaults(suiteName: "...")!

extension Defaults.Keys {
  public static let isBypass = Key<Bool>("isBypass", default: false, suite: extensionDefaults)
  public static let deviceID = Key<String>("deviceID", default: noneDeviceID, suite: extensionDefaults)
}

struct TabSettingsView: View {
    ...
    @Default(.deviceID) var deviceID: String
    @Default(.isBypass) var isBypass: Bool
    ...
}

Am I using it wrong? Before, in XCode 15, this error did not show up. And I'm using the latest main branch commit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions