Problems with Swift Playgrounds

Hello world! I was creating a playground with Swift Playgrounds, and I created a .swift files and should connect these files to ContentView(), but when I write that file name on ContentView() it tells me "Cannot find ... in scope".

Does anyone know why this error and how to fix it?

Thanks in advance from heart.

You don't have a public property in structs and classes.

You should add public property to the classes, structs and variables. The files you have created are treated as different modules by the compiler.

Hope it helps ❤️

OK. I tried this:

import SwiftUI

public struct Block: View {
    public var body: some View {
        Rectangle()
            .frame(width: 90, height: 90)
    }
}

and in the ContentView:
But now it gives me one other error.

import PlaygroundSupport
import SwiftUI

struct ContentView: View {
    var body: some View {
        Block() // ERROR: 'Block' initializer is inaccessible due to 'internal' protection level.
    }
}

PlaygroundPage.current.setLiveView(ContentView())
Problems with Swift Playgrounds
 
 
Q