EmergeTools / SnapshotPreviews-iOS

Automatic snapshots from Xcode previews
MIT License
193 stars 6 forks source link

Use of #Preview's: Inability to exclude snapshots #119

Closed cprince-foreflight closed 2 months ago

cprince-foreflight commented 2 months ago

As I've discussed with @noahsmartin in our company Slack channel, I understand that SwiftUI #Preview's aren't fully supported in terms of naming. E.g., you can't use a #Preview and expect to exclude that snapshot (e.g., if it's failing). For example, when doing Local Snapshot Generation its name comes up as something like:

test://com.apple.xcode/FFM/Automated%20UI%20Tests/MyPreviewTest/DiscoverUI.$s10DiscoverUI33_B2E12565CA02B533B60DA0669E69BC1BLl7PreviewfMf15PreviewRegistryfMu-0-81

which can't be used in the excludedSnapshotPreviews.

With this in mind, I'm changing our app's codebase back to using PreviewProviders, which don't suffer the above issue.

The reason I'm raising an issue is because I'm getting pushback internally from our develepers about not being able to use #Previews. I'll see if I can get some of them to chime in with their thoughts on this issue.

PS. I also wonder what the name for a #Preview looks like in screenshots uploaded to the Emergetools backend. Is it mangled like in the above example?

swolf-foreflight commented 2 months ago

My biggest concern with giving up #Preview is the inability to use UIKit directly into Live Previews, without requiring SwiftUI. As well as giving up any future features Apple provides with the Macro, I have practically been exclusively using them for a year now. Not sure if it outweighs switching tools, but it's a limitation to be aware of.

Wrapping a UIViewController into UIViewControllerRepresentable may change the behavior of the UIViewController, at least I have seen this when using UIViewControllerRepresentable in the past. I personally am going to avoid doing that, especially if the UIViewController has no need to be ported to SwiftUI.

noahsmartin commented 2 months ago

Names in the emerge UI aren't mangled like this, we support #Preview for all the emerge-generated snapshots so they should be able to be used as-is without any changes. We don't support excluding them so they would all need to not be crashing. We'll look into adding support for excluding them, thanks for opening the issue!

cprince-foreflight commented 2 months ago

Thanks for the note, @noahsmartin. By emerge UI, I think you mean your web-based system, right?

While I'm obviously just gaining experience with your systems, I see our use flow looking like: 1) Use the Local Snapshot Generation to get our previews working, and adding any excludes into first the Swift PreviewTest excludedSnapshotPreviews, then 2) Building our Debug xarchive or .ipa and uploading it to your backend, along with a emerge_config.yaml with excludes converted from the excludedSnapshotPreviews.

So, with this, it would be necessary for us to have name-able and excludable previews in the Local Snapshot Generation. I.e., the lack of #Preview usage for excluding is an issue.

noahsmartin commented 2 months ago

Yes that makes sense!