Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
iOS 12 Programming for Beginners
iOS 12 Programming for Beginners

iOS 12 Programming for Beginners: An introductory guide to iOS app development with Swift 4.2 and Xcode 10 , Third Edition

eBook
€8.99 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

iOS 12 Programming for Beginners

Getting Familiar with Xcode

So, you want to get into iOS development? I was in your shoes on January 27, 2010, when Apple first announced the iPad. As soon as the conference was over, I knew that I wanted to learn how to create apps for the iPad. I signed up for the Apple Developer website and paid my $99 annual fee. But then, I realized that I did not know where to begin. A large variety of instructional books or videos did not exist, especially since the iPad hadn't released. I had previous programming experience; however, I had no idea how to write Objective-C (the original programming language for iOS). Therefore, I had to teach myself the basics. In this book, we will learn what it takes to become an iOS developer together.

If you are new to programming, take your time. You should understand the lessons that are provided in one chapter before moving on to the next. These essential skills will set you up with a solid foundation in iOS development. If you have previous programming experience, you should still review the earlier chapters, as they will be a refresher for you.

Throughout this book, we will work in Xcode, specifically Xcode 10 (and Swift 4, which we will tackle later in this book). Xcode is known as an Integrated Development Environment (IDE). Using Xcode gives us everything we will need to build apps for iOS, tvOS, macOS (formerly, OS X), and watchOS. In this chapter, we will explore Xcode to help you get more comfortable using it. If you are not on Xcode 10, make sure to update Xcode, as the code in this book will not run correctly otherwise.

Our focus in this book will be on creating a universal iOS app (an app for both the iPhone and iPad). The best way to do this is to create a project to familiarize yourself with where everything is and how to find what you need. So first, let's first download and install Xcode.

Getting started

To download Xcode, launch the App Store on your Mac and then type Xcode into the search bar in the upper-right corner:

This is the screenshot of the App Store and the blurred out information is not important here
For enhanced image quality, download the graphics bundle from https://www.packtpub.com/sites/default/files/downloads/9781789348668_ColorImages.pdf.

Next, click on INSTALL:

This is the screenshot of the App Store and the blurred out information is not important here

Once installed, launch Xcode, and you should see the following Welcome to Xcode screen:

If this is the first time you have launched Xcode, then you will see No Recent Projects in the right-hand panel. If you have previously created projects, then you will see those listed to the right. To get started, we are going to click on Create a new Xcode project in the left-hand panel of the welcome screen. You will see the new project screen, as follows:

Across the top of this screen, you can select one of the following items: iOS, watchOS, tvOS, macOS, and Cross-platform. Since we are creating apps for iOS, make sure that you have iOS selected. Then, choose Single View App and click on Next. Now, you will see an options screen for a new project:

This option screen has the following seven items to complete or choose:

  1. Product Name: The product name is your app. We are going to set ours as ExploringXcode.
  2. Team: The team connects to your Apple account. We are going to ignore this for now, because we do not need the Team for this chapter. If you already have a team set up, leave it as is. We will cover this in greater detail later in this book.
  1. Organization Name: You can set the organization name to your company name, or just use your name.
  2. Organizer Identifier: You will set the organizer identifier to be your domain name in reverse. For example, my website URL is cocoa.academy, and therefore, my identifier is academy.cocoa. Since URLs are unique, it will ensure that no one else will have your identifier. If you do not have a domain, then use your first and last names for now. However, you will eventually have to purchase a domain if you want to submit your app to the Apple Store.
  3. Bundle Identifier: When you create a new project, Apple will combine your Product Name with your Organizer Identifier to create your unique bundle identifier. So, even if 10,000 people create this project, each person will have a different bundle identifier.
  4. Language: Set language to Swift.
  5. Checkboxes: You can uncheck Use Core Data, Include Unit Tests, and Include UI Tests, as these are things that we will not use in this chapter.

Now, select Next, and Xcode will prompt us to save our project. I have a dedicated folder for all my projects, but you can save it on your desktop for easy access.

The Xcode interface

Your project is now open, and it is time for us to get familiar with all of the panels. If this is your first time in Xcode, then it will probably be a bit overwhelming for you. Therefore, we will break it down into six parts:

  • NAVIGATOR PANEL
  • STANDARD EDITOR
  • UTILITIES PANEL
  • DEBUG PANEL
  • TOOLBAR
  • WINDOW PANE CONTROLS

Navigator panel

The primary use of the navigator panel is to add new files and select existing files. The other icons are used from time to time; we will cover them as we need them.

Standard editor

