stleamist/BetterSafariView

Example code does not compile

arbyruns opened this issue · 6 comments

I get the following errors when attempting to compile.

  • Argument passed to call that takes no arguments
  • Type 'SafariView' has no member 'Configuration'
  • Cannot infer contextual base in reference to member 'systemBlue'
  • Cannot infer contextual base in reference to member 'done'

I'm running:

  • Apple Swift version 5.2.4
    Xcode: 11.7
import SwiftUI
import BetterSafariView

struct SafariView: View {

    @State private var presentingSafariView = false

    var body: some View {
        Button(action: {
            self.presentingSafariView = true
        }) {
            Text("Present SafariView")
        }
        .safariView(isPresented: $presentingSafariView) {
            SafariView(
                url: URL(string: "https://github.com/")!,
                configuration: SafariView.Configuration(
                    entersReaderIfAvailable: false,
                    barCollapsingEnabled: true
                )
            )
            .preferredControlTintColor(.systemBlue)
            .dismissButtonStyle(.done)
        }
    }
}

struct SafariView_Previews: PreviewProvider {
    static var previews: some View {
        SafariView()
    }
}

Hi @rbevans-ugh,

It's because SafariView that you implemented is passing itself recursively. Your View name should not be the SafariView, as it is used by BetterSafariView.

Change struct SafariView to any other name, then it should work. 😁

Ah thank you! So it works in preview, but I still get the compile errors.

  • Extra argument 'configuration' in call
  • Type 'SafariView' has no member 'Configuration'
  • Cannot infer contextual base in reference to member 'systemBlue'
  • Cannot infer contextual base in reference to member 'done'

image

Hmm, could you try cleaning build folder by pressing shift-command-K and run again?

I tried that as well as restarting. Let me try a new project.

Seems to be something within my project since creating a new project the issue is resolved. Thanks for the help!

Glad to hear that!