Salmaan Ahmed

@salmaanahmedz

A journey from android development to iOS development in 2018 — Kotlin and Swift

January 15th 2019

Back in 2014 I started my career as android application developer, I worked on many projects including core android apps which required deep knowledge of android SDKs and also NDK. Other than that I also worked on IOT projects which included connecting with external and on-device sensors.

I enjoy being challenged and engaging with projects that require me to work outside my comfort and knowledge set, therefore I started looking into iOS development later in 2017. Knowing the mobile eco-system, it wasn’t much difficult for me to getting along and thanks to the sister languages, kotlin and swift, there was almost zero effort to work on swift.

TL;DR
From Android to iOS development — highlighting the better things

Root view controller

I was writing a network wrapper for iOS to manage all network calls.
Whenever network request is made, loader dialog is shown and is removed when call is ended. (Not the ideal way, but it was a small app)
Imagine doing it in android :@ What would you do? pass a context in every function, function by function or putting it in a constants file? using application context (which introduces a new set of problems).

let currentVC = rootVC.presentedViewController ?? rootVC!currentVC.present(screenLoader, animated: false)

Creating custom views

Ever created custom view for android? Some heavy chart? Remember problems with onDraw? It being fired more than once? or do you remember onLayoutSubviews where you request for the view size?
Well, iOS manages it beautifully. It’s not like we don’t have onDraw in iOS but it is different, frame and bounds are really powerful.

override func draw(_ rect: CGRect) {
super.draw(rect)
    self.layer.borderColor = UIColor.blue.cgColor
self.layer.cornerRadius = self.frame.height/2
self.layer.borderWidth = 2.0
self.clipsToBounds = true
self
.setTitleColor(.white, for: .highlighted)
(buttonColor = buttonColor)
}

Or you can also use auto layout in custom view. See example here.

Storyboard

Android developers have been away from this blessing, anyhow they are catching up now.
There is no markup language to learn such as XML. You don’t have to see the code for sometime which is also a good feeling. Drag and drop is lot easy, you can say, common sense is required for building simple UIs.
No view ids — phew. IBOutlets and IBActions are something from heaven, well kotlinx synthetic has also made it a lot easier but aren’t mature enough.
Another beautiful thing about storyboard are the seagues, the navigation between the view controllers, a proper, better backstack and understanding of the app flow.
Ever implemented bottom bar/tab bar? Had to work with the fragments? Maintaining multiple lifecycles? Try doing it on iOS :)

Dependency Injection

Dagger and Koin are the most popular dependency injection libraries in android, they require a tricky setup and lots of code, specially autogenerated, and they come with their own set of bugs and errors.
In iOS, we do not require any library but technique which is less prone to errors and easier to implement.

Call Kit

We worked on a chat application which included audio/video call. There were tons of things we had to take care of in android. Setting the wake-lock, proximity sensor to disable the screen, keep screen on, running the timer etc.
Whereas iOS comes with call kit which already handle all these cases :)

Anyhow, call kit helps but it also limit developers.

Target Devices

Apple has the limited number of devices running on iOS: iPhone, iPod and iPad. Moreover, the most recent statistics shows, that over 50% of users updated their operating systems to the latest version (iOS 11) during the first 3 weeks after the release. It makes lives of iOS developers easier. A development process flows faster because you have to build your app for a narrow range of devices and operating systems.

But if we talk about Android, it’s just a mess. There are dozens of smartphones and tablets on Android with different screen sizes and aspect ratios. It means your app should be suitable for all of them. Or at least for the biggest part.
The same thing is about operating systems. Here you can’t find any, which is used by more than 50% of Android device owners. And it means that you again have to consider this difference while building your app.

XCode IDE

When it comes to the IDE, android studio is lot better in many things, such as giving suggestions, navigation by clicking on the class, improving code snippet etc. but when it comes to speed, XCode is way better, android studio is memory hungry. It takes lot of time to import a project or even running the project can be very frustrating at times specially in debug mode.

Conclusion

It is not like that iOS is better than Android for development aspect, both have their own pros and cons. This post focuses on few pros I have experienced in last year. If there are any other things I missed, please comment and if you liked it please clap :)

More by Salmaan Ahmed

More Related Stories