Home > Blockchain >  How to remove a copied preview phone in Xcode 13?
How to remove a copied preview phone in Xcode 13?

Time:04-04

When I click the following button on the top of a preview phone, Xcode copies the preview phone for me. So if there is only one preview phone before clicking the button, there are two afterward.

Preview Phone

My question is: How to remove the copied preview phone?

CodePudding user response:

Previews only happen because your code says they should happen. All this button really does is to modify the code that generates the preview(s). For example:

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        Group {
            ContentView()
            ContentView()
        }
    }
}

See how it says ContentView() twice? That's two previews. To remove the second preview, revert the change. For example:

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
  • Related