sindresorhus / sindresorhus/Defaults
XCode 16 throws error message ion Defaults code
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 2.5k
- Forks
- 163
- PR merge metrics
- No merged PRs in 30d
Description
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."
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the warning in the shown TabSettingsView with Xcode 16, focusing on the @Default(.deviceID) and @Default(.isBypass) usage and the Defaults package's latest main branch. Done means determining whether the example uses the package incorrectly or the package needs a compatibility fix, with the result supported by a reproducible case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100