I am trying to use multiple files in SwiftUI playground. I added some code in a separate file in sources. I just want the sheet view to appear when the button is tapped. Even though I have made the struct public but I still get the error as " SecondView initializer is inaccessible due to internal protection level "
Here's the code:
struct ContentView: View {
@State private var showingScene = false
var body: some View {
Button(action: {
self.showingScene.toggle()
}, label: {
Text("Button")
})
.sheet(isPresented: $showingScene, content: {
SecondView()
})
}
}
//The code in source file
import SwiftUI
public struct SecondView: View{
public var body: some View {
Text("Second View")
}
}