intune ios xcode

Create a Webview App For iOS, iPad OS or macOS

The major motive for exploring this was to have a website as an app and then publish it so that users can download and install it on their mobile devices. Yes, I know what you might be thinking, and you are correct; why do I need to create an app

5 min read
Create a Webview App For iOS, iPad OS or macOS

The major motive for exploring this was to have a website as an app and then publish it so that users can download and install it on their mobile devices.

Yes, I know what you might be thinking, and you are correct; why do I need to create an app when we can use Intune to achieve it? But sometimes requirements are that weird 😁. And as I said, the requirements…so these users are external and cannot have any M365 license (not even a standalone Intune license), and they should directly go to a secure location to download and install the apps.

We have websites with a perfect mobile view, but it is expected to act as an application that helps the users view only the particular website instead of opening a browser and browsing it. This kind of application acts and works like a browser, but users should be able to install it as an app on their mobile devices. Sounds weird again…and I said..the requirements!🤦‍♂️🤷‍♂️ But, this was something new, and I was excited to go the developer way. Why wait, then? Let’s get started 💻

In this post, I will walk you through creating a web view application for the iOS family using a swift programming language.


Pre-requisites

Let’s get started.


XCode

For this minimal iOS app, I will use the Xcode IDE by Apple. Xcode is Apple’s integrated development environment for macOS and is used to develop software for macOS, iOS, iPadOS, watchOS, and tvOS. Xcode provides a unified user interface design, coding, testing, and debugging workflow. The Xcode IDE combined with the Swift programming language makes developing apps easy and fun. To test or run applications on an iPhone, iPad, Apple TV, or Apple Watch, all you need is a free Apple ID.

The best thing is it has a built-in default simulator that helps you to simulate the app you are developing, and you do not any third-party app for testing your app. By using that simulator, you can make a simulation of your application for almost all iOS devices depending upon the minimum required OS that you configure in the app settings.

Download Xcode from Appstore.

📢📢 Xcode is around 13Gigs and will take time to download and install on your Mac. 

Minimum requirements for Xcode: https://developer.apple.com/support/xcode/


Create the app

On your Macbook, open Xcode and click on Create a new Xcode project

On the next screen, under Application, select App and click next. In this case, you can use multiplatform as we create a webview app that should run on all iOS devices.

Now, provide a Product Name and Organization Identifier, which will be used to define a Bundle Identifier for your app. You can also provide values for Team and Organization Name or leave it with the default values for now. When you press Next, you’ll be prompted to select the location where you will store the project. Select your preferred location and click on Create.

The next page is for defining your configurations for the app. You can choose the version of iOS from the drop-down menu.

Open ViewController.swift file from your left-hand pane, which contains the code we need to change.

Time to write some code

To use the system UI and web configuration, we first import the UI kit and Web kit in ViewController.swift

import UIKit    
import WebKit

Next, we extend ViewController class by implementing the WKNavigationDelegate protocol.

class ViewController: UIViewController, WKNavigationDelegate {

Then within the ViewController class, define the WKWebView property, which will be used to store the reference objects.

var webView: WKWebView!

We will not get into iOS development. Use the below lines of code, and your working app should be ready to run in the simulator.

import UIKit
import WebKit

class ViewController: UIViewController {
class ViewController: UIViewController, WKNavigationDelegate {
    var webView: WKWebView!

    override func loadView() {
        webView = WKWebView()
        webView.navigationDelegate = self
        view = webView
    }

    override func viewDidLoad() {
        super.viewDidLoad()
       
        let url = URL(string: "https://www.intuneirl.com")!
        webView.load(URLRequest(url: url))
        webView.allowsBackForwardNavigationGestures = true
    }

Play Around

The simulator app within Xcode presents the iPhone, iPad, Mac, or Apple Watch user interface in a window on your Mac computer. You interact with Simulator using the keyboard and the mouse to emulate taps, device rotation, and other user actions.

For this blog, we will stick to the basics of using a Simulator and perform all these steps using our own iOS webview app.

From the top bar, select the iOS device on which you would like to test your app and press the button with the “Play” icon to launch the simulator.

You can also see the performance of your app in the simulator. It will show how much CPU or memory your app is consuming.


Publish The App

Everything looks good till here. Now, follow the steps in this blog post to create a .ipa for the app, and then you can publish it to Apple App Store or even distribute it through your MDM solution.

If you want to use MAM capabilities, wrap the app and distribute it. The steps are here – Wrap me Up!.

Awesome..I can imagine that feeling. You just created & developed your first iOS app – High5✋

Share your feedback and comments, and keep learning. “Challenges drive Us #mempowered

Stay In(tuned) to create a webview app for Android.


Share This Post

Check out these related posts

Platform SSO for macOS: A Deep Dive into Configuration & Troubleshooting

Application Inventory: The Unsung Hero of macOS Security

Set Sail for Smooth Seas: Effortless Mac Enrollment with Intune