Chapter 1
The Development Tools, the Learning Approach, and the App Idea

Since you pick up this book, I guess you want to create an iOS app. Creating an app is a fun and rewarding experience. I still remembered the joy when I first created an app years ago, even though the app is just so simple and elementary.

iOS, the mobile operating system behind iPhone and iPad, has been released for more than 10 years. The tools, the programming language and its frameworks have greatly evolved over these years. Therefore, before we dive into iOS programming, let's go through the tools you need to build an app and get prepared the mindset for learning iOS app development.

The Tools

Apple has favored a closed ecosystem over the open system. iOS can be only run on Apple's own devices including iPhone and iPad. It is very much unlike its competitor, Google, that Android is allowed to run on mobile devices from different manufacturers. As an aspiring iOS developer, what this means to you is that you will need a Mac for app development.

1. Get a Mac

Having a Mac is the basic requirement for iOS development. To develop an iPhone (or iPad) app, you need to get a Mac that is capable to run on macOS version 13.5 (or later). If you now own a PC, the cheapest option is to purchase the Mac Mini. As of this writing, the retail price of the entry model is US$599. You can hook it up to the monitor of your PC. I would recommend you to pick the basic model of Mac mini with Apple M1 chip. It should be good enough to run the iOS development tools smoothly. Of course, if you have a bigger budget, get the higher model or an iMac with better processing power.

2. Register Your Apple ID

You will need an Apple ID to download Xcode, access iOS SDK documentation, and other technical resources. Most importantly, it will allow you to deploy your app to a real iPhone/iPad for testing.

