How to create webview on xcode ios

Hello, friends, today am going to show how you can create a webview based application using Xcode on Mac OS. Please follow along with this post also posted a video on my channel please consider watching that video also.


  1. Macbook or Mac mini
  2. some time to get started.

What is WebView?

A Webview is a component in the ios development environment with which you can load HTML pages in your application. Also this very helpful when you need to design something out of the box and something which will take a lot of effort to built-in native swift, then you can use HTML page to render that on screen. Webview is available in both ios and android most of the time webview is used to design smaller mobile application.

Get Started with WebView on Xcode.

Step 1: Open Xcode application on your mac

Xcode window

Step 2: Click on ‘Create new XCode Project’

create new xcode application

Then select ‘Single View App’, then press ‘Next’.

Step 3: Name your App

name your ios app

Then save your application in the desired folder.

Step 4: Open Main.storyboard

Then place webview from the bottom right component section.

ios component box in xcode

Then drag webview component and place it on a storyboard, and then adjust the side to fit the screen. (Please see the video for more details),

Swift Code & Logic for WebView in iOs

let url = URL(string:"")
let UrlRequest = URLRequest(url:url!)

These are the above three lines which actually load the website in your ios app webview. Let`s understand how this three line code works.

The first line creates a URI from URL so that it can be easily pushed to URLRequest method. Then URLRequest Method will make manage all the default headers and then webview1.load method will actually load the URL Request to webview and renders it on the fly.

Now, webview1 is a reference to the actual webview that is present on the view controller. in your case, it can be anything, but associated load method will remain same.

If you have any doubts or getting errors while creating webview in your mobile app. Feel free to comment in the section below.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.