Hi! I have a Cloud Firestore database set up and I am trying to make a SwiftUI view which grabs data from houseId(a key in the database) and puts it on a label. When I try, it says Type 'Void' cannot conform to 'View'; only struct/enum/class types can conform to protocols
Here is my code:
Here is my code:
Code Block swift import SwiftUI import MapKit import Contacts import Firebase struct BirdhouseView: View { @State private var region = MKCoordinateRegion( center: CLLocationCoordinate2D(latitude: 25.7617, longitude: 80.1918), span: MKCoordinateSpan(latitudeDelta: 10, longitudeDelta: 10) ) var body: some View { let db = Firestore.firestore() var houseId = "bluebirdsample" let housesRef = db.collection("houses").document("\(houseId)") housesRef.getDocument { (document, error) in if let document = document, document.exists { let dataDescription = document.data().map(String.init(describing:)) ?? "nil" print("Document data: \(dataDescription)") } else { print("Document does not exist") } } ScrollView { VStack { Text("Bluebird House").foregroundColor(Color.yellow).font(.system(size: 40)) Image(uiImage: UIImage(named: "sample_house")!).resizable().frame(width: 290, height: 190, alignment: .center).padding() Text("A super-cute birdhouse in Irvine Terrace Park!!").padding().foregroundColor(Color.yellow) Divider() HStack { Image(uiImage: UIImage(named: "sample-user")!).resizable().clipShape(Circle()).frame(width: 60, height: 60) Text("Beep Boop").font(.system(size: 24)).bold() } Divider() Button(action: { let url = URL(string: "http://maps.apple.com/maps?saddr=&daddr=\(33.5958557),\(-117.8806124)") UIApplication.shared.open(url!) }) { Text("Get Directions in Maps!") } Map(coordinateRegion: $region).frame(width: UIScreen.main.bounds.size.width, height: 400) } } } } struct BirdhouseView_Previews: PreviewProvider { static var previews: some View { BirdhouseView() } }