Closed ynnckcmprnl closed 6 months ago
Could you try to set a name?
#Preview("Redacted") {
VStack {
Redacted(.horizontal)
Redacted(.vertical)
}
}
Could you try to set a name?
That isn't picked up either, the function name remains unchanged.
Could you try to set a name?
That isn't picked up either, the function name remains unchanged.
I can't reproduce it. Can you try to clear the build?
I can't reproduce it. Can you try to clear the build?
Indeed, I was too quick to judge, specifying a preview name is getting picked up! I think that's an acceptable method, otherwise Prefire would have to do some magic with the contents of the preview and the filename to guess the correct name.
Please consider adding this example to the Readme. I had the same problem, and this issue helped me a lot, but it might not be easily noticeable.
@davidnext I think a tweak can be made and use the filename as the main identifier. Then the name will be stable and you won't need to specify a custom name every time. Pretty simple modification, I'll try to upload it in the next day.
Sounds great! Looking forward @BarredEwe
Context 🕵️♀️
I'm integrating Prefire 2.2.1 in a SwiftUI Design System package.
What 🌱
A common approach in our previews is the use of a
VStack
orHStack
to display multiple instantiations of a view. This comes in handy for the (small) components of our design system, being able to see several variations at once.Example:
This setup causes Prefire to use the same function name (
test_VStack_Preview
andtest_HStack_Preview
) for every generated preview test which results in invalid redeclaration compile errors.Setting a custom
previewDisplayName
orpreviewUserStory
isn't picked up either by Prefire, which could have been a workaround although I'd rather not have to specify a custom name/story.