return 42;

by Jan Wedel

First Impressions of iOS Development

As a hobby project, I started to write an iOS app. Actually, I always wanted to do that because I am a bit of an Apple Fanboy but I didn't want to spend the $100 on the dev account just to play a bit around and test on my iPhone.

But with Xcode 7, you can now use a test profile that allows you to install apps on your own devices (for a limited period of time).

Additionally, I was interested in Swift, if it introduces new concepts and because as a software developer, you should learn a new language every year.

Swift

So first, I started with "The Swift Programming Language Book" which can be downloaded for free on iTunes.

Although it's "only" version 2.0, I am still a bit disappointed:

  • No language concurrency model (except of framework-based Grand Central Dispatch)
  • No method based pattern matching (at least it has pattern matching in switch)
  • Still using null/nil (because of the Objective-C roots)

At least the language makes it easier to write nil checks and class casts:

if let sourceViewController = sender.sourceViewController as? IntervalViewController, interval = sourceViewController.interval {
    // sourceViewController is definitely set and of correct type
    // interval may be nil
}

Coming from a mostly Java world, I have to say that Swift is still immature. Java is known to be very slow-moving and conservative but it has made some substantial progress with Java 8. Writing Java 8 code with the right IDE surprisingly starts to make fun!

iOS App development with Xcode 7

So I started with the Meals tutorial. It is an iOS table-view-based application that lets you add meals with photos, ratings edit and delete them. It also covers some basic persistence features.

I have to say, they put a lot of effort in it to make it cover a lot of important topics and to keep you on board by incrementally applying changes to the code, explaining every bit and also having the changed parts of code after every step.

UI

At first, Xcode compared to IntelliJ IDE is really confusing, at least to me. It looks very well-designed (and maybe it is) but it puts a lot of functionality into tabs, side-bars and what not and it was hard to understand how assistant editor works, what to select there and what the difference between identity, attributes and size inspector is in the storyboard editor. This is not covered in the tutorial. I guess there must be some Xcode tutorial...

IDE

Code completion

Maybe this is a problem with Swift or Objective-C, but when using auto-completion, it shows a million of attributes and methods. It is really hard to get an understanding of what an object really offers. I was just following the tutorial, which works but I was interested to see what else I could do. Another thing is, if you have variables and classes like meal and Meal, it very often replaces your lower-case writing by the upper-case version without selecting it.

Fix imports

When you add a new interface to implement (like e.g. NSCoding), it will show a compiler error until you add import Foundation. The IDE you automatically add the import on request to fix the error because the IDE has the library in scope.

Interface Builder

The worst part of the experience is the Interface Builder, at least for me.

I have to admit that I am not a UI developer. I like beautiful design but I hate crappy things like HTML, CSS that makes it really hard to get from an idea to an actual outcome that looks and behaves as expected.

I went through the tutorial twice, once with the meals app and once to build my own app, just trying to follow the steps. And even after the second time I am really confused and disappointed how things are solved in Xcode and Cocoa when it comes to build the UI.

You just spend to much time to build standard UI.

You create controllers (OK, MVC), you create views in the IB, then you sometimes you ctrl-drag stuff to create attributes and methods, sometimes you add implementation to existing methods, sometimes you override method that are not already in the auto-generated code. Then you use completely different approaches for displaying the same view for adding and editing an table item or saving and cancelling the edit. For some things you use the IB, some things you just implement in the code. Then there is another concept of segues where, again you have a confusing mix of custom methods, IB configuration. Sometimes you have to enter an identifier in the identity inspected and, then again, manually enter it in the source code. Then some classes have attributes like tableView which appear hidden to an unexperienced developer, sometimes you get a variable as parameter.

Why can't it just use types and attribute names which will automatically be correct once it compiles? Why isn't there a unified concept of creating interaction between UI and code?

AutoLayout?

I heard a lot of bad things and jokes like Au t oLay ou t. I have to say, that it is also hard for me to understand what it is doing and why. I just experiment a lot, add and delete constraints and update frames of the view and of all views without really knowing what I am doing.

Apple as a lot of experience in creating self-explaining UIs and they should spend some more time on doing the same for Xcode.

Summary

It just feels not right, not fun. It feels like writing Java 1.3 code in Notepad instead of Java 8 code in IntelliJ IDEA. I was actually hoping to to have "WOW" experience but it's not there. Hopefully, it will change in the future.


Jan Wedel's DEV Profile