Live Preview Window - Show/Hide?

Hi,

I have been working through some of the SwiftUI tutorials (I really like it so far). Today I was editing a source file and I decided to widen the window a bit. I dragged too far to the right and wound up hiding the Preview. I cannot find any menu item, preference, etc. that allows you to show/hide the Preview. I'd like to get it back but have no idea how. I tried deleting some Xcode preferences but that did not help. I appreciate any advice. This is for Xcode 12.1.
Post not yet marked as solved Up vote post of PilotSteve Down vote post of PilotSteve
37k views
  • Isn't it great how the text in the pane itself refers to it as "preview," but nothing else does?

Add a Comment

Replies

Update: Found the solution. In the "Adjust Editor Options" popup menu I had to select "Canvas". Apologies for asking too quickly, but I thought I had tried everything.
  • Had the same problem today haha. Thank you!

  • I am still new to xcode. but where is Canvas? For now I only depended on the keystroke.

  • This worked for me! Thank you!

Add a Comment
Xcode Editor Menu has a Canvas option as well to toggle on or off.
There's a quick-key stroke as well: Option + Command + Enter
Post not yet marked as solved Up vote reply of jhb Down vote reply of jhb
Add a Comment

[Xcode 12.4, Catalina 10.15.6]

Note, whilst the above are the actions you use to get the view back, you must actually have a PreviewProvider in your view's source (at the bottom of the page by default). If you commented it out or deleted this struct, pressing the above keys does nothing.

struct NavigationPrimary_Previews: PreviewProvider {
  static var previews: some View {
    NavigationPrimary(selectedLandmark: .constant(landmarkData[0]))
      .environmentObject(UserData())
  }
}

Thank you for posting this and the answer.