22. Nov 2021iOS

Starterpack for future iOS developers

Last week at GoodRequest was marked by events. On Tuesday I kicked them off, who am I? iOS Lead Maroš Novák. I took part in Online Talks, which this time was dedicated to the topic Introduction to the world of programming.

I have been involved in development for more than 15 years, of which I have been an iOS developer in GoodRequest for almost 8 years now. In addition to myself, I also introduced GoodRequest, all our teams and the most well-known projects of the iOS team, which include, for example, Bistro.sk, Tatra banka or Reprezóna. After a short introduction, we kicked off a presentation, where I was talking about how development can be nice and easy, and how Apple is trying to make it even more siple.

Hardware requirements

iOS applications can only be developed on macOS. Of course, he has his pros and cons and not everyone likes pricing or marketing. My colleagues and I discovered the benefits after entering the ecosystem and we immediately liked it, we really needed to try it. The main thing to keep in mind is that you don't need a high-end computer for more than € 2,000 right from the start. A Macbook Air or Mac mini will suffice. They now even have new chips from Apple that roll throught benchmarks, so you can have a powerful machine for up to € 1,000. In addition, you don't have to worry about making a mistake and staying closed to just Apple and having to focus on just one development, almost everyone in GR uses Macbooks for their development and even most Android developers.

As for iPhones, they are not a prerequisite, thanks to the simulator that is part of the native development environment. This gives us enough space to test our cases and apps. I know from experience that 90% of the things we code are enough to test on a simulator. Of course, if you want to work with bluetooth or camera, you will need an iPhone.

Software requirements

Xcode is a development environment directly from Apple, which is its main advantage and disadvantage 😄. This means that they can often surprise us, but at the same time we can rely on regular updates, support for new devices and development, from writing code to deploying to the AppStore via Xcode. There is also an alternative from JetBrains - Appcode. It can also only be run on a Mac but unlike Xcode it is paid.

Programming language

Swift replaced Objective-C a few years ago, just as Kotlin replaced Java. Swift is simple, modern, easy to read and also open-source. In recent years, the community has been able to bring this language to a great level and thus simplify our daily development. Another advantage of Swift is the ability to create a server-side app or any script. My favorite thing on Swift is that it is type-safe and also Optional to values, when there may or may not be a value within the variable. In this case, the compiler will push you to handle these conditions, and as a result, the apps in the AppStore are more secure and do not crash.

iOS vs. Android

Kotlin vs. Swift

Now let's look at a brief comparison of iOS and Android platforms. In the slide below you can see a small comparison of the syntax of Kotlin and Swift. In these few cases, you can see that the syntax is very similar, and if you already know Kotlin, learning Swift is a matter of hours. The transition from Swift to Kotlin and vice versa is therefore easy and fast.

One of the great advantages of Swift is that it is really fast in terms of compilation. It is faster than Kotlin and even 8.4 times faster than Phyton. The combination of the new Macbooks with M1 chip and Swift language provides express application building in seconds. This is a real productivity changer in our daily development.

Market share

In Slovakia, the share of iPhone users is 23%, which of course seems small, but we at GR are working on applications that are not targeted only at the Slovak market. When we look at Europe, the share is more than 36%. In the strong US market, clients want an iOS application first, then an Android application, as more than half of Americans own an iPhone.

Slovak clients also want to have their solutions and products on iOS devices, because they do not want to lose a large customer base. The fact that iOS is less represented in Slovakia does not mean that applications are used less. iPhone owners are more active, buy more, and use more apps. For example, with the Bistro app, 46% of iOS users order more than people with Android.

That's why we need more iOS developers, because there is as much work for them as for Android developers.

iOS advantages over Android

