Post

Replies

Boosts

Views

Activity

Closure containing a declaration cannot be used with result builder 'ViewBuilder' and Struct 'ViewBuilder' declared here (SwiftUI.ViewBuilder)
An error appears and I don't know how to solve it : Closure containing a declaration cannot be used with result builder 'ViewBuilder'. import SwiftUI Struct ContentView: View { var body: some View { // some code... struct ContentView_Previews: PreviewProvider { // <- error Closure containing a declaration cannot be used with result builder 'ViewBuilder'.     static var previews: some View {         ContentView()   } } Struct Name: View { // some code ... var body: some View { Text"some text" // some code ... Struct Name: View { var body: some View { Text"some text" Struct Name: View { var body: some View { Text"some text"
1
0
4.6k
Sep ’21
How to implement a local video in app iOS swift 5, (4 errors).
Hi, how can I solve this errors ? : Cannot find type 'Video' in scope. Cannot find '$selectedVideo' in scope. Cannot find 'ErrorView' in scope. import SwiftUI import AVKit struct ContentView: View {     @State private var selectedVideo: Video? // the error is here     var selectedVideo = video // the same error var body:some View {         NavigationView {             .fullScreenCover(item: $selectedVideo) { // error               // On Dismiss Closure             } content: { item in               makeFullScreenVideoPlayer(for: item)             }                          @ViewBuilder     func makeFullScreenVideoPlayer(for video: Video) -> some View {               // 1               if let url = video.videoURL {                 // 2                 let avPlayer = AVPlayer(url: url)                 // 3                 VideoPlayer(player: avPlayer)                   // 4                   .edgesIgnoringSafeArea(.all)                   .onAppear {                     // 5                     avPlayer.play()                   }               } else {                 ErrorView() // error               }             }         ```
1
0
1.1k
Sep ’21