The standard editor is a single panel view that's used to edit files. The standard editor area is the primary area in which you will work. In this area, we can view storyboard files, see our Swift files, or view our project settings.

Utilities panel

The utilities panel can be a bit confusing when you first use Xcode because this menu changes based on what you have selected in the standard editor. When we start building an app, we will dig deeper into this. For now, know that the utilities panel is made up of the inspector pane at the top and the library pane at the bottom. The inspector pane allows you to change the attributes or properties of things you put in your storyboard; the library pane enables you to insert objects, image assets, and code snippets into your app.

Debug panel

The debug panel will allow us to see log messages from our app. You will become very familiar with this panel by the time you finish this book. The debug panel is one of the most excellent tools for getting feedback on what your app is doing or not doing.

Toolbar

Next, we look at the toolbar, which is demonstrated as follows:

First, we have a play button, which is how we launch our app (or use command + R). Next, you will see a stop button, which will not be active until you run your app. This stop button (or command + .) is used to stop your app from running. To the right of the stop button, you will see your target (your project name), along with the current simulator that has been selected. If you click on your project name, you will see a screen similar to this:

This drop-down menu, which we will call the Device and iOS Simulators drop-down menu, allows you to change your simulator type. For our project, select iPhone7 Plus as your simulator and then click on the play icon (or use command + R) to run your app.

Now, let's return to Xcode and select the stop button (or use command + .).

If you use the keyboard shortcut, make sure Xcode is in focus; otherwise, this shortcut will not work. I work on a 15-inch MacBook Pro Retina. Therefore, when I am working on an app, I will use the iPhone X or iPad Air 2 simulator in landscape mode. They both fit nicely on my screen without me having to resize either.

In addition to the Simulator, there is a Build Only Device as well as a Device section, both of which can be found at the top of the Device and Simulator drop-down menu that was shown earlier in this chapter. Note that, for our purposes, you will only need a simulator while we are building the app; however, you can add an iOS device if you would like (see under iOS Device).

Generic iOS device

The Generic iOS Device, under the Build Only Device section of the Device and Simulator drop-down menu, is used for when you need to archive your app, which means that you are preparing your app for submission to Apple (either to the App Store or Test Flight). If you try to select Generic iOS Device now and run the app, you will get the following message:

Therefore, change Generic iOS Device to an actual simulator, and then you will be able to continue.

iOS device

If you do not have a device connected to the computer, you will see No devices connected under the Device section of the Device and Simulator drop-down menu.

As noted earlier, when we start building the Let's Eat app, you will have the option of using the simulator or connecting a device to Xcode. Using a device is slower; however, the simulator will not perform in the same way as a device will.

In the past, you needed to have a paid account to build your app on a device. Nowadays, you do not need a developer account to run the app on your device. Note that, if you decide to connect your device instead of using a simulator, you will need iOS 12 installed on it. Xcode 10 introduced the capability of connecting your phone wirelessly. We will look at the traditional way first and then we will go over how you can connect your phone wirelessly.

The following steps are only intended for those of you who do not want to pay for the Apple Developer Program at this time:

  1. Connect your iOS device via USB.
  2. In the drop-down menu, select your device (here, I have chosen Xclusive iPhone 6 Plus):
  1. Wait for Xcode 10 to finish indexing and processing. The indexing and processing may take a bit of time. Once complete, the status will say Ready.
  2. Run the project by hitting the Play button (or use command + R).

You will get two errors that state the following:

    • Signing for ExploringXcode requires a development team.
      Select a development team in the project editor.
    • Code signing requires a product type application in SDK iOS 12.0.

Ignore the specifics of these errors as they indicate that we need to create an account and add our device to that account.

  1. Now, in the standard editor, you will see under Signing that you need to add an account:
  1. Click on Add Account. If a Sign into Xcode with your Apple ID dialog box does not pop up, inside the Accounts screen on the bottom left, click on the + and select Apple ID:
  1. Then, when you click on Create Apple ID, you will be asked to enter your birth date, name, email, and password, along with a number of security questions. Make sure that you verify your email before you answer the security questions, otherwise you will have to come back to this screen and add your Apple ID again.

  1. Once you have finished all of the steps, you will see your account, as follows:

If you already have an account, then instead of seeing Add Account, you will see a drop-down menu with your account listed. If your device is not connected to this account, you might see a message asking if you would like to add your device to your account. Adding your device to an account is for testing purposes only.

Connecting wirelessly

Now that you have your phone and account connected, you can quickly get your phone set up to run wirelessly. With your device already connected via USB, go to Window | Devices, and then Simulators. Click on the checkbox marked Connect via network:

Make sure that your phone and your computer are connected to the same Wi-Fi network.

