@Table Draft initializer in #Preview #142
Replies: 1 comment
-
Hi @jacksonarich,
It definitely is macro-related, but it may be more of an Xcode bug with import SwiftUI
@TaskLocal var count = 0
#Preview {
$count.withValue(0) { // 🛑
Text("\(count)")
}
} Another work around is to just use We have filed a feedback about this issue, and we have asked others that bring up this problem to dupe the feedback. It's the only way to get it fixed someday in the future. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When I compile this code:
...I get this compile error:
"Missing argument for parameter #1 in call."
The error stems from the use of the Draft initializer inside the Preview macro. If I move the declaration ofx
out of the #Preview it compiles normally.I thought perhaps it was related to the macro-declared Draft type being initialized inside another macro, but it compiles normally inside a swift-testing #expect or #require statement.
I tried importing the other libraries like StructuredQueriesCore just to see if there's a piece I'm missing, but that didn't help any either.
There is a workaround where you declare the item outside the #Preview and then reference it from inside:
This compiles normally, but obviously it's just extra boilerplate. Has anyone else seen this same issue?
Beta Was this translation helpful? Give feedback.
All reactions