Once upon a time, when we were developing iOS apps (5-7 years ago), we needed a number of third-party libraries to expand our native capabilities. We just needed libraries for just scanning the codes or mapping objects from the server. Just from the name dependencies it follows that we are dependent on something external. We need to make sure that the library is updated, that it has support from the creators, or that it is usable in the new version of iOS - so that the app doesn't crash. Over the years, Apple has improved its native SDK and noticed what is being used the most, and then implemented it for itself. Now, by default, we use a number of library units that are verified and their task is e.g. track crash or usability in app. As far as UIs and frameworks are concerned, the native SDK is enough for us.

Another advantage is the development of devices from one manufacturer. It's really great when you know what your app will run on and you can test it directly in the simulators. The simulator can build a 4" device application directly in Xcode up to the latest with a 6.7" display, which is the iPhone 13 Pro Max. It is also possible to build any iPad, Apple TV or Apple watch. Every real Apple hardware has a software simulator. The problem with Android is that the application can work properly on high-end devices but crashes on a few devices from some manufacturers.

The advantage of both platforms is a great community. iOS has very good resources for current solutions as well as for learning programming. In GoodRequest, we also educate students and those who are interested in iOS. We have 2 platforms for that. One of them is an iOS internship, which is intended for anyone who is interested in programming and has some basic knowledge, e.g. object-oriented programming. We will go through the whole Swift together and an introduction to iOS programming. Then we have iOS Academy, where we already build on the basics, which can be from UDEMY courses, from YouTube videos or home programming. There we get to advanced architectures, UI creation, animations and the like.

How Apple is making our work easier

The first topic is Mac Catalyst and Swift UI. Catalyst allows you to run applications programmed on both iOS and macOS. It is also possible to directly start developing applications cross-platform, but still within the Apple ecosystem.

The new way to create a UI is the SwiftUI framework. Component creation is similar to React or Compose. Swift helps us to create UIs, call parameters and customize them directly in the code. Such an application programmed primarily for the iPhone can work for the Mac, while preserving the native features.

The example shows what SwiftUI looks like. The right side represents the list of articles. The List component will create a list for us and each list item will point toArticleView using NavigationLink.

ArcticleView is a detail of such an article, consisting of a simple vertical stack -VStack. We can insert components into it, in our case two Texts and Spacer. Defining parameters is very simple and it takes a few minutes to create such a prototype on different platforms.

The result then looks like I can build the application on different platforms. It has a sidebar on the iPad where the list is below. On the iPhone, these are naturally tabs that are down next to each other. On a Mac, the detail looks completely different from other patforms, because each platform has native specifics. Catalyst will do this for us with one source code.

Augmented Rality Kit

Another good example of how well Apple's native frameworks work is augmented reality. We worked with augmented reality on a furniture project that allowed different types of furniture to be inserted into a room and then moved or rotated so that customers could decide what suits their home.

The code is insanely simple and everything works natively. We define sceneView, which in our case represents the world around us. Next, we set up the configuration for floor tracking. Just define that we want to detect horizontal plane planeDetection = .horizontal. in iOS, we can also scan a vertical surface, such as a wall. Within this sceneView we can start a session, which will still track the floor in the background. Then we just load the configured 3D model of the chair, which we add to the scene.

func setupSceneView() {
        let sceneView = ARSCNView()
        sceneView.delegate = self

        let config = ARWorldTrackingConfiguration()
        config.planeDetection = .horizontal

        sceneView.session.run(config)

        let scene = SCNScene(named: "chair.scn")
        sceneView.scene = scene
    }

Video streaming

We work in applications with video playback as well, loading and saving photos to the gallery, accessing the camera or processing notifications from the server. It is therefore important to have a simple API to these frequently used native libraries. An example below is the Gopass application, where we displayed, among other things, live stream cameras. The condition was that the user could also display these cameras picture in picture. Thanks to Apple, we don't have to deal with a complex implementation and we just need to call allowsPictureInPicturePlayback = true. Loading a stream, adjusting the volume, landscape mode, it's all a matter of a few lines of code. It is really easy to work with native libraries, they save us time and we can focus on, for example, improving architecture, UI imitations or animations.

You can find the full video (in Slovak) here ⬇️

Maroš NovákHead of Design & Engineering