Can Swift for Android be used

Swift ... 100% native

In this last part of the series about iOS development I would like to deal with the supreme discipline of app development, so to speak.

With Swift you enter a completely new universe, namely the universe of Apple, and you quickly notice that a lot of things are not what you are used to. Of course, this mainly affects developers who have previously only developed under Windows.

Most of the frameworks presented last use common front-end technologies, and front-end developers are working more and more often with Macs from Apple. For these people, the switch is not that difficult, as they are at least already familiar with the MacOS operating system and its general look and feel.

What is Swift?

In contrast to the technologies presented in the previous reports, Swift is not a framework, but a programming language developed by Apple. In addition to apps for iOS, you can also use it to develop software for iPadOS, macOS, tvOS, watchOS and Linux. What you can do, however, at least not without further ado, is to develop apps for Android.

Swift is a very young programming language. Version 1.0 was only released by Apple in September 2014.

Why should you do this to yourself?

Many people ask themselves these or similar questions: Should one learn Swift? Is it worth the effort? The answer is of course here again: It depends on what you want to do. However, the cases that make the use of native development with Swift imperative are becoming fewer and fewer. On the one hand, this is due to an increasing number of really good frameworks and technologies for cross-platform development and, on the other hand, also to the fact that it is increasingly rare to develop solely for iOS devices.

Nowadays, an app has to run practically all the time on iOS and Android and you don't want to develop it twice and then maintain two completely separate products. Twice the effort is simply not particularly economically effective.

For an app like the one in our example, it can be said quite clearly that a native implementation using Swift is not necessary. Neither the performance benefits to be expected nor the direct access to system functions justify the effort of getting to grips with Swift in the first place.

No question about it, Swift is fast. People like to compare it to C / C ++ and when it comes to writing applications that require this kind of performance, Swift will be the right choice or you can hardly avoid Swift. For everything else, you can just as easily use React Native, Capacitor or Xamarin.

Buckle up, steep learning curve ahead!

First the good news: There are an incredibly large number of good tutorials, online video courses, and forums of all kinds for iOS development with Swift.

The bad news: you really need it all.

If you have never developed for iOS before, you have to learn two things in particular:

  • the operation of the development environment XCode
  • the Swift programming language

And if you haven't had much to do with Apple devices up to now, then you have to get used to the operation of MacOS, because XCode only runs under Apple's own operating system and it is not licensed to use this on hardware other than Apple's install, even if it is technically possible to run MacOS on a VM under Windows.

The first thing that strikes you, especially if you come from the Windows world, is that Apple apparently still takes its former advertising slogan “Think Different” very seriously. Sometimes you really get the impression that when you were developing Swift and XCode you really tried to do as many things as possible differently than most developers are used to.

If you then dig deeper into Swift, you quickly notice that it has become a very mature language. You can also find all the common features of other languages ​​in Swift, only these are usually called differently than you know.

“This” means “self”, “Interfaces” are called “Protocols” and anonymous methods or functions are called “Closures”. I find the keyword “let” particularly bad. This declares a constant in Swift, whereas it declares a variable in JavaScript, for example.

The sample application

One last time we reproduced our app, which we had recently developed with React Native, Capacitor or Xamarin, a small business app with a classic structure that loads data and images from a web service and then uses this data in the form of a list with the associated detailed view indicates. In addition, common sensor data and the camera were accessed and various form fields were displayed.

When choosing the development environment, we were obviously somewhat limited.

However, the development with XCode is quick and easy once you are familiar with it. Until then, you have to struggle with handling this software.

The graphical editor for the layout of the user interface of the app offers everything you need, but is more than just cumbersome to use. Above all, creating a flexible layout for different display sizes using so-called constraints takes some practice and, above all, you need good nerves. But once you have this thing under control, you are extremely flexible in designing the user interface.

Obviously, the control of sensors of all kinds is not problematic either, since you are in a system-level programming environment with direct access to pretty much everything iOS has to offer.

If you don't know what to do next, you will quickly find what you are looking for on the web. The seemingly endless number of video tutorials, forums, and blogs really helps here.

Conclusion

One might well be tempted to say “I only let water and Swift on my apps” - I would strongly advise against water at this point - and the resulting advantages of being able to take the direct route with Swift, so to speak, lie also very obvious. However, the disadvantages are just as serious and that is precisely what does not necessarily make the decision easier.

For conventional business apps like the one in our example, you can clearly say that you don't need to learn Swift for this. Especially if you already have know-how in one or the other front-end technology, you will reach your goal much faster with Capacitor or React Native.

Only for applications where high performance is a decisive criterion, you will not be able to do without Swift. But here we are already in the field of real-time applications such as those found in audio and music production, 3D animation or games. For everything else, Swift is actually just an exaggerated expense.

Written by Thomas Polaschek