Learn Courses My Dashboard

Xcode 13 preview problem

Hello everyone, this is my first time posting here and I just started my coding journey with no previous programming experience. Am on the 14 day coding challenge, lesson 4 challenge, and xcode is not letting me preview the UI without opening the simulator. Also there is some error called “Thread 1: Sigterm”. I have already looked up this problem elsewhere including Stack Overflow and places like that as well as tried Command Option P while in xcode and nothing is working. Does anyone have any suggestions?

@pauly1

Hi Paul,

Welcome to the community.

Can you copy your code and paste it as text in a reply.

Place 3 back-ticks ``` on the line above your code and 3 back-ticks ``` on the line below your code so that it is formatted nicely in the reply. The back-tick character is located on the same keyboard key as the tilde character ~ (below the Esc key).

This also makes it easier for anyone assisting as they can copy the code and carry out some testing.

Hi Chris, sure I can paste the code here. Not sure how it will help since this seems to be a problem with xcode itself.

import SwiftUI

struct ContentView: View {
    var body: some View {
        VStack{
            ZStack{
            Image("london")
                    .resizable()
                    .aspectRatio(contentMode:.fit)
                    
                VStack{
            Text("Big Ben")
                    .font(.largeTitle)
                    .foregroundColor(Color.white)
                    .background(Color.black
                        .opacity(0.60))
                    Text("London")
                        .foregroundColor(Color.white)
                        .background(Color.black
                            .opacity(0.60))
                }
                
            }
            ZStack {
            Image("toronto")
                    .resizable()
                    .aspectRatio(contentMode:.fit)
                VStack{
            Text("CN Tower")
                    .font(.largeTitle)
                    .foregroundColor(Color.white)
                    .background(Color.black
                                .opacity(0.60))
                    Text("Toronto")
                        .foregroundColor(Color.white)
                        .background(Color.black .opacity(0.60))
                }
            }
        }
        
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
@main
struct PaulCWCLesson4ChallengeApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

The @main is where I am seeing the Thread 1: signal SIGTERM error.

The reason I suggested posting your code is just to be sure that there was not a code issue.

Have you tried cleaning the project? Do that either from the Xcode menu Product > Clean Build Folder or use the keyboard combination Shift + Command + K

If that does not work and you still have issues then copy the code from within ContentView, create a new project and paste the code in that new project. You will also need to add the two images to your assets.

I tried all of your suggestions and then did some internet searching. One thing that seems to have changed from xcode 12 to xcode 13 is that in order to open and close the preview canvas instead of using the simulator, one needs to press command + option + return. In xcode 12, it was command + option + p. Still not sure where the Thread 1: signal SIGTERM error was coming from, but after copying my project from contentview, creating a new project, then pasting it in the new project, that error seems to have gone away.

The fact that the error has gone away is reason enough to assume that the previous App was corrupted in some way. Good to hear you have it working now. Xcode can be frustrating sometimes.