ContentView's Canvas disappeared

Hello all!

My Xcode Version 12.0 (12A7209) and MacOS Catalina 10.15.6 (MacBook Pro Retina, 13-inch, Late 2013)

ContentView.swift's canvas is invisible although it is open in editor. I checked all options and they all ok.

What is problem here? is it bug or am I missing something?
Howdy,

Sorry to hear your canvas is not behaving the way you are expecting. In the version of Xcode you are running the visibility of the canvas is gated on the presence of an import SwiftUI in your .swift file. If that does not fix the issue, then would you be able to share what the contents of your swift file is?

Note, this behavior has changed in the 12.2 beta which you can read more about here:
https://developer.apple.com/documentation/xcode-release-notes/xcode-12_2-beta-release-notes

The previews canvas now automatically shows and hides based on the presence of a PreviewProvider in the file being edited. (67083504, 67693254)




//
// ContentView.swift
// BaseArios2
//
// Created by Sercan Demirtaş on 23.09.2020.
//

  import SwiftUI
  import RealityKit
  

  struct ContentView : View {
    var models: [String] = {
       
      let filemanager = FileManager.default
       
      guard let path = Bundle.main.resourcePath, let files = try?
        filemanager.contentsOfDirectory(atPath:path) else
          { return[]
        }
      var avaliableModels: [String] = []
      for filename in files where filename.hasSuffix("usdz") {
        let modelName = filename.replacingOccurrences(of: ".usdz", with: "")
        avaliableModels.append(modelName)
      }
       
      return avaliableModels
    }()
     
    var body: some View {
      ZStack(alignment: .bottom) {
        ARViewContainer()
         
        ModelPickerView(models: self.models)
         
        PlacementButtonsView()
      }
    }
  }

  struct ARViewContainer: UIViewRepresentable {
     
    func makeUIView(context: Context) -> ARView {
       
      let arView = ARView(frame: .zero)
       
      return arView
       
    }
     
    func updateUIView( uiView: ARView, context: Context) {}
     
  }

  struct ModelPickerView: View {
    var models: [String]
     
    var body: some View {
      ScrollView(.horizontal, showsIndicators: false) {
        HStack(spacing: 20) {
          ForEach(0 ..<
            self.models.count) { index in
            Button(action: {
              print("DEBUG: selected model with name: \(self.models[index])")
            }) {
              Image(uiImage: UIImage(named: self.models[index])!)
                .resizable()
                .frame(height: 60)
                .aspectRatio(1/1,contentMode: .fit)
                .background(Color.white)
                .cornerRadius(12)

               }
                 .buttonStyle (PlainButtonStyle())
             
             }
         }
      }
      .padding(15)
      .background(Color.black.opacity(0.5))
  }
    }

  struct PlacementButtonsView: View {
    var body: some View {
      HStack {
        //Cancel Button
        Button(action: {
          print("DEBUG: model placement canceled.")
        }) {
          Image(systemName: "xmark")
          .frame(width: 60, height: 60)
          .font(.title)
          .background(Color.white.opacity(0.75))
          .cornerRadius(30)
          .padding(20)
           
        }
         
        //Confirm Button
        Button(action: {
          print("DEBUG: model placement confirmed.")
        }) {
          Image(systemName: "checkmark")
          .frame(width: 60, height: 60)
          .font(.title)
          .background(Color.white.opacity(0.65))
          .cornerRadius(30)
          .padding(20)
           
        }
      }
    }
  }
     
  #if DEBUG
  struct ContentView
Previews : PreviewProvider {
    static var previews: some View {
      ContentView()
    }
  }
  #endif

     
 

ContentView's Canvas disappeared
 
 
Q