When I first connected to my device, I saw a globe icon in Xcode that lets you know that your device is connected via the network, as demonstrated in the following screenshot:

After a short time, the globe went away. Even if you do not see the icon, you can disconnect the USB, and your device should still be connected to Xcode (as long as it is connected to the same Wi-Fi network).

You will not need to use a device for this book, but it is always good to run your app in an actual device before you submit it to the store.

Before we get to the right-hand side of the toolbar, select the Main.storyboard file in your navigator panel. This file is used to display all of your visual setup for your entire app. We will this in detail later in this book. After you select the file, you should see the following:

Window pane controls

The following screenshot shows the window pane controls:

Moving on to the window pane controls, you will see two groups of icons. The first group is called the Editor Mode, and the second group is called the View. Let's look at the functions of the Editor Mode icons:

Editor Mode icons Function
This icon controls the standard editor (which is the center panel in the earlier screenshot of the Main.storyboard file in the navigator panel).
This icon splits the Standard editor into two panels, where you will see the ViewController.swift file on the right. We will use this split screen throughout this book.
This icon is the Version editor. We will not address the Version editor in this book since it is a more advanced feature.

At this point, you might be thinking that there are way too many panels open, and I would agree with you! The last panel is where the previous group of View icons in the toolbar comes in handy.

Let's look at these icons and their functions in the following table:

View Mode icons Function
This icon will toggle (hide or show) the navigator panel (or use command + O).

This icon will toggle (hide or show) the debug panel (or use command + shift + Y).

This icon will toggle (hide or show) the utilities panel (or use command + alt + O).

Summary

Congratulations! You have finished exploring the basics of Xcode. When we start building our app, we will cover the more essential parts of Xcode in depth. In the next few chapters, we will begin learning about the Swift programming language. We will use the latest Swift version, and this will be a basic intro into the programming language. If you are familiar with Swift, feel free to skip ahead to Chapter 6, Starting the UI Setup. Even if you are familiar with Swift, it is always good to go back through the basics as a refresher. So, let's get started!

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Kick-start your iOS programming career and have fun building iOS apps of your choice
  • Get to grips with Xcode 10 and Swift 4.2, the building blocks of iOS development
  • Discover the latest features of iOS 12 - SiriKit, notifications, and much more

Description

Want to build iOS 12 applications from scratch with the latest Swift 4.2 language and Xcode 10 by your side? Forget sifting through tutorials and blog posts; this book is a direct route to iOS development, taking you through the basics and showing you how to put principles into practice. Take advantage of this developer-friendly guide and start building applications that may just take the App Store by storm! If you’re already an experienced programmer, you can jump right in and learn the latest iOS 12 features. For beginners, this book starts by introducing you to iOS development as you learn Xcode and Swift. You'll also study advanced iOS design topics, such as gestures and animations, to give your app the edge. You’ll explore the latest Swift 4.2 and iOS 12 developments by incorporating new features, such as the latest in notifications, custom-UI notifications, maps, and the recent additions in Sirikit. The book will guide you in using TestFlight to quickly get to grips with everything you need to get your project on the App Store. By the end of this book, you'll be ready to start building your own cool iOS applications confidently.

Who is this book for?

This book is for you if you are completely new to Swift, iOS, or programming and want to make iOS applications. However, you’ll also find this book useful if you’re an experienced programmer looking to explore the latest iOS 12 features.

What you will learn

  • Explore the distinctive design principles that define the iOS user experience
  • Navigate panels within an Xcode project
  • Use the latest Xcode asset catalogue of Xcode 10
  • Create a playgrounds project within your projects and understand how Ranges and Control flow work
  • Study operations with integers and work your way through if statements
  • Build a responsive UI and add privacy to your custom-rich notifications
  • Set up Sirikit to add voice for Siri shortcuts
  • Collect valuable feedback with TestFlight before releasing your apps on the App Store

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Dec 24, 2018
Length: 692 pages
Edition : 3rd
Language : English
ISBN-13 : 9781789348354
Vendor :
Apple
Category :
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Dec 24, 2018
Length: 692 pages
Edition : 3rd
Language : English
ISBN-13 : 9781789348354
Vendor :
Apple
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 115.97
iOS 12 Programming for Beginners
€36.99
Hands-On Design Patterns with Swift
€36.99
Mastering iOS 12 Programming
€41.99
Total 115.97 Stars icon
Banner background image

Table of Contents

