Book Image

iOS 13 Programming for Beginners - Fourth Edition

By : Ahmad Sahar, Craig Clayton
Book Image

iOS 13 Programming for Beginners - Fourth Edition

By: Ahmad Sahar, Craig Clayton

Overview of this book

iOS 13 comes with features ranging from Dark Mode and Catalyst through to SwiftUI and Sign In with Apple. If you're a beginner and are looking to experiment and work with these features to create your own apps, then this updated fourth edition gets you off to a strong start. The book offers a comprehensive introduction for programmers who are new to iOS, covering the entire process of learning the Swift language, writing your own apps, and publishing them on the App Store. This edition is updated and revised to cover the new iOS 13 features along with Xcode 11 and Swift 5. The book starts with an introduction to the Swift programming language, and how to accomplish common programming tasks with it. You'll then start building the user interface (UI) of a complete real-world app, using the latest version of Xcode, and also implement the code for views, view controllers, data managers, and other aspects of mobile apps. The book will then help you apply the latest iOS 13 features to existing apps, along with introducing you to SwiftUI, a new way to design UIs. Finally, the book will take you through setting up testers for your app, and what you need to do to publish your app on the App Store. By the end of this book, you'll be well versed with how to write and publish apps, and will be able to apply the skills you've gained to enhance your apps.
Table of Contents (33 chapters)
1
Section 1: Swift
10
Section 2: Design
15
Section 3: Code
26
Section 4: Features

Running the app in the Simulator

The Simulator gives you an idea of how your app would look and behave if it were running on a device. It can model a number of different types of hardware—all the screen sizes and resolutions for both iPad and iPhone—so you can simulate your app on every device you're developing for.

To run the app in the Simulator, perform the following steps:

  1. Click the Scheme menu in the toolbar and you will see a list of Simulators. Choose iPhone 11 from this menu:
  1. Click the Play button to install and run your app on the currently selected Simulator. You can also use the command + R keyboard shortcut.
  2. If you see the Developer Tools Access dialog box, enter the Mac's admin Username and Password and click Continue:

  1. The Simulator app will launch and show a representation of an iPhone 11. Your app displays a white screen, as you have not yet added anything to your project:
  1. Switch back to Xcode and click on the Stop button (or type Command - .) to stop the currently running project.

You have just created and run your first iOS app in the Simulator! Great job!

If you look at the Scheme menu, you may be wondering about what the No Device and Build Only Device menu items are for. Let's take a look at them.

Understanding the No Device and Build Only Device menu items

You learned how to choose a Simulator in the Scheme menu to run your app in the previous section. But what are the No Device and Build Only Device menu items for? Well, Xcode not only allows you to run apps on the Simulator, but it also allows you to run apps on actual iOS devices, and prepare apps for submission to the App Store.

By clicking the Scheme menu in the toolbar, you will see the entire menu, and at the top of the menu are the No Device and Build Only Device sections:

The No Device section currently displays text stating No devices connected to 'My Mac'... because you currently don't have any iOS devices connected to your computer. If you were to plug in an iOS device, it would appear in this section, and you would be able to run the apps you develop on it for testing. Running your apps on an actual device is recommended as the Simulator will not accurately reflect the performance characteristics of an actual iOS device, and does not have some hardware features and software APIs that actual devices have.

The Build Only Device section has only one option, Generic iOS Device. This is used when you need to archive your app prior to submitting it to the App Store. You'll learn how to do this in the last chapter of this book.

Now let's see how to build and run your app on an actual iOS 13 device. The vast majority of the instructions in this book do not require you to have an iOS device though, so if you don't have one, skip the next section and go straight to Chapter 2, Simple Values and Types.