Loading Posts...

How to Use WebView with Swift 3.0 and Mac OSX

Swift 3.0 and WebView
Swift 3.0 and WebView

I was running into a big issue recently when trying to use the WebView in swift 3.0 and Mac OSX.  The issue was that most of the code examples online were old and useless. I could not find any information even on the apple developer website explaining how to setup the Web View properly when developing an OSX mac app and using the WebView module.  Anyway here is what I came up with.

This simple code should help you get started:
self.NAMEOFWEBVIEW.mainFrameURL = "http://www.devprocb.com";
You also have to modify your info.plist file to allow non secure websites.

Add a New Row and type ” App Transport Security Settings

Click the arrow to the left of App Transport Security Settings so that it is pointing down.

Add a new row.

The Drop down will have a couple of options.

Select “Allow Arbitrary Loads“.

Your info.plist should look like this:

info plist for all sites swift 3.0

This will help anyone looking to use the webview in their code on swift 3.0 and Mac OS X

Summary
Article Name
How to Use WebView with Swift 3.0 and Mac OSX
Description
How to use set a wep page using swift 3.0 and developing a mac osx app.
Author
Publisher Name
DEVPROCB
Publisher Logo
2
YayYay
0
HeartHeart
0
HahaHaha
0
LoveLove
0
WowWow
0
SadSad
0
AngryAngry
0
CrapCrap
Voted Thanks!

DEVPRO

CIO at a Large Private Company, Web Developer, Web Designer,

Leave a Comment

Loading Posts...