|
Hello folks 👋 , I've been trying to make the new This is the sample code I'm working with: import Dependencies
import DependenciesMacros
import SwiftUI
@DependencyClient
struct APIClient {
var fetch: () -> Data = { .init() }
}
extension DependencyValues {
@DependencyEntry
var apiClient: APIClient = .init()
}
// This would potential be in a separate module
extension APIClient: DependencyKey {
static var liveValue = Self {
"HELLO".data(using: .utf8)!
}
}When I unwrap the macro, it give me the following code: extension DependencyValues {
@DependencyEntry
var apiClient: APIClient = .init()
{
get {
self[__Key_apiClient.self]
}
set {
self[__Key_apiClient.self] = newValue
}
}
private enum __Key_apiClient: Dependencies.TestDependencyKey {
typealias Value = APIClient
static var testValue: Value {
.init()
}
}
}So I'm guessing the issue is that I should be conforming Thanks for your help! |
Replies: 1 comment 2 replies
|
Hi @bruno-mfw, you are right that this isn't well supported right now because the underlying key isn't publicized by the macro. You will need to continue defining the |
Hi @bruno-mfw, we just pushed #447 to explore this. Wanna give it a spin and let us know if it would work for you?