Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

304
Vistas
WKWebView is not getting intialized in swift 4 xcode 10

Could anyone help me in understanding why my webView is not getting initialized here. I am getting the following error because webView is nil.

Fatal error: Unexpectedly found nil while unwrapping an Optional value

What exactly I am missing here?

import UIKit
import WebKit


class MemoriesViewController: UIViewController, WKNavigationDelegate {

    @IBOutlet weak var webView: WKWebView!

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear( animated )

        let urlString:String = "https://www.apple.com"
        let url:URL = URL(string: urlString)!
        let urlRequest:URLRequest = URLRequest(url: url)
        webView.load(urlRequest)

    }


    }

}

Screenshot for better clarity where the error is actually happening:

enter image description here

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

Add Webkit.Frameworks to Linked Framework and Libraries

enter image description here

You can then add the Outlet for WKWebView and use your code

import UIKit
import WebKit

class MyWebViewController: UIViewController {

@IBOutlet weak var myWV: WKWebView!

override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
    let urlString:String = "https://www.apple.com"
    let url:URL = URL(string: urlString)!
    let urlRequest:URLRequest = URLRequest(url: url)
    myWV.load(urlRequest)
}


}
over 4 years ago · Santiago Trujillo Denunciar

0

In Xcode 10, you can foll bellow the step:

  1. Click the project
  2. Go to build phase
  3. Go to Link Binary with Libraries
  4. Click add plus sing under Link Binary with Libraries
  5. open a windows & search Webkit.framework
  6. add & enjoy it
  7. Show bellow image enter image description here
over 4 years ago · Santiago Trujillo Denunciar

0

The problem was my output was not connected to the storyboard. That's why @IBOutlet was not getting initialized.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda