Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
iOS 13 Programming for Beginners

You're reading from   iOS 13 Programming for Beginners Get started with building iOS apps with Swift 5 and Xcode 11

Arrow left icon
Product type Paperback
Published in Jan 2020
Publisher Packt
ISBN-13 9781838821906
Length 822 pages
Edition 4th Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Craig Clayton Craig Clayton
Author Profile Icon Craig Clayton
Craig Clayton
Ahmad Sahar Ahmad Sahar
Author Profile Icon Ahmad Sahar
Ahmad Sahar
Arrow right icon
View More author details
Toc

Table of Contents (33) Chapters Close

Preface 1. Section 1: Swift
2. Getting Familiar with Xcode FREE CHAPTER 3. Simple Values and Types 4. Conditionals and Optionals 5. Range Operators and Loops 6. Collection Types 7. Functions and Closures 8. Classes, Structures, and Enumerations 9. Protocols, Extensions, and Error Handling 10. Section 2: Design
11. Setting Up the Basic Structure 12. Building Your App Structure in Storyboard 13. Finishing Up Your App Structure in Storyboard 14. Modifying and Configuring Cells 15. Section 3: Code
16. Getting Started with MVC and Collection Views 17. Getting Data into Collection Views 18. Getting Started with Table Views 19. Getting Started with MapKit 20. Getting Started with JSON Files 21. Displaying Data in a Static Table View 22. Getting Started with Custom UIControls 23. Getting Started with Cameras and Photo Libraries 24. Understanding Core Data 25. Saving and Loading from Core Data 26. Section 4: Features
27. Getting Started with Dark Mode 28. Getting Started with Mac Catalyst 29. Getting Started with SwiftUI 30. Getting Started with Sign In with Apple 31. Testing and Submitting Your App to the App Store 32. Other Books You May Enjoy

Using an iOS 13 device for development

Although you'll be able to go through most of the exercises in this book using the Simulator, it is recommended to build and test your apps on an actual iOS device, as the Simulator will not be able to simulate some hardware components and software APIs.

For a comprehensive look at all the differences between the Simulator and an actual device, see this link:
https://help.apple.com/simulator/mac/current/#/devb0244142d.

In addition to your device, you'll need an Apple ID or a paid Apple Developer account to build and run your app on your device. You'll use the same Apple ID that you used in the App Store for now:

  1. Use the USB cable to connect the iOS device to your Mac.
  2. In the Scheme menu, choose your device (iPhone in this case):
  1. Wait for Xcode to finish indexing and processing, which will take a while. Once complete, Ready will be displayed in the status window.
  2. Run the project by hitting the Play button (or use command + R). You will get the following error: Signing for "Exploring Xcode" requires a development team:

This is because a digital certificate is required to run the app on an iOS 13 device, and you need to add an Apple ID or a Developer account to Xcode so the digital certificate can be generated.

Certificates ensure that the only apps that run on your device are the ones you authorize. This helps to protect against malware. You can also learn more about them at this link: https://help.apple.com/xcode/mac/current/#/dev60b6fbbc7.
  1. Click the Add Account... button:
  1. The Xcode Preferences window appears with the Accounts pane selected. Enter your Apple ID and click Next. Note that you can create a different Apple ID if you wish using the Create Apple ID button:
  1. Enter your password when prompted. After a few minutes, the Accounts pane will display your account settings:
  1. Close the Preferences window when you're done by clicking the red button in the top-left corner.
  1. In Xcode's editing area, Click Signing & Capabilities. Make sure Automatically manage signing is ticked and Personal Team is selected from the Team pop-up menu:
  1. If you still see errors in this screen, try changing your Bundle Identifier by typing some random characters into it, for example, com.12345myname.Exploring-Xcode.
  2. Everything should work now when you build and run, and your app will be installed on your iOS device. However, it will not launch and you will see the following message:

This means you need to trust the certificate that has been installed on your device.

You can also access Xcode preferences by choosing Preferences in the Xcode menu.

In the next section, we will see how to do that.

Trusting the Developer App certificate on your iOS device

A Developer App certificate is a special file that gets installed on your iOS device along with your app. Before your app can run, you need to trust it. Let's do that now:

  1. On your iOS 13 device, tap Settings.
  2. Tap General.
  3. Tap Device Management:
  1. Tap Apple Development:
  1. Tap Trust "Apple Development: ":
  1. Tap Trust:
  1. You should see the following, which shows the app is now trusted:
  1. Click the Play button in Xcode to build and run again. You'll see your app launch and run on your iOS device.

Congratulations! Note that you have to connect your iOS 13 device to your Mac using the USB cable to build and run your app, so in the next section we'll see how we can connect over Wi-Fi.

Connecting an iOS device wirelessly

Unplugging and replugging your iOS device using USB gets pretty cumbersome after a while, so you'll configure Xcode to connect to your iOS device over Wi-Fi as follows:

  1. Make sure your Mac and iOS device are on the same wireless network.
  2. Choose Window | Devices and Simulators from the menu bar:
  1. Click on the checkbox marked Connect via network:

Awesome! Your iOS device is now connected wirelessly to Xcode, and you no longer need the USB cable connected.

You have been reading a chapter from
iOS 13 Programming for Beginners - Fourth Edition
Published in: Jan 2020
Publisher: Packt
ISBN-13: 9781838821906
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime