stleamist / BetterSafariView

A better way to present a SFSafariViewController or start a ASWebAuthenticationSession in SwiftUI.
MIT License
581 stars 57 forks source link

Example code does not compile #4

Closed arbyruns closed 4 years ago

arbyruns commented 4 years ago

I get the following errors when attempting to compile.

I'm running:

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()
    }
}
stleamist commented 4 years ago

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. 😁

arbyruns commented 4 years ago

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

image

stleamist commented 4 years ago

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

arbyruns commented 4 years ago

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

arbyruns commented 4 years ago

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

stleamist commented 4 years ago

Glad to hear that!