user3245722
user3245722

Reputation: 323

WKWebView is not loading url

WKWebview is not loading certain urls. this is my code snippet

let myURL = URL(string: "https://contents.tdscpc.gov.in/")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)

when I change the url to say URL(string: "https://www.ndtv.com/") it works . Not sure why? any suggestions will be really helpful.

Upvotes: 16

Views: 16569

Answers (2)

Mick
Mick

Reputation: 31959

Mac App Devs

If you are building an app for the Mac, make sure to turn App Sandbox ON in your target and tick Networks Incoming/Outgoing Connections.

enter image description here


Update: If you prefer the long way, add the following to YourAppName.entitlements

<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>

Upvotes: 12

iPatel
iPatel

Reputation: 47099

First check did you set the permission in the info.plist file ? If not then you just need to take permission of TransportSecurit to YES in info.plist file

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

Like below

enter image description here

Upvotes: 30

Related Questions