Lesson 1 - Developing iOS apps in Swift
Welcome to the introductory tutorial focusing on the basics of app programming for Apple mobile devices. That means, of course, iPhone, but also iPad, because you can develop for both devices at the same time. In this introductory lesson, we're going to talk about reasons to choose this platform, what we're going to need, and the Xcode editor.
Why should we choose iOS? Because it's an important mobile platform and Apple sells loads of new devices every quarter. When developing, you don't have to deal with dozens of display sizes, different aspect ratios, or user system versions, which you would run into when developing for Android. iOS users are used to paying for high quality applications, even a few dollars. However, you should choose iOS if the platform is close to you and you want to start programming cool applications for your mobile assistant.
If you happen to be wondering why Swift and not Objective-C (in which iOS applications were written in the past), this short paragraph is just for you. It's simple. Swift is the future of iOS development, it's a modern, object-oriented language that offers cool features. You won't be screaming in agony because of a missing semicolon, and if you write it to the end of the line out of habit, nothing bad happens. Swift, unlike Objective-C, isn't 25 years old, and provides programmers with automatic memory management to avoid a huge amount of errors that are otherwise difficult to find. In addition, it includes null-safety and other advanced mechanisms for you to make even less mistakes in your code. If these reasons aren't enough, look for some Objective-C code samples, which should surely convince you why you want to use Swift
- iOS device
- Xcode 9 (you can find it in AppStore)
- OOP level Swift knowledge
- desire to learn something new
You don't need any real iOS physical device. Xcode provides us with simulators for every relevant device. Of course, it's the best to test the app on a real device, especially if you don't have a powerful Mac, not using simulators will help with the performance. Besides, you can't do some things in the simulator which can be problematic. If you read the article up until here, I guess you already own an iOS device.
We explained why and what to develop with. Let's quickly get to know the environment in this introductory lesson and then dive straight into programming.
Let's do this. Meet Xcode. First, have a look at the picture below where I highlighted the important parts of the program with different colors. Check it out and then read the description below.
- Brown - Here you'll run the app, close the app, choose on which device should the app run (your iPhone / simulator). If you have more complex project, you can also choose what to run here.
- Blue- Switching editor and customizing UI. The second button of the first three switches to Assistant editor. That's useful in the case you need the UI and the code to be opened at the same time. We'll use this when connecting the UI with the code. We'll learn everything in further lessons. The next three buttons simply hide parts of Xcode to get more space, which you'll surely use on a laptop.
- Yellow - The "inspector" area. These are your helpers when
building the UI. Some important inspectors are Identity, Attributes, and Size.
We'll get to them later, so just a quick description. You'll primarily assign
your classes to the UI components in Identity. Attributes is probably most often
used with the
Labelcomponent. Here you can set its height, the text, color and so on. Size deals with sizes.
- Red - Libraries, especially the library of UI components
but also e.g. of predefined code or file templates. Here you can find all UI
elements you need. Use searching to find them easily. And a hint: If you needed
Viewcomponent, write "uiview" in the search bar, because only "view" would first show the specific variants such as
TableView, etc. You can try it in next lessons, when we'll get to it.
- Green - The final part of our Xcode tour. Here you can find
your project files. You can organize them as you wish (except for
Info.plistwhich has to be in the root directory).
What will come in the next lessons?
The course is designed to teach you all the necessary basics of the iOS
development. We'll look at how the UI works, how to link the components to the
code, how the navigation to different pages of the application works. We'll look
TableView in detail, one of the most important UI components.
We'll also look at how to make work easier by using packages (libraries) to help
us with colors, JSON processing, HTTP request, etc. You can also look forward to
different ways of saving data.
Let us know what you think
I certainly don't consider myself a flawless master in writing tutorials, if there's a problem somewhere or some part isn't quite clearly explained, I'll be pleased if you let me know, for example, in the comments section below or via messages, so I can improve the materials. Thanks!
In the next lesson, Building the UI and introduction to basic components, we'll talk about creating theUI and describe basic components.
No one has commented yet - be the first!