Learning iOS development

I am teaching a course at a Hungarian university about iOS development and my students are constantly asking about which version of Swift should they choose, how should they begin to create an app? These questions are very difficult to answer, but I always tell them to go with Swift 3. You have basically no other choice to move forward, right now. Let me explain this a little bit.

we focused on this idea of evolution over revolution

WWDC 2016 - Session 207

Currently there is a revolution in Apple kingdom. Developers are constantly struggling with the bugs, implementing the new features every year, adapting the new platforms, devices, and they don't even have a stable language. No, not even objective-c is the same anymore.

Languages

The great question: Objective-C vs Swift???

Swift

In 2014 Apple announced Swift. I was really happy to see javascript as their main programming language. I always thought that Objective-C is like javascript, but with a different syntax. The only problem was that Swift was not ready for production at all. Apple wanted to have a brand new language with modern features like generics, type safety, and many more. Releasing Swift 1.0 was a really brave but reckless move. It was only good for learning the new syntax, but that went pretty quick for everyone. Swift 2.0 was a bigger step forward with protocol oriented programming, but it was a minor update compared to Swift 3.0. Now it's almost 2017 here we are with 3 major versions, and those are totally incompatible with each other. Congratulations. This is evolution. Oh wait, there is more...

Objective-C

Swift is cool, but some coders wanted to stick with objective-baggage-c. What's the situation now? Those who converted to swift on the first place, now they are thinking completely different, but the rest of the obj-c coders who converted nowadays are just experimenting with pop, generics, and functional paradigm or they are still writing the same objective-c code, but in Swift. I know this progress, because the same evolution happened to me. Xcode has many bugs now, the syntax highlight has gone mad if you are using objective-c, and the code completion is not playing nice anymore. Ah yeah, and there is nullability too. That's it. No "evolution".

The Swift (r)evolution

Swift 1.0 -> just learn the new syntax, kay?
Swift 2.0 -> whoa let's use protocols everywhere!
Swift 3.0 -> fuck (obj-c) foundation.
Swift 4.0 -> finish all the things! generics, foundation.
Swift 5.0 -> stable abi. hello i am a mature language now!

We're at 3.0 now, and I really believe that this is a good direction, but don't dare to tell me there is an evolution, instead of a revolution while we have two foundation framework, and one of them is incomplete, and almost incompatible with the other.

override func startLoading() {  
        // rdar://26849668 - URLProtocol had some API's that didnt make the value type conversion
        let urlRequest = (request.urlRequest! as NSURLRequest).mutableCopy() as! NSMutableURLRequest
        URLProtocol.setProperty(true, forKey: PropertyKeys.handledByForwarderURLProtocol, in: urlRequest)
        activeTask = session.dataTask(with: urlRequest as URLRequest)
        activeTask?.resume()
    }

Do I have to say more?

So back to the original question: go with Swift. Use always the latest version. Converting your code will suck, but you will learn a lot while you take that path. Apple is pointing developers in the right direction, but they need time to finish everything. It's really hard to create a new language with multi-platform support, but I honestly believe that 2 more years will be enough. We just need to survive 1 or 2 more big updates. :)

Xcode

Xcode is in public beta now. There are many annoying bugs that make your life harder. Sometimes the whole interface gets broken like this. Why do I have to set an environment variable to hide logs inside Xcode8? Swift migrator as always is broken, but now if I open a legacy project I have to close 2 alert panels. Updating to Xcode 8 was hard. Keep it up guys fixes are coming in 8.1.

Is this an A/B test or what?

A

B

Podhell

Sorry for writing this but: CocoaPods sucks. I am not the firts one who thinks this, but read this and think for a while. My key problems are that the infrastructure is centralized, people are making dumb pods, there is a huge lack of quality, and even CocoaPods is not compatible with itself. Should I mention the unnecessary workspace too? Go with carthage or Swift Package Manager.

Native code

Always use vanilla code. API's made by Apple are more or less pretty straightforward. You don't need 3rd-party wrappers around the basic frameworks. Alamofire is good, but if the task is to download a JSON file from the web, why would you use a whole library? The same applies for JSON parsing too. There are tons of parsers out there, but every single one of them is crap. Of course you don't have to reinvent the wheel, but please be smart and - if you can - avoid libraries and external dependencies. Your project will be more maintainable.

User interfaces

In the past 10 years we've seen a hardware revolution. Remember this guy?

Now look at this chart.

Wow. Just wow. Multi-core 64bit desktop class chipset inside a mobile phone. That's amazing. But what happened with the software during this 10 years?

One complete redesign since the first iOS. But now we have iPads in 3 sizes, iPhones in 4 screen sizes and some kind of "black magic" to solve this...

Adaptive User Interfaces

Hahahahaha. Look at this mess. You call this an adaptive user interface? This whole term is a joke. Responsive websites are better than this shit. You can give developers size classes and auto layout, but if you don't educate them how to create adaptive apps - designers should learn the opportunities and limitations too - it's not going to work. I really believe that we need a responsive grid system, or at least something like that to help us. Stack views are good, but they are not scrollable, so we have to put them inside scrollviews, or tableviews. That's ok but it's still not an adaptive grid or layout template...

I could bet this was made with a collection view and the first two examples are not! Check out the calendar or the photos app and think for a second. If collection views are this powerful why the fuck are we not using it to build user interfaces??? Oh, wait. I am already doing this... prepare for CoreKit! I promise I'll share the progress details in my one of my next posts, but if you want to read about my existing solution, go here.

INCONSISTENCY

Let introduce you to iOS10 in pictures.

TabBar you are drunk. WTF bold text, fuck alignment.

Fat Navigation bars! Yummy...

Look it's an UFO, no it's a floating window...

Consistent search positioning...

Final thoughts: developers can argue about UIKit and AppKit differences, but until they don't get consistent building blocks - even Apple is not respecting the human interface guidelines - what are we expecting? We should really get some unified UXKit both for tvOS, iOS, macOS. There are some really nasty API differences per platforms like this.

#if os(iOS) || os(tvOS)
    public typealias AppleColor                             = UIColor
    public typealias AppleNib                               = UINib
    public typealias AppleScreen                            = UIScreen
#elseif os(macOS)
    public typealias AppleColor                             = NSColor
    public typealias AppleNib                               = NSNib
    public typealias AppleScreen                            = NSScreen

    public extension AppleScreen {
        static var main: AppleScreen {
            return AppleScreen.main()!
        }

        var bounds: CGRect { return NSRectToCGRect(self.visibleFrame) }
    }

    public extension AppleNib
    {

        convenience init?(nibName: String, bundle: Bundle?) {
            var bundleVar = Bundle.main
            if let bundle = bundle {
                bundleVar = bundle
            }
            if bundleVar.path(forResource: nibName, ofType: "nib") == nil {
                return nil
            }
            self.init(nibNamed: nibName, bundle: bundle)
        }
    }

#endif

Come on Apple you can do better than this. I really hope that in the future the company can focus more on cleaning up this mess and fixing bugs, rather than creating new iMessage extensions. It's important to have new features every year, but if you don't have a strong foundation, your building will eventually collapse.

PS. I still love appleOS's, Swift and Xcode. I was just letting off the steam... :)