If you have downloaded an app from the App Store, it is quite sure that you already own an Apple ID. In case you haven't created your Apple ID before, you have to get one. Simply go to Apple's website (https://appleid.apple.com/account) and follow the procedures for registration.

3. Install Xcode

To start developing iOS apps, Xcode is the only tool you need to download. Xcode is an integrated development environment (IDE) provided by Apple. Xcode provides everything you need to kick start your app development. It already bundles the latest version of the iOS SDK (short for Software Development Kit), a built-in source code editor, graphic user interface (UI) editor, debugging tools and much more. Most importantly, Xcode comes with an iPhone (and iPad) simulator so you can test your app without the real devices.

To install Xcode, go up to the Mac App Store and download it. If you're using the latest version of Mac OS, you should be able to open the Mac App Store by clicking the icon in the dock. In case you can't find it, you may need to upgrade your Mac OS.

Figure 1-1. App Store icon in the dock
Figure 1-1. App Store icon in the dock

In the Mac App Store, simply search "Xcode" and click the "Get" button to download it.

Figure 1-2. Download Xcode on App Store
Figure 1-2. Download Xcode on App Store

Once you complete the installation process, you will find Xcode in the Launchpad.

Figure 1-3. Xcode icon in the Launchpad
Figure 1-3. Xcode icon in the Launchpad

At the time of this writing, the latest version of Xcode is 15. Throughout this book, we will use this version of Xcode to create the demo apps. Even if you have installed Xcode before, I suggest you upgrade to the latest version. This should make it easier for you to follow the tutorials.

4. Enroll in the Apple Developer Program (Optional)

A common question about developing an iOS app is whether you need to enroll in the Apple Developer Program (https://developer.apple.com/programs/). The short answer is optional. First, Xcode already includes a built-in iPhone and iPad simulator. You can develop and test out your app on Mac, without enrolling in the program.

Starting from Xcode 7, Apple has changed its policy regarding permissions required to build and run apps on devices. Before that, the company required you to pay US$99 per year in order to deploy and run your apps on a physical iPhone or iPad. Now, program membership is no longer required. Everyone can test their apps on a real device without enrolling in the Apple Developer Program. Having said that, if you want to try out some advanced features such as in-app purchase, push notifications or CloudKit, you still need to apply for the program membership. Most importantly, you're not able to submit your app to App Store without paying the annual membership fee.

So, should you enroll in the program now? The Apple Developer Program costs US$99 per year. It's not big money but it's not cheap either. Since you're reading this book, you're probably a newcomer and just start exploring iOS development. The book is written for beginners. We will first start with something simple. You are not going to tap into the advanced features until you grasp the basic skills.

Therefore, even if you do not enroll into the program, you will still be able to follow most of the content to build an app and test it on your device. For now, save your money. I will let you know when you need to enroll in the program. At that time, you're encouraged to join the program as you're ready to publish the app to the App Store!

The Learning Approach

I have been teaching iOS programming from 2012 through blogging, online courses, and in-person workshops. What I found is that it is the learning approach and the mindset that make the difference between failing and achieving. Before we talk about Swift and iOS programming, I want to get you equip with the right mindset and understand the most effective way to learn programming.

Get Your Hands Dirty

One of the most popular questions about learning how to code is:

What's the best way to learn iOS programming?

First, thanks for reading this book. Unfortunately, I have to tell you that you cannot learn programming just by reading books. This book has everything you need to learn Xcode, Swift, and iOS app development.

But the most important part is taking action.

If I have to provide an answer to the question, I will say "Learn by Doing". It is at the heart of my teaching approach.

Let me change the question a little bit:

What's the best way to learn English (or other foreign languages)?

What's the best way to learn cycling (or any other sports)?

You probably know the answer. I especially like this answer on Quora about learning a new language:

Follow this routine: listen 1 hour a day, speak 1 hour a day, publish 1 journal entry.

- Dario Mars Patible

You learn through practice, not by just studying grammar. Learning programming is somewhat very similar to learning a language. You need to take actions. You have to work on a project or some exercises. You have to sit in front of your Mac, immerse yourself in Xcode, and write the Swift code. It doesn't matter how many mistakes you make during the process. Just remember to open Xcode and code while reading this book.

Motivations

Why do you want to learn app development? What motivates you to sacrifice the weekends and holidays to learn how to code?

Some people begin learning app development just because of money. There is nothing wrong with that. You may want to build your app business to earn some side income and eventually turn it into a full-time business. That's completely understandable. Who doesn't want to live a rich life?

As of August 2022, however, there were over 2.2 million apps on the App Store. It is really hard to put up an app on the App Store and expect to make a load of money overnight. You'll be easily discouraged or even give up if money is your primary reason for building apps, especially when you come across articles like this:

Then reality set in.

199 units old = US$209 in sales = US$135 proceeds (net to me). In order to get the app on the app store I needed to pay the $99 developer fee.

So after 2 months and 1 week my (before tax) profit was $36.

- James

Programming is hard and challenging. I find people who successfully master the language are those who have a strong desire to build apps and are enthusiastic to learn programming. They usually have an idea in their mind and want to turn it into a real app. Making money is not their number one concern. They know the app can solve their own problems and will be beneficial to others. With such a powerful purpose in mind, they can overcome any obstacles come up.

So, think again why you want to learn programming.

Find a Buddy

"The best way to learn is to teach" is an old saying. It still works in the modern world, however. You don't need to be an expert to teach. I'm not talking about giving a lecture at a university or teaching a bunch of students in a formal class. Teaching does not always happen that way. It can be as simple as sharing your knowledge with a colleague or a classmate sitting next to you.

Try to find someone who is also interested in learning iOS programming. When you learn something new, try to explain the materials to your buddy. For example, after building your first app, teach your close friend how it works and how he/she can create an app too.

What if you can't find a buddy to share what you've learned? No worries. Start a blog on medium.com (or whatever platforms you like), write a blog post every day, and document everything you learn.

This is one of the most effective ways of learning as I learn so much while publishing tutorials on appcoda.com, as well as, developing my first book.

Sometimes you think you know the materials well. But once you need to explain the concept to someone else and answer questions, chances are that you didn't understand the material thoroughly. This will motivate you to study the materials even harder. Give this method a shot while you learn iOS programming.

Be Patient

Grit is passion and perseverance for very long-term goals. Grit is having stamina. Grit is sticking with your future, day-in, day-out. Not just for the week, not just for the month, but for years. And working really hard to make that future a reality. Grit is living life like it’s a marathon, not a sprint.

- Dr. Angela Lee Duckworth

Some of my students asked, "How long would it take to become a good developer?"

It takes time to master programming and become a great developer. It usually takes years. Not weeks, not months but years.

This book will help you kick start the journey. You will learn all the basics of Swift and iOS programming and eventually, build an app. That said, it takes time and lots of practices to become a professional programmer.

Be patient. Don't set your expectations too high for your first app. Just enjoy the process, create something simple and fun. Keep reading and coding daily. You will eventually master the skill.

Find Your App Idea

I always encourage my students to come up with their own app idea when start learning app development. The idea doesn't have to be big. You do not need to build the next Uber app or come up with a new idea to change the world. You just need to start with a very small idea that solves a problem.

Let me give you a couple of the examples.

One classic example that I used to mention is Cockpit Dictionary. It is an app built by Manolo Suarez, who is a pilot by profession. He had an app idea while learning app programming. The idea was not fancy but solved his own problem. There are tens of thousands of Aviation terms in abbreviated form. Even for an experienced pilot with over 20 years of aviation experience, it is impossible to remember all the acronyms and technical terms. Instead of using a print dictionary, he thought of building a handy app for pilots to look up all kinds of Aviation terms. A simple, yet a great idea to solve his own problem.

Figure 1-4. Cockpit Dictionary
Figure 1-4. Cockpit Dictionary

Another example is the NOAA Buoy Data app. While this app is no longer available on the App Store, I still want to quote it as an example. The app was designed to retrieve the latest weather, wind, and wave data from the National Oceanic and Atmospheric Administration’s (NOAA) National Data Buoy Center (NDBC). Developed by Leo Kin, he came up with the app idea during his recovery from surgery.

"After the surgery, I had to wear a neck brace for three months. During those three months, I couldn’t move a lot and even had a hard time walking or even raising my arms. My physical therapist advised that I go walking as much as I can to get exercise and to build back my atrophied leg muscles.

There is an island close to where I was living that I really enjoyed walking to. The only problem was that it can only be reached during low tide. And if the tide came in, there’s no way to get back home except by swimming. Since I was very physically weakened, I was very scared of getting stuck on the island with no way back. While walking, I was always going to NOAA’s website to check how high or low the tide was and if I had enough time to walk to the island and back.

During one of my walks, the idea came to me that I should build an app. Even if no one else uses the app, it wouldn’t matter because it would help me keep track of the tides and get back in time."

- Leo Kin

His app may not interest you, but it was solving a problem he faced at the time. Probably people on that island would benefit from his app too.

Figure 1-5. NOAA Buoy Data app
Figure 1-5. NOAA Buoy Data app

Having your own app idea will give you a clear goal and motivate you to keep learning. Now spare some time and write down three app ideas below:




UIKit vs SwiftUI

Which UI framework should you learn? As a beginner, you may have come across these two terms: UIKit and SwiftUI. Some individuals advocate learning UIKit for app development, while others suggest that you can bypass UIKit and directly immerse yourself in SwiftUI, considering it as Apple's latest UI framework.

I understand that these technical terms might be confusing. Let me provide you with a brief overview of both frameworks, so you can gain clarity on which one to prioritize.

Figure 1-6. Building apps using UIKit and Interface Builder
Figure 1-6. Building apps using UIKit and Interface Builder

First, both frameworks allow you to build great apps. The UIKit framework is the original UI framework available since the first release of iOS. With UIKit, you can write code to build the mobile app UI or create app layouts using Xcode's Interface Builder. One of the downsides, however, is that the framework is more complicated to learn as compared to SwiftUI.

Figure 1-7. Building apps using SwiftUI
Figure 1-7. Building apps using SwiftUI

With SwiftUI, you can develop the UI of your app using a declarative Swift syntax. This means that writing UI code becomes easier and more intuitive. In comparison to existing UI frameworks like UIKit, you can achieve the same UI design with significantly less code.

The preview function has always been a weak point of Xcode. While you can preview simple layouts in Interface Builder (or Storyboard), obtaining a complete preview of the UI was often only possible once the app was loaded onto the simulators. SwiftUI changes this by providing immediate feedback on the UI as you code. For instance, when you add a new record to a table, Xcode dynamically updates the UI in a preview canvas. Additionally, previewing your UI in dark mode or making other adjustments is as simple as changing an option. This instant preview feature streamlines UI development and significantly accelerates the iteration process.

Now, let's address the core question: as a beginner, which framework should you learn?

You should ask yourself why you want to learn iOS programming. What are your goals? Do you aim to pursue a professional career as an iOS developer and secure job opportunities? Or are you simply interested in learning something new as a hobby?

If your goal is to establish a career in iOS development, my suggestion is to learn both frameworks. However, it is advisable to start with UIKit, as many companies still rely on it for app development. Acquiring UIKit skills will be invaluable in enhancing your employability. Therefore, I recommend familiarizing yourself with UIKit first, followed by SwiftUI.

On the other hand, if you are pursuing programming as a hobby or working on an app as a side project, I recommend diving directly into SwiftUI. It is easier to learn and allows you to build apps with less code. Occasionally, you may encounter the need to utilize specific UI components from UIKit. In such instances, you can learn how to incorporate those particular UIKit components. So, prioritize learning SwiftUI initially, and subsequently delve into UIKit when the need arises.

Summary

That's all for the introduction. Take some time to install Xcode on your Mac, brainstorm your app idea, and select the framework you wish to concentrate on. We offer both UIKit and SwiftUI books, which will assist you in acquiring the necessary skills for developing your own apps.

If SwiftUI is your focus, proceed to the next chapter and we will start programming in Swift.

Prepare yourself for the exciting journey ahead!

results matching ""

    No results matching ""