Learn Courses My Dashboard

Adding RootView for SwiftUi

I am going through the youtube videos and am looking how to switch from Content View to Root View. In the video, it just says he renamed it. When I renamed it, I get the “Cannot find ‘Content View’ in Scope” error and the canvas will not show up. If I try to continue with the Content View, and input the following code, it says “Cannot find type “Tabs” in Scope”.

I have tried to search around both in XCode and Google to not avail…

Thanks!

Capitalize the s in State. @State.

For snippets, GitHubs your friend. For me, I can assume you made a custom bar, but how are you connecting that bar to content? Chris made a vid recently on this topic.

Thanks,

That is the video I was following. In the beginning he says that he already renamed everything to the RootView, so I tried to rename and it did not work… Not sure if there are specific settings for this?

did you change the swiftui_ChatApp to RootView() as well?

ignore my struct name. that was for a different app in CWC+

struct CitySightsApp: App {
    var body: some Scene {
        WindowGroup {
            LaunchView()  -- Change this
        }
    }
}

@tp3

When you perform a rename of something (it can be any object), right click on the name and from the menu that pops up, select Refactor > Rename

Xcode will search for every occurrence of that name in your code and by changing the one you initially selected you will see that change take effect throughout. It reduces the chances of missing anything.

If it is the name of a .swift file like ContentView, for example, you will see that the filename is also included and where it finds that same name in a comment, it will list that as a possible change but you have to hover the cursor over it till you see a + symbol appear, then tap that + so that it is included.

That said, there have been instances where I have had to restart Xcode since it wasn’t able to resolve what should be been the obvious. If you have been using Xcode for some hours there is a chance that it’s getting a little messy in memory and you can generally tell when it isn’t doing what you expected or throws up peculiar errors.

Welcome to the community! As mentioned, note Swift is a type safe language and casing matters!

When things are uppercase / lowercase be sure to type it exactly, variables as name and Name are 2 different things