iOS turned 10 last month
and the platform is definitely showing signs of maturity. Swift has been officially supported for 3 years now, and is currently moving on to version 4. New frameworks and functionality are being pushed out annually, and this is definitely helping to move the industry forward as a whole. CoreML and ARKit are both poised to transform the mobile landscape, and iPhone 8 rumors are creating buzz for iOS’s future. With all this excitement in mind, I decided to spend some time getting familiar with what it’s like to be a new developer in an ecosystem that is already a decade old. In the coming paragraphs, you’ll see why now is as good a time as any to get into iOS development.
The goal of this post is to help beginners get comfortable with the Language’s, Tools, and Patterns regarding iOS development. Please note that you will need a Mac in order to do the type of development for iOS that I discuss here. There’s a good chance that I suffer from some sort of bias that will cause me to gloss over some things that might be unfamiliar to people who are very new to programming and development in general. If that is the case, please feel free to leave a comment or message me for clarification. If you’re already a developer and have worked on iOS before, this post probably won’t teach you anything new. Still, it’s always good to remind ourselves what it’s currently like for new entrants in our respective fields. Extend the Empathy people!
For those who don’t know, Swift is an open-sourced programming language developed by Apple for use in its many platforms, as well as for back-end server development. Swift was released in June 2014 and was made open-source in 2015 by Apple. The great thing about learning iOS development with Swift is the high-quality free material that Apple provides for you to learn. Swift Playgrounds is a free iPad app that helps you learn Swift in fun and interactive ways. Don’t have an iPad? Me either! That’s why I used The Swift Programming Language and App Development With Swift which are both free in the iBooks store. Having the official language documentation is just about as close as you’ll get to learning all of the nuances and best practices in iOS programming. If you’re like me, however, and you have a weird fetish for physical formats, I’d recommend the Swift Programming book by the folks at Big Nerd Ranch. Just be warned that this book is starting to show its age with Swift coming very close to a stable release of version 4.
Even though Objective-C is derived from the C family of languages, it still somehow comes across as alien to many beginners who are already familiar with the C family. Make no mistake, Objective-C is a beast at what it does, but it was apparently lacking so much that Apple felt compelled to promote and develop Swift. Now, I have no personal opinion on this topic. I come from a C++ background, so I hold no loyalty to either Swift or Objective-C. That said, Objective-C is still incredibly prevalent in iOS development. The folks at Team Treehouse wrote this post about the differences between Objective-C and Swift, which will do a much better job at examining that aspect for you. In the meantime, it’s important to understand that many of the best iOS libraries¹ were written in Objective-C and many of those have yet to be ported over to Swift. Additionally, you want to consider that many existing products that use Objective-C will need support, so if you’re inheriting a project from someone else, you may be required to know it.
¹ For those who don’t know, a library is essentially a set of code written by other developers. There are many, many libraries for many different platforms, and a lot of them are free to use in your own projects.
XCode is stable in version 8 right now, and version 9 beta 4 was just announced today (July 24, 2017). As with any IDE or enterprise level software, XCode can be large and very intimidating at first. If you’ve never experienced XCode, I encourage you to download it for free from the App Store and poke around a bit. One thing you might notice is the “Get started with a Playground” button on XCode’s home screen. Playgrounds are a great way to get your feet wet with some Swift or Objective-C code without having to create a full-blown iOS or MacOS project. You should use a Playground whenever you want to mess around with code that doesn’t require a graphical interface.
XCode – Interface Builder
As of XCode 5, Apple has been shipping Interface Builder with XCode as a way of developing apps visually. This sort of development is often referred to as WYSIWYG (sometimes pronounced wizzy-wig). There are two things to note about Interface Builder:
- You are not required to use it to build apps (you can do it programmatically too), but Apple encourages it.
- It has a bad name in some developer circles, mostly because of its inability to figure out human intent (Alan Turing would snicker at this).
It’s best to reserve judgment on IB, as it can be very helpful for beginners in reasoning about their app layouts and design. You can find more information about Interface Builder and XCode here.
I don’t mean to be ambiguous with my wording, but I’ll admit that “The Patterns” isn’t very obvious or useful in and of itself. I do, however, want to reinforce the term over and over again in this post, as I believe it to be perhaps the most important topic I am going to discuss. The term Design Pattern generally refers to a set of solutions that are commonly used in any given programming paradigm. There are Design Patterns for iOS, Object Oriented Programming, Web Development, and so on. Some Design Patterns even transcend paradigms and are applicable in any paradigm you choose. As it relates to iOS development, one thing you must understand is that you’ll be using Design Patterns almost literally everywhere in your code. Most of the frameworks that Apple puts out follow the Object Oriented Pattern, which in turn allows for a variety of Sub Patterns such as the Singleton Pattern, the Factory, and the Observer. Each of these patterns will be useful in some aspect of your program and are often used without you even realizing it.
Going in depth on Design Patterns is beyond the scope of this post, but I urge you to do a minimum of 2 hours research on common iOS Design Patterns in order to get your feet wet and prime your mind to be receptive to them as you carry on learning about iOS. There’s a PDF for free from the University of Colorado, and a very extensive Introduction to iOS Design Patterns in Swift. If you’re interested in a Video Series (NOT FREE), you can check out this fantastic course by the team at raywenderlich.com.
The Take Away
We’ve covered the essentials of iOS development in only a few paragraphs. From a top-level view, it seems very easy, and you know what? It is! You don’t need to be a Computer Science major to develop apps on iOS because the tools, languages, and patterns are very accessible to anyone who’s willing to put in the effort and learn them. You really don’t need much more then what I’ve shown you thus far in order to create some killer apps, the rest is all about getting into the right mindset and learning as much as you can.
As a word of advice, I’d recommend that you do make your study sessions very deliberate. What I mean by this is that you go into a study session with a goal in mind and keep working until you achieve that goal. This “soft skill” can definitely make the difference between a great developer and a mediocre one. An example of deliberate study would look like this:
Me: I want to add camera functionality to my app. My brain: How can you do that? Me: Apple's documentation is saying I need to learn the AVFoundation framework. My brain: Welp, Rob, it's time to get to work. Grab some coffee and get to work on reading that documentation.
Oh yeah, and learning to love reading through documentation is a key skill for all programmers, so do yourself a favor and learn to love it!
We’re Not Done Yet
“The journey of 1000 miles starts with the first step”
Or something like that…
So far, I’ve given you a very high-level overview of some of the core technologies and mental models you need to adopt in order to start developing for iOS. It’d be nice to call it quits here and send you on your way, but I’m not quite done yet. No introduction to iOS development would be complete without a Hello World tutorial! (
hurrayyyy 🎉). If you still haven’t downloaded XCode, please do so now. Ready? Let’s go.
Step 1: Open Xcode and select “Get started with a Playground”
Step 2: Enter “HelloiOS” for the Playground name and click “Next”
Step 3: Choose Desktop from the dropdown menu and hit “Create”
Step 4: Delete the code from line 5 and insert the following code in its place
You should now see the output from your print statement:
That’s it! If this is your first time writing code, congrats, you’re on your way!
There are some things to keep in mind as you progress through your iOS development journey. Here are a few common questions I see on Reddit and other discussion boards that you may have as well.
- How do I make my first app?
- First of all, you should go into it with the right mindset and expectations. The first app I made was, quite frankly, terrible. The layouts were messed up when I rotated the phone, the pictures didn’t appear where I wanted them, and my code crashed the app over and over. What’s really important in this “infant” stage of learning is to be persistent and keep going. If you notice something is broken in your first app, take the time to fix it to satisfaction. This will make you a much stronger developer in the long run, and buggy code will cower in your presence.
- Second, try starting out with the tutorials in the books that I linked you to above. The official Apple books (in iBooks) has plenty of starter projects that will let you build and learn at the same time. Once you’ve done these and you feel you’re ready to branch out, you can use a common development pattern known as “Storyboarding,” in which you draw your app on paper before you write the code or build the interface.
- Third, after drawing your app on paper, start to put pieces together in the Interface Builder. Use things like background color, background images, buttons, labels, and image views to create something that resembles your drawing. Once you have a basic layout done, learn how to connect code to the various objects on your storyboard. There’s nothing more satisfying than seeing your first button change a label by setting it up in some code.
- Your first app will likely be unimpressive to everyone but you and your mom, and that’s ok. Keep thinking up ideas for future apps as you carry on with learning about XCode, Swift, Objective-C and the various Apple frameworks. Over time, you’ll start to formulate ideas and implement them in your projects!
- Should I learn Swift or Objective-C?
- As I mentioned above, this is kind of a loaded question. There’s really no right answer here, and it will depend entirely on your situation. If you’re doing iOS development as a hobby or as an aspiring developer, I’d say start with Swift and pick up Objective-C as you need it. If you’re a current developer or you’re hoping to score a gig at an established company, you might do good by stretching your efforts and learning both. Either way, remember to take it slow and study, study, study.
- How do I learn to use Apple’s frameworks?
- Be careful here. There have been plenty of programmers who felt that all this low-level stuff was, well, below them. It’s easy to get enamored and bite off more than you can chew. Start slowly with the guide I provided you above, and when the time is right and you actually need to know a framework to help build your app, you’ll know it. When that time comes, refer to Apple’s extensive documentation for help with specific frameworks.
That’s a wrap!
I hope this guide has been useful to you, future iOS programmers! If it has, I’d love to hear your feedback in the comments below or as a personal email. Additionally, if you have any comments, questions, or advice for me (because I too, am a lifelong learner), I’d love to hear from you as well.
Until next time,