26 Chapters
Getting Familiar with Xcode Chevron down icon Chevron up icon
Building a Foundation with Swift Chevron down icon Chevron up icon
Building on the Swift Foundation Chevron down icon Chevron up icon
Digging Deeper Chevron down icon Chevron up icon
Digging into Collections Chevron down icon Chevron up icon
Starting the UI Setup Chevron down icon Chevron up icon
Setting Up the Basic Structure Chevron down icon Chevron up icon
Building Our App Structure in Storyboard Chevron down icon Chevron up icon
Finishing Up Our App Structure in Storyboard Chevron down icon Chevron up icon
Designing Cells Chevron down icon Chevron up icon
Getting Started with the Grid Chevron down icon Chevron up icon
Getting Data into Our Grid Chevron down icon Chevron up icon
Getting Started with the List Chevron down icon Chevron up icon
Where Are We? Chevron down icon Chevron up icon
Working with an API Chevron down icon Chevron up icon
Displaying Data in Restaurant Detail Chevron down icon Chevron up icon
Foodie Reviews Chevron down icon Chevron up icon
Working with Photo Filters Chevron down icon Chevron up icon
Understanding Core Data Chevron down icon Chevron up icon
Saving Reviews Chevron down icon Chevron up icon
Universal Chevron down icon Chevron up icon
iMessages Chevron down icon Chevron up icon
Notifications Chevron down icon Chevron up icon
SiriKit Chevron down icon Chevron up icon
Beta and Store Submission Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.5
(6 Ratings)
5 star 33.3%
4 star 0%
3 star 0%
2 star 16.7%
1 star 50%
Filter icon Filter
Top Reviews

Filter reviews by




Maria Urbina Jun 01, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is super easy.Ingot the book today and it was hard for me to put it down because you learn a lot and it’s well explained I’m someone with autism and I m glad I bought it. :-)
Amazon Verified review Amazon
George Matty Apr 23, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I'm into about 5 chapters. The examples are great; easy to follow and the explanations are right on. The author goes at just the right pace. He took the right approach. He teaches Swift as well as iOS 12. This book is well worth the money. I am now about to start the iOS 12 section building apps. I will updated more as I continue. Chapters are clear and easy to understand. Generally each chapter can be completed in about 2 hours or less. I'm looking forward to adding to this review once I complete this book.
Amazon Verified review Amazon
Kam Jun 11, 2020
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
I'm an experienced (5+ years, 6 monetized, published apps) Android developer who bought this book to add iOS to my portfolio. I bought the eBook on sale directly from Packt for $10, and man am I glad I didn't spend more than that.First, the good bits.1. Clean codeThis book has so much potential. It subtly teaches the use of design patterns (it doesn't specifically name them, but if you're already an experienced coder, you'll recognize them) and good programming practices, such as "separation of concerns", "D.R.Y. (don't repeat yourself), and S.O.L.I.D principles in general. I like that it's not just teaching you how to code swift, but how to write clean code, period. The end of some chapters even have you go back and refactor.2. ThoroughThe book's project, "Let's Eat", is an Open Table/Yelp style app that brings you from the basics of Swift to advanced topics not usually explored in a beginners "learn to code" book such as APIs (specifically JSON), store submission, and iMessages and Siri integration. If you take your time and carefully learn each chapter, you will be equipped to start your own project with plenty of sample code to reference from.Now the bad: TYPOS, TYPOS, TYPOS.There are so many typos that it unfortunately undoes all of the positive points I've listed above. Because I'm an experienced coder in Java/Kotlin, and patient enough to explore Apple's Swift documentation when in doubt, I was able to make it to the end of the book. But it was definitely a testament to my determination more than anything.TLDR:This book has so much potential but thanks to project-breaking typos, missing code and more, I would NOT recommend this book to anyone who is coding Swift for the first time. Because of the advanced topics it covers towards the end, it might be ok as a second book after a using one with better editing as your introduction to Swift. That way you can recognize the typos (admittedly, some are obvious) and have a bit more confidence when the sample code doesn't compile even though you copied it word-for-word.Do not pay more than $10 for this book.
Amazon Verified review Amazon
Bruce E. Hamilton Oct 14, 2019
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
Started the LetsEat tutorial. It worked for a couple of chapters then the app started crashing. Inspection revealed there appear to be some code missing. Have requested support from Packt. After a couple of weeks, nothing from Packt. Advise new iOS programmers not to purchase the book as the app will require some study and a bit of luck to make work.
Amazon Verified review Amazon
C. Thurgood Oct 13, 2019
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
My review simply echos W. Baer's review... Up to Chapter 10 - great, after that, I had to stop. I contacted Packt and although they did reply it didn't help me so regretfully I had to abandon this book. Shame as it looks like it had everything I was looking for.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.