I'm new to iOS Development. This is my second app in the class and I've followed along the tutorial and I cannot figure out what is wrong here.
I created a new SwiftUI file and named it "NewTaskView" and now I'm trying to use the struct "NewTaskView in a sheet view. Why is Xcode saying "Use of unresolved identifier 'NewTaskView', when it has been created but in a separate SwiftUI file?
Here are my code snippets and a screenshot of the error
import SwiftUI
struct NewTaskView: View {
@State var text = ""
var body: some View {
TextField("Task Name", text: $text)
}
}
struct NewTaskView_Previews: PreviewProvider {
static var previews: some View {
NewTaskView()
}
}
import SwiftUI
struct ContentView: View {
var taskStore: TaskStore
@State var modalIsPresented = false
var body: some View {
NavigationView {
List(taskStore.tasks) { task in
Text(task.name)
}
.navigationBarTitle("Tasks")
.navigationBarItems(
trailing:
Button(action: {
self.modalIsPresented = true
}) {
Image(systemName: "plus")
}
)
}.sheet(isPresented: $modalIsPresented) {
NewTaskView()
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView(taskStore: TaskStore() )
}
}
Answer:
Bug in xcode 11.7 works fine in xcode 12