0
import WebKit
import UIKit


class DissTrackSignUp: UIViewController {
    
    var webView: WKWebView!

        override func viewDidLoad() {
            super.viewDidLoad()
            webView = WKWebView(frame: view.bounds)
            view.addSubview(webView)
        }

    @IBAction func signInSpotifyTapped(_ sender: Any) {
            let authURL = URL(string: "https://accounts.spotify.com/authorize?client_id=c36fff5175844337a4da991b6eb0436f&response_type=code&redirect_uri=myapp-spotify://&scope=user-read-email")!
            let request = URLRequest(url: authURL)
            webView.load(request)
            webView.isHidden = false
        }
    }

I am trying to get the user to log in with spotify by redirection in Xcode, but the app will crash before the app is loaded and the launch screen hasnt disappeared.

Ive tried every possible thing like restarting xcode, reconnectiing and deleting outlets, and rewriting code.

vadian
  • 274,689
  • 30
  • 353
  • 361
  • There are no outlets in the code you posted. – HangarRash Apr 05 '23 at 17:10
  • `webview` and `webView` are not the same thing. – HangarRash Apr 05 '23 at 17:11
  • Press ⇧⌘F and search for `webview` (all lowercase). Maybe there is an unused element or connection in Interface Builder. – vadian Apr 05 '23 at 17:11
  • @vadian done that, and changed the webview and webView problem, still nothing. Here is updated code. import WebKit import UIKit class DissTrackSignUp: UIViewController, UIWebViewDelegate { IBOutlet var WebView: WKWebView! IBAction func signInSpotifyTapped(_ sender: Any) { let url = URL(string: "https://www.google.com")! let request = URLRequest(url: url) WebView.load(request) } override func viewDidLoad() { super.viewDidLoad() } } I put google just as an example site – Rylan Kodak Apr 06 '23 at 16:20
  • This is the third different spelling of *(w|W)eb(v|V)iew*. Case sensitivity matters. – vadian Apr 06 '23 at 16:25
  • @vadian Yes, i’ve deleted all outlets and reconnected them to all be WebView. – Rylan Kodak Apr 06 '23 at 21:45

0 Answers0