TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Solved: New xCode update - How to remove ContentView?

Forums > iOS

So, I'm having a couple issues with my xCode app screen. I'm following CodeWithChris's tutorials, but since then, xCode seems to have been updated... so now I have this body of code in my ContentView (in the tutorial its a ViewController, not ContentView)

struct ContentView: View {
    var body: some View {

        Text("Hello World!")

    }
}

I have done a bit of code before in Java, and from what I can tell, this ContentView is overriding the nice screen I made in the storyboard view controller, and putting the text "Hello World!" on the screen. So whenever I run the project or simulator, it shows me the nice screen I made in the storyboard.. and five seconds later turns to a blank screen that says "Hello World!" on it. How can I remove this, or just keep on the screen what I want to be on the screen? The videos I'm watching are not quite up to date and not clear about this. I've tried removing the Text("Hello World!") bit, but it just throws out errors. I've tried removing the whole ContentView method, but it makes everything go nuts. What do I do? Sorry if the answer is obvious and I'm not seeing it, I'm a total beginner.

Thanks in advance.

3      

hi,

if you were expecting to have, but don't have a default ViewController, then you started a project with SwiftUI selected as the User Interface, rather than Storyboards (UIKit). a SwiftUI project template has the default ContentView code and puts in an AppDelegate/SceneDelegate pair (in XCode 11 & iOS 13) to start the app with the ContentView. (it's a little different in XCode 12 & iOS 14.)

i'd recommend that you go back to square one and start over with a new project template (select User Inteface = Storyboards) and transplant whatever you've written so far to the new project.

hope that helps,

DMG

3      

That helps a ton- and it explains why I was not able to find anything on google after an hour of searching various keywords. Totally a beginners mistake to make, thanks for pointing that out! Appreciate it :)

3      

Hacking with Swift is sponsored by Blaze.

SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!

Reserve your spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.