Xcode 14 Previews: Groups on the same page?

In Xcode 13, I can use groups to preview my views in different states:

In Xcode 14 (Beta 1) groups are now rendered as tabs, making it way more difficult to verify all states after changes:

Is there a way to toggle back to the old behavior - or is there any other container view that would be more suitable?

Post not yet marked as solved Up vote post of paxos Down vote post of paxos
3.8k views

Replies

I am seeing this same behavior and am unable to find a solution.

Happy to dupe or report -- is there an existing bug number for this?

Steps to duplicate:

Expected behavior: I've attached the (a) dysfunctional and also (b) expected behavior below...

  • Filed in Feedback Assistant: FB10319229

Add a Comment

I feel the same pain, Maybe some intelligent person has decided we can't view two previews at the same time anymore.

Also seeing this and hoping for a resolution! It's very inconvenient.

+1 to this issue. It's a huge step back.

It's obviously not the same, but a quick trick could be to use a VStack to render the views. Doing so you can easily space them.

Additionally, you can create a PreviewContainer based on VStack which you can use to give a name to the preview similarly as previewDisplayName does.

struct PreviewContainer<Content: View>: View {

  @ViewBuilder let content: () -> Content

  var body: some View {
    VStack(spacing: 16) {
      content()
    }
    .background(Color.white)
    .previewLayout(.sizeThatFits)
    .padding()
    .background(Color.gray)
    .cornerRadius(16)
    .background(Color.clear)
  }
}

struct PreviewCase<Content: View>: View {

  let previewName: String
  @ViewBuilder let content: () -> Content

  var body: some View {
    VStack(spacing: 16) {
      Text(previewName)
      content()
    }
  }
}

struct MyView_Previews: PreviewProvider {
  static var previews: some View {
    PreviewContainer {
      PreviewCase(previewName: "Case 1") {
        Capsule()
          .frame(height: 56)
      }
      PreviewCase(previewName: "Case 2") {
        Capsule()
          .frame(height: 80)
      }
    }
  }
}

And you will obtain something like this

You can iterate this as much as you want to make your perfect Preview rendering experience. Hope this helps 😉