The Five Steps to Build IoT Apps On iOS

By Carsten Rhod Gregersen

It is surprisingly simple to build Internet of Things applications for Apple's operating system.

It should go without saying that the Internet of Things (IoT) has become far more accessible in recent years thanks to the rise of smartphones. Devices are more powerful and the Internet more widespread than ever before, meaning more vendors are looking to find success with their own smartphone application.

There is a catch, of course, and it is that the world's favorite smartphone runs on a specific operating system that warrants extra attention. The Apple iPhone accounts for a significant chunk of active smartphones today—more than one billion worldwide—and yet its famous iOS operating system demands additional considerations from application developers.

How can you go about programming the Internet of Things with iOS? What's more, how can you build an  IoT iOS app? Let's look at the five key steps to building applications for Apple audiences.

Step 1: Learn Xcode and Swift
When developing an app, you need to choose whether to do it natively, hybrid or cross-platform. The best of these options—if your app is only for one operating system—is native development. This is because it lets you access OS features, such as GPS or the camera, and gives your app better performance. When developing natively for iOS, you are going to want to use the native Xcode.

Xcode is an Integrated Development Environment (IDE) for macOS that contains a set of tools created by Apple for the development of software for multiple Apple operating systems, including MacOS, iOS, watchOS and tvOS. Xcode is the only legitimate program you can use to make native Apple apps, so learning Xcode is going to be necessary for developing an iOS IoT app. This IDE lets you test your app with either a simulator or your own iOS device, so its advantage for developing in iOS is immediately noticeable.

Xcode is completely free for users of the latest macOS and can be found at the Mac App Store. This means you need a Mac computer to work on Xcode. That being said, if you are a Windows or Linux user, there is a way around this: simply set up a virtual machine (VM) running macOS and work from there.

Next, you need to get to grips with Swift, a programming language developed by Apple. More importantly, it's primarily what you'll use alongside Xcode to make iOS apps. Swift has the advantage of being the dominant language for iOS development, and it's not hard to learn as it's similar to other programming languages. Further, Swift boosts efficient and concise memory management and supports dynamic libraries. Therefore, even if you're new to Swift as a programming language, it should still be a relatively stress-free process.

Step 2: Choose an Application-Enabled Platform
The next step is to choose an IoT application-enabled platform (AEP). An AEP is an environment within which to build and deploy IoT products and services. As you probably know, building an IoT platform from scratch can be incredibly difficult and a long process. However, an AEP streamlines the process of implementing IoT into your app.

Without one, you would need to design, build, test and maintain each part of the IoT stack, including server and database deployment and maintenance, UX and UI build, third-party connections and APIs, and front-end build and maintenance. You have two options when it comes to choosing an AEP. The first is a centralized traditional IoT application-enabled platform, like Azure IoT and AWS IoT. The second is a decentralized IoT application-enabled platform that communicates via  IoT P2P.

While a traditional AEP benefits from having software development kits (SDKs) that provide native support to iOS devices, it has some drawbacks. Firstly, there are the security concerns. These use the cloud for data storage. As data passes through, it's vulnerable to bulk data theft or loss. What's more, data having to pass through a central server may result in high latency for your iOS IoT app. However, with a decentralized AEP, you can circumvent these security and latency concerns, and also have lower running costs. Therefore, I recommend going down this route if you're wondering  how to develop IoT apps and simply want your iOS IoT app to run as smoothly as possible.

Step 3: Code the Front- and Back-Ends
After choosing your AEP, it's time to code the front- and back-ends of your IoT app. The way data is presented to a user is just as important as the way it is used. Xcode has an Interface Builder function built-in that lets you design user interfaces without having to write any code. However, you can make even better user interfaces with the  SwiftUI toolkit.

Back-end development in IoT is complex and time-consuming. Thankfully, back-end development can usually be aided or entirely handled by the AEP you have chosen. Moreover, you can avoid back-end development altogether if you use a decentralized AEP solution. This is because back-ends are normally the centralized server application of a centralized AEP system, whereas with a P2P or decentralized AEP, you just have the client application (front-end) which connects directly to the IoT application running on the IoT device.

Step 4: Utilize Apple Native IoT Frameworks
As mentioned earlier, if your app is going to be exclusively for iOS, developing natively can offer a ton of benefits. Being able to use Apple's native IoT frameworks is one of them. Apple has developed a couple of IoT frameworks for use in their devices, so why not use them? HomeKit is an IoT framework that allows users to communicate with and control connected accessories in their homes using your app. It can display, edit and act upon the data in the home configuration database, and actions can even be activated via Siri.

To utilize HomeKit in your project, you would enable the HomeKit capability and include the NSHomeKitUsageDescription key in your app's Info.plist file. This and other frameworks, like HealthKit, can make developing IoT systems for iOS more appealing and easy. Therefore, don't be afraid to take a quick look over the documentation to see if it would fit into your IoT project.

Step 5: Deploy Your App to the App Store
The final step will be to publish your project. Keep in mind that you need to sign up to the Apple Developer Program to submit your apps for review and eventual publishing. This costs $99 per year. After you sign up, you'll have access to App Store Connect, in which you will be able to view app analytics and other options. Submit your app and wait around 48 hours for approval. Once this process is completed, you will have an IoT app for iOS readily available to the public.

As you can see, it's surprisingly simple to build Internet of Things applicationss on IoS. Apple's ease of usability is often cited as a reason for the iPhone's popularity, and when it comes to developing IoT iOS apps, it's no different.

Carsten Rhod Gregersen is the CEO and founder of  Nabto, a P2P IoT connectivity provider that enables remote control of devices with secure end-to-end encryption.