Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to remove a copied preview phone in Xcode 13?

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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()
    }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading