davidsteppenbeck / ObservableUserDefault

A Swift macro that adds accessor blocks to properties in `Observable` classes that read and write values in `UserDefaults`.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: '@ObservableUserDefault' unable to extract the required values from the argument

DePasqualeOrg opened this issue · comments

I'm trying to use this library based on the examples provided, but I get the following error:

// Error: '@ObservableUserDefault' unable to extract the required values from the argument
@ObservableUserDefault(.init(key: "systemPrompt", defaultValue: "You are a helpful assistant.", store: UserDefaults(suiteName: "\(appGroupIdentifier).settings")!))
@ObservationIgnored
var systemPrompt: String

The solution is to set a static property on UserDefaults and use that in store:

extension UserDefaults {
  static let settings = UserDefaults(suiteName: "\(appGroupIdentifier).settings")!
}