Now that you are familiar with the iOS ecosystem, it's time to discover the tools that you'll use to develop your first iPhone application.
iOS development strategy
Front-end or back-end?
In short, a back-end developer is responsible for the server-side implementation, or a site's back-end. The server's role is to support client applications by providing the necessary data exchange. The back-end software is running on a computer (a server, in this case) and is not directly accessible by a user.
What is a client application?
Client applications are all the apps that users interact with on their devices (client devices): laptops, smartphones, or tablets. As you can guess now, a front-end developer is responsible for the client-side implementation.
Where do iOS developers fit in?
As we established, iOS developers create applications for mobile devices, therefore iOS developers are front-end developers. And the mobile devices - iPhone, iPad and iPod Touch - are clients.
Native vs. hybrid
There are 2 development strategies: native and hybrid.
Let's consider first that there are multiple operating systems for phones and mobile devices like we saw in the last chapter, such as Android, iOS, and Windows. If we want people to install our app on all these platforms, we need to ensure they all know how to interact with our application. This can be done in 2 ways.
The first one is to make sure our app is developed specifically for a particular platform. This also means that we have to develop 3 different apps: one for each platform. This is called native development.
The second way is to assume some level of compatibility and create some form of application that all platforms can understand. Simply speaking, this is a website! In this case, you develop only one hybrid application: a website encapsulated in an application that you can install on all the platforms. Contrary to the native application, a hybrid application is platform-independent.
Therefore, building a hybrid app means developing your code once and installing it on the platforms. This sounds efficient! Native development means developing multiple times. This sounds like a waste of time.
Why do the 2 strategies co-exist?
Let's go back to our analogy of preparing a presentation for a multilingual conference.
If you are presenting in a particular language to people who are all fluent in this language, you can utilize all the nuances of the language: jokes, expressions etc. You'll therefore create a more interesting presentation that provides a more memorable experience for the participants. This is a metaphor for native development.
If you are presenting in a common language to a multinational crowd, you assume that all participants have a common level of language proficiency. Some may be more fluent than others, and you will have to always consider this limitation and make sure your presentation is accessible to all the participants. Nevertheless, you can still create a great presentation; you just will not be able to take advantage of all the specifics of a language. This is a metaphor for hybrid development.
Here are the key benefits of developing a native application:
User experience: Users of each platform expect certain style visuals, layout and interactions that contribute to the core of expected user experience. A classic example: a back button on Android phones that is expected to act similarly to the back button in a browser. It would be redundant and even confusing to have a touch button with an Android app that would do the same. iPhones don't have such a button, therefore requiring a touch button to perform this function when needed.
Specific functionality: Developing native applications enables you to leverage access to platform-specific hardware and software features, at times uniquely available on a particular platform.
Performance: Having the most direct access to the device resources ensures the opportunity for optimal performance: app responsiveness, usage of internal and external resources (i.e. processing power, storage management, battery etc).
Stability: Dealing with only native components also means the least amount of dependencies. This, in turn, simplifies development and testing and maintenance processes, resulting into more stable applications in the long run.
There's a variation of multi-platform (cross-platform) development that uses tools that allow writing code in a unified language and then translating it into the languages of each particular platform. At the end, you do get a native app for each platform without having to write an app multiple times.
Isn't this mixed approach a perfect solution then?
Not quite, for the following reasons:
Developers of supporting tools gain access to the native innovations only when they become available (at least in beta). They have limited time for incorporating the innovations and improvements into their environment.
Compromising or omitting a native feature altogether for a sake of unification is unfortunate. Say that only one of the 3 platforms introduces a cool feature that's not supported on other platforms. The multi-platform tool will not introduce this feature.
Tools are required to prove that everything works across platforms, which results in either compromised stability or longer time required to ship new features.
Existing tools are quite immature and their future is not guaranteed.
Here's a summary of native vs. hybrid strategies:
Now that you know you're going to be a front-end developer specialized in native iOS development, let's find out what exactly we are going to deal with!
To create an application, or to program an application, we need to use a programming language.
As humans, we use languages (spoken language, sign language, braille) to communicate with one another. Similarly, to communicate to a computer, we must use a machine language. Ultimately, computers 'speak' in binary - using only two symbols 0 and 1 (or yes and no).
For instance, a simple word 'Hi' is expressed in binary as
01101000 01101001(a.k.a. machine code).
It is! This is why we have programming languages. Programming languages serve as interpreters between programmers and machines.
There are two categories of programming languages: low-level and high-level.
The closer the language to machine code, the lower the level of the language. The more the language is abstracted from machine code, the higher the level of the language.
The ultimate example of a low-level programming language is Assembly, which is only one level of abstraction from machine code.
The more abstraction levels we introduce, the more efficient it is for programmers.
There are currently two programming languages for native iOS development: Objective-C and Swift. Both are high-level.
Here's an overview of programming languages in human-computer relations:
Objective-C was originally developed in the early 1980s. It was selected as the main language for the NeXTSTEP operating system developed by NeXT, a company founded by Steve Jobs.
NeXTSTEP is an ancestor of operating systems OS X (now MacOS) and iOS. You will later notice the NS prefix in many terms of Objective-C. It refers to the abbreviation of NeXTSTEP.
Until 2014, Objective-C was the only language in which to develop native applications for iOS devices.
The first public version of Swift was released at the WWDC conference on June 2, 2014. It originated from the work of Chris Lattner. His original intention was to improve Objective-C. He ended up creating a whole new language: Swift!
It's interesting to note that people do attempt to improve programming languages quite often, and it's common to achieve great results. However, brand-new programming languages don't come around that often. Let's illustrate such an evolution over several decades:
There had been a 14-year gap before Swift. As you can see, most languages are over 20 years old, which is centuries in computer science! Since its release, it has been improving every year. It's got tremendous support from developers around the world. At the end of 2015, Swift became open source. Now, it's in the hands of a well-managed developer community.
Swift is the natural choice for this course!
A framework is a set of software features gathered in a module. Let's take a car as an example:
A car is a composition of complex mechanical and electronic components. Most of us learn how to drive one without worrying about every detail of how exactly it functions inside. We can speed up, slow down, or change directions with ease.
A framework is similar to a car! It's a software building system that handles all the necessary functionality that's required within that block. It's another level of abstraction built on top of a programming language.
iOS incorporates many frameworks. They help us handle complex tasks by using simple commands.
There are two frameworks that we will use constantly:
Foundation: As its name indicates, this one is the essential component ! It allows us to manage various core elements, such as numbers, dates, text, communication between different objects of the code, etc. In short, it handles the basics!
UIKit (User Interface Kit): This framework is responsible for the user interface: the elements we see on the screen. It contains many elements like buttons, lists, text inputs, and so on. It also manages user interaction, like gestures, text etc.
These two frameworks are combined in an umbrella framework called Cocoa Touch. it is indeed very convenient that we can combine frameworks like the pieces of a puzzle!
You will use the Cocoa Touch framework to develop iOS applications.
What do we use to code?
Here we are. It's time for the final touch!
First, you need a Mac computer. One of these:
Second, you need coding software! This software is called Xcode, and it is provided for free by Apple. Xcode is an IDE (Integrated Development Environment).
An IDE is software that allows developers to program efficiently. In general, it contains at least three features:
A text editor: This allows the programmer to write. Microsoft Word is a very well-known example of an editor, but of course, that's not what you should use to program. Similar to how Word assists in writing text in a spoken language, an IDE's editor takes care of the specifics of a programming language. It suggests what words to use and can guess a programmer's intention, highlights mistakes, and styles code to enhance readability.
A compiler: This is that language interpreter we talked about earlier in this chapter. It verifies that the code is valid, translates it into machine code, and validates the result, confirming that it's ready to be executed or, alternatively, points out the issues it discovered.
A debugger: The debugger allows a programmer to identify and correct bugs.
This is how Xcode looks:
This looks intimidating?!
Not to worry, we will go over the details of the Xcode interface and functionality in the following chapters. It's simpler than it looks !
Let's get it up and running on your Mac! To install Xcode, simply perform following steps:
Step 1: Launch the App Store app on your Mac
Step 2: Search for the Xcode app in the App Store:
Step 3: Click 'Install' under the Xcode icon:
You are now all set! You have everything you need to create your first iOS app!
You will become:
A front-end developer
Specialized in native iOS development
Develop apps using a Mac equipped with Xcode IDE
Write code in the Swift language using the Cocoa Touch framework (Foundation + UIKit)