title: WKWebView App Rejected By Apple Due To Crash
body: <p>I have uploaded my WKWebView app that just loads website data to the app and it is running fine on my side but when I uploaded it to AppStore, apple rejected it saying "We were unable to review your app as it crashed on launch. We have attached detailed crash logs to help troubleshoot this issue". App minimum deployment target is 11.1 and Xcode version: 11.3.1. any help would be appreciated, Thanks.</p>
  
  <p><a href="https://i.stack.imgur.com/Lgq3j.png" rel="nofollow noreferrer">Crash Report Screenshot</a></p>
  
  <p>Here is my entire code:</p>
  
  <pre><code>class ViewController: UIViewController, WKNavigationDelegate {
  var refreshControl = UIRefreshControl()
  
  @IBOutlet weak var webView: WKWebView!
  @IBOutlet weak var refreshView: UIStackView!
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      initializeView()
  
  }
  
  
  private func initializeView(){
  
     webView.navigationDelegate = self
  
     guard let url = URL(string: "https://appybag.com") else {
         return
     }
  
     let urlRequest = URLRequest(url: url)
  
     webView.load(urlRequest)
  
     refreshControl.attributedTitle = NSAttributedString(string: "Pull to refresh")
     refreshControl.addTarget(self, action: #selector(reloadWebView), for: .valueChanged)
     webView.scrollView.addSubview(refreshControl)
  
  }
  
  @objc private func reloadWebView(){
  
     refreshView.isHidden = true
  
     if let _ = webView.url {
         webView.reload()
     } else {
         guard let url = URL(string: "https://appybag.com") else {
             return
         }
         webView.load(URLRequest(url: url))
     }
  
     refreshControl.endRefreshing()
  }
  
  func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
      ProgressHUD.show()
      print("loading")
  }
  
  func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
      ProgressHUD.dismiss()
      print("loaded")
  }
  
  func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
      refreshView.isHidden = false
      ProgressHUD.dismiss()
      print("failed to load")
  }
  
  func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {
      ProgressHUD.dismiss()
      refreshView.isHidden = false
  }
  </code></pre>
  
  <p>}</p>
  
  <p>And here are crash reports link:</p>
  
  <p><a href="https://iosapps-ssl.itunes.apple.com/itunes-assets/Purple123/v4/04/67/a2/0467a228-b74d-c9cc-7eb9-bebd13fac665/attachment-595762434851874863crashlog-AC94124F-204D-434E-8A1D-73A9355358FE.txt?accessKey=1591425677_7212368649932022101_ovHEGrHgVDTVg4wyC3tIiJOCMqwRHkjjpeICOnRTwTkmey%2FQafeIpk2ojIJH0MONv258wI4s0lb%2ByhLQsQ3%2FSsoV5SXMsmiYmqZo6ZyW3e96DqnfgTo8UnQdZJpZA7y3uWUnmFLgeB7M1SuWDsE3QyYTR1jLwSe1%2FZHoD2S1NGCz3BnV2vAlyYDHSR08wl3dgVD5ok%2FvoMAaKgkKSlz4ER7%2FO%2BnStmF82IeEi1CklxV1KjON2w%2Fmvv6iMIMV%2F%2BGT" rel="nofollow noreferrer">https://iosapps-ssl.itunes.apple.com/itunes-assets/Purple123/v4/04/67/a2/0467a228-b74d-c9cc-7eb9-bebd13fac665/attachment-595762434851874863crashlog-AC94124F-204D-434E-8A1D-73A9355358FE.txt?accessKey=1591425677_7212368649932022101_ovHEGrHgVDTVg4wyC3tIiJOCMqwRHkjjpeICOnRTwTkmey%2FQafeIpk2ojIJH0MONv258wI4s0lb%2ByhLQsQ3%2FSsoV5SXMsmiYmqZo6ZyW3e96DqnfgTo8UnQdZJpZA7y3uWUnmFLgeB7M1SuWDsE3QyYTR1jLwSe1%2FZHoD2S1NGCz3BnV2vAlyYDHSR08wl3dgVD5ok%2FvoMAaKgkKSlz4ER7%2FO%2BnStmF82IeEi1CklxV1KjON2w%2Fmvv6iMIMV%2F%2BGT</a></p>
  
  <p><a href="https://iosapps-ssl.itunes.apple.com/itunes-assets/Purple113/v4/95/d2/90/95d2909c-77d2-6593-3f26-6509c40c1f42/attachment-1735289411846494652crashlog-66DECCAE-BDA0-45B1-B3DA-94EDF504BF70.txt?accessKey=1591425677_7573732762115220118_SdP0MyNEDi%2BIm3fdnXeyEvl8RghEpk9WNyjyO5NZABlXcSmq0E4x%2BxZSsMaX7JJrN2OZz8VioTcOLVkeYa6MGnLefuNCcziBb%2FtwI6nOdK4niJ%2Bv4r4k0HmE89QfZYP4tXYihYX%2FCszG2WHA5DGQvAcicnGG8%2FgbU4elJGzx%2Ft4JmFNF%2B74xXO52EfSSZDh2pZ8Q9o1yeqKYdtXe6h3AvuodEeHWEgaZmk0N%2Bv7j6ALd3lJmvaCAlcasp0XjzNke" rel="nofollow noreferrer">https://iosapps-ssl.itunes.apple.com/itunes-assets/Purple113/v4/95/d2/90/95d2909c-77d2-6593-3f26-6509c40c1f42/attachment-1735289411846494652crashlog-66DECCAE-BDA0-45B1-B3DA-94EDF504BF70.txt?accessKey=1591425677_7573732762115220118_SdP0MyNEDi%2BIm3fdnXeyEvl8RghEpk9WNyjyO5NZABlXcSmq0E4x%2BxZSsMaX7JJrN2OZz8VioTcOLVkeYa6MGnLefuNCcziBb%2FtwI6nOdK4niJ%2Bv4r4k0HmE89QfZYP4tXYihYX%2FCszG2WHA5DGQvAcicnGG8%2FgbU4elJGzx%2Ft4JmFNF%2B74xXO52EfSSZDh2pZ8Q9o1yeqKYdtXe6h3AvuodEeHWEgaZmk0N%2Bv7j6ALd3lJmvaCAlcasp0XjzNke</a></p>