Creating A Simple Web View App For iOS

Introduction

 
Creating a web view mobile application is a basic and simple task for any developer who is doing it. The major motive of creating a web view the mobile application is because we already have a website with a perfect mobile view, but we need an application that helps us to view only the particular website, instead of a browser. This kind of application acts and works like a browser, but it displays only the particular website. In this article we will discuss creating a web view application for the IOS, using a swift programming language.
 

Xcode

 
For creating this application, I am going to use the Xcode IDE by Apple. Xcode helps you in different ways while creating an application. The basic and very important thing is it has a default simulator that helps you to simulate the app which you developed, without the help of any other software or any other device. By using that simulator, you can make a simulation of your application for many numbers of devices, which supports the operating system you have chosen. You can download the Xcode from apple’s app store which is available for free of cost. Apart from Xcode, you can also use different types of IDE’s which support swift programming language, but while doing like that the steps and execution procedure may vary, but there will be no changes in the code.
 

Creating an application

 
First, you need to open the Xcode IDE. In the appearing screen, you need to select Create a new Xcode project. 
 
Creating A Simple Web View App For iOS
 
On the next screen under the iOS tab select the app option and click next.
 
Creating A Simple Web View App For iOS
 
In the next screen you need to enter the name of the app you are developing and the team you are working with, then click Next.
 
Creating A Simple Web View App For iOS
 
Then you need to select the location where you are going to store the project then click create.
 
Creating A Simple Web View App For iOS
 
You can choose the version of iOS by clicking the drop-down box which is available under deployment info. Then you can type your code in ViewController.swift by clicking it. 
 
Creating A Simple Web View App For iOS
 
First we are going to import the UI kit and Web kit for the purpose of using the system UI and web configuration.
  1. import UIKit    
  2. import WebKit     
Creating A Simple Web View App For iOS
  1. import UIKit  
  2. import WebKit  
  3. class ViewController: UIViewController, WKUIDelegate {  
  4.     var webView: WKWebView!override func loadView() {  
  5.         let webConfiguration = WKWebViewConfiguration()  
  6.         webView = WKWebView(frame: .zero, configuration: webConfiguration)  
  7.         webView.uiDelegate = self  
  8.         view = webView  
  9.     }  
  10.     override func viewDidLoad() {  
  11.         super.viewDidLoad()  
  12.         let myURL = URL(string: "https://www.c-sharpcorner.com")  
  13.         let myRequest = URLRequest(url: myURL!)  
  14.         webView.load(myRequest)  
  15.     }  
  16. }   
After coding your project now, we are going to test the project. For that, we are going to use the default simulator. You can choose the device which you are going to simulate by clicking the drop-down box nearby the project name. Then you click the build button to start building the project.
 
Creating A Simple Web View App For iOS
 
Then the simulator opens automatically. Here I chose iPhone 11 and the screen of iPhone 11 is opening now. It displays the web content in the mobile application. 
 
Creating A Simple Web View App For iOS
 
Creating A Simple Web View App For iOS
 
You can also analyze the performance of the application by the given option in the Xcode. It displays the details of how much CPU the app is using and the memory used by the app and also the network used by the app. This gives you a clear idea of how your app is working.
 
Creating A Simple Web View App For iOS
 
There are a lot more options available in Xcode which I will explain in my upcoming articles.
 

Conclusion

 
This is one of the simplest ways of creating a mobile application. This may help some people to create their applications for their website. You may also create a web view app with customized buttons. I will explain those things in my upcoming articles. Thank You!