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 16 Programming for Beginners

You're reading from   iOS 16 Programming for Beginners Kickstart your iOS app development journey with a hands-on guide to Swift 5.7 and Xcode 14

Arrow left icon
Product type Paperback
Published in Nov 2022
Publisher Packt
ISBN-13 9781803237046
Length 686 pages
Edition 7th Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Ahmad Sahar Ahmad Sahar
Author Profile Icon Ahmad Sahar
Ahmad Sahar
Craig Clayton Craig Clayton
Author Profile Icon Craig Clayton
Craig Clayton
Arrow right icon
View More author details
Toc

Table of Contents (34) Chapters Close

Preface 1. Part I: 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. Swift Concurrency 11. Part II: Design
12. Setting Up the User Interface 13. Building Your User Interface 14. Finishing Up Your User Interface 15. Modifying and Configuring Cells 16. Part III: Code
17. Getting Started with MVC and Collection Views 18. Getting Data into Collection Views 19. Getting Started with Table Views 20. Getting Started with MapKit 21. Getting Started with JSON Files 22. Displaying Data in a Static Table View 23. Getting Started with Custom UIControls 24. Getting Started with Cameras and Photo Libraries 25. Understanding Core Data 26. Part IV: Features
27. Getting Started with Mac Catalyst 28. Getting Started with SwiftUI 29. Getting Started with Lock Screen Widgets 30. Getting Started with WeatherKit 31. Testing and Submitting Your App to the App Store 32. Other Books You May Enjoy
33. Index

Running the app in the iOS simulator

The iOS simulator is installed when you install Xcode. It provides a simulated iOS device so that you can see what your app looks like and how it behaves, without needing a physical iOS device. It can model all the screen sizes and resolutions for both iPad and iPhone so you can test your app on multiple devices easily.

To run your app in the simulator, follow these steps:

  1. Click the Scheme menu in the toolbar and you will see a list of simulators. Choose iPhone SE (3rd generation) from this menu:

Figure 1.14: Xcode Scheme menu with iPhone SE (3rd generation) selected

  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. The simulator will launch and show a representation of an iPhone SE (3rd generation). Your app displays a white screen, as you have not yet added anything to your project:

Figure 1.15: iOS Simulator

  1. Switch back to Xcode and click on the Stop button (or press 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 wonder what the Devices and Build sections are for. Let’s take a look at them in the next section.

Understanding the Devices and Build sections

You learned how to choose a simulator in the Scheme menu to run your app in the previous section. In addition to the list of simulators, the Scheme menu also has Devices and Build sections. These allow you to run apps on actual iOS devices, and prepare apps for submission to the App Store.

Click the Scheme menu in the toolbar to see the Devices and Build sections at the top of the menu:

Figure 1.16: Xcode Scheme menu showing Devices and Build sections

If you have an Apple Silicon Mac, the Devices section will display text stating My Mac (Designed for iPad), because Apple Silicon Macs can run iOS apps. Otherwise, No Devices will be displayed. 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 section has only one menu item, Any 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 Chapter 27, Testing and Submitting Your App to the App Store.

Now let’s see how to build and run your app on an actual iOS 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, you can skip the next section and go straight to Chapter 2, Simple Values and Types.

You have been reading a chapter from
iOS 16 Programming for Beginners - Seventh Edition
Published in: Nov 2022
Publisher: Packt
ISBN-13: 9781803237046
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