Berke Aras
Berke Aras

Reputation: 11

Some Websites are not loading in Swift Xcode 9.2

Hey :) I am new to swift and I want to create a WebView App. If I set URL to https://www.apple.com it works perfect. But if I change the URl to https://www.berkearas.de it does not work anymore. The Website is still working and online, and I have a SSL Certificate too. What can I do? Thank you all :)

import WebKit
class ViewController: UIViewController, WKUIDelegate {

    var webView: WKWebView!

    override func loadView() {
        let webConfiguration = WKWebViewConfiguration()
        webView = WKWebView(frame: .zero, configuration: webConfiguration)
        webView.uiDelegate = self
        view = webView
    }
    override func viewDidLoad() {
        super.viewDidLoad()

        let myURL = URL(string:"https://www.berkearas.de")
        let myRequest = URLRequest(url: myURL!)
        webView.load(myRequest)
    }}

Upvotes: 1

Views: 172

Answers (1)

Hitesh Surani
Hitesh Surani

Reputation: 13557

Just add NSAppTransportSecurity key into your .plist file then everything working fine.

<key>NSAppTransportSecurity</key>  
 <dict>  
      <key>NSAllowsArbitraryLoads</key><true/>  
 </dict>

Screenshot

Upvotes: 1

Related Questions