Sahar | SwiftUI for Beginners | E-Book | www.sack.de
E-Book

E-Book, Englisch, 252 Seiten

Reihe: Packt Publishing

Sahar SwiftUI for Beginners

Build your first iOS app with SwiftUI, Swift Playground, and iPad
1. Auflage 2026
ISBN: 978-1-80778-556-7
Verlag: Packt Publishing
Format: EPUB
Kopierschutz: 0 - No protection

Build your first iOS app with SwiftUI, Swift Playground, and iPad

E-Book, Englisch, 252 Seiten

Reihe: Packt Publishing

ISBN: 978-1-80778-556-7
Verlag: Packt Publishing
Format: EPUB
Kopierschutz: 0 - No protection



Most beginners want to build a real app, not work through isolated exercises. SwiftUI for Beginners gets you building from the start, showing you how to create a complete iOS app on iPad using Swift Playground, Swift 6, and SwiftUI.
Starting with the Swift Playground environment and Swift fundamentals, you will design adaptive multi-screen interfaces, build navigation flows, and manage application data. As the app grows, you will add SwiftData for persistent storage, Core Location and MapKit for location-aware features, and Photo Library integration for rich media. You will also build reusable custom views and implement search to improve usability throughout.
By the end of this book, you will have built, tested, and published a complete iOS app to the App Store using SwiftUI, SwiftData, MapKit, and TestFlight.

Sahar SwiftUI for Beginners jetzt bestellen!

Autoren/Hrsg.


Weitere Infos & Material


1


Hello, Swift Playground


Welcome to . I hope this book serves as a useful introduction to creating and publishing SwiftUI apps on the App Store. Throughout the course of this book, you will build a simple app named , which lets you document cats that live in your area.

In this chapter, you'll download and install Swift Playground on your iPad. Then, you'll explore the Swift Playground user interface. After that, you'll create your first SwiftUI app and see what it looks like in App Preview. Finally, you'll run your app on your iPad. This app will be the starting point of the app.

By the end of this chapter, you will know how to create a SwiftUI app, how to preview it in App Preview, and how to run it on your iPad.

The following topics will be covered in this chapter:

  • Download and install Swift Playground from the App Store
  • Explore the Swift Playground user interface
  • Preview your app in App Preview
  • Run your app on your iPad

Download the code bundle and the PDF version of this book

Your purchase includes a DRM-free PDF copy of this book, the code bundle, and a range of exclusive benefits. To unlock everything, follow the section in the .

Technical requirements


To do the exercises for this chapter, you will need the following:

  • An iPad running iPadOS 26 or iPadOS 27
  • An Apple account (if you don't have one, you will create one in this chapter)

A Bluetooth keyboard and mouse are optional, but they do make typing in code much easier.

The Swift Playground project for this chapter is in the file of the code bundle for this book. To access the repository link, follow the steps in the section in the .

Check out the following video to see the code in action:

https://packt.link/rxDV1

You'll start by downloading Swift Playground, an app which helps you learn how to code in an interactive environment, in the next section.

Download and install Swift Playground from the App Store


Swift Playground is an app for iPad and Mac that helps you learn how to code. It includes interactive lessons that teach coding in a fun and engaging way, and it also allows you to create your own apps, which you can then upload to the App Store.

To learn more about Swift Playground, see this link: https://developer.apple.com/swift-playground/.

To watch a video demonstration of Swift Playground from WWDC 2022, see this link: https://developer.apple.com/videos/play/wwdc2022/110348/.

You will build apps using Apple's SwiftUI framework, a simple and innovative way to build user interfaces for all Apple platforms with a minimum of code. It uses a declarative syntax, which means you can simply state what your user interface should do, instead of having to specify in detail how it should work. When you type in SwiftUI code in Swift Playground, you can immediately preview the results, and you can also run your apps on your iPad itself.

To learn more about SwiftUI, see this link:

https://developer.apple.com/swiftui/.

To watch a video explaining the latest updates to SwiftUI from WWDC 2026, see this link:

https://developer.apple.com/videos/play/wwdc2026/269/.

You'll need to download and install Swift Playground on your iPad prior to writing your first app. Follow these steps:

  1. On your iPad, tap the App Store icon.
  2. Tap the Search (magnifying glass) icon, type and tap the key.
  3. You'll see Swift Playground in the search results. Tap Get.
  4. Type your Apple Account email or phone number in the text field and enter your password when prompted.

    You can see more information on how to create an Apple account using this link: https://support.apple.com/en-us/108647#appstore.

  5. Once Swift Playground has been installed, tap Open. Swift Playground will launch, and you'll see a welcome screen. Tap the New Playground... button:

    Figure 1.1: Welcome screen

  6. You'll see the New Playground... dialog box. Tap the App button to create a new app playground:

    Figure 1.2: New Playground... dialog box

  7. Your new app playground will appear.

Fantastic! You have now successfully downloaded and installed Swift Playground and created your first app playground. In the next section, you will learn about the Swift Playground user interface.

Explore the Swift Playground User Interface


You've just created your first Swift Playground app playground! As you can see, the app playground user interface is divided into several distinct parts, as shown here:

Figure 1.3: App playground user interface

Let's look at each part in more detail. The following descriptions correspond to the numbers shown in the preceding screenshot:

  • Back button (1): Returns you to the welcome screen
  • Sidebar button (2): Displays assets contained in your app playground, such as Swift files or images
  • Run App button (3): Runs the app playground on your iPad in its own window
  • Views button (4): Displays the Views library, which allows you to add a view or control to your app playground
  • Modifiers button (5): Displays the Modifiers library, which allows you to add a control, an effect, a layout, text, an image, a list and more to your app playground
  • Symbols button (6): Displays the Symbols library, which allows you to add a symbol to your app playground
  • Colors button (7): Displays the Colors library, which allows you to add a color to your app playground
  • Issues button (8): Displays warnings or errors in your app playground
  • App Preview button (9): Hides or shows App Preview in your app playground
  • More button (10): Allows you to change text size in the editor area, as well as accessing advanced settings for your app playground
  • Editor area (11): Allows you to edit the code contained in the Swift files for your app playground
  • App Preview (12): Displays the result of the code in the Editor area
  • Console button (13): Shows or hides the Console area
  • Tab bar (14): Allows you to switch between different Swift files in your project

Don't be overwhelmed by all the different parts, as you'll learn about them in more detail in the upcoming chapters. Now that you are familiar with the Swift Playground interface, you will make some changes in the Editor area and see the results in App Preview.

Preview your app in App Preview


App Preview automatically displays the results of the code that you type in the Editor area. You'll make some changes to your code and observe the results in App Preview. Follow these steps:

  1. You may find the size of the text in the Editor area to be too small. Tap the More button and tap the right-side A button to make the text larger:

    Figure 1.4: More menu showing A button

  2. In the Editor area, select all the code between and and tap to remove it.

    Figure 1.5: Editor area showing code to be removed

  3. Swipe left with three fingers on the screen to undo what you just did. The text you removed should reappear.
  4. Swipe right with three fingers on the screen to redo what you just did. The text will disappear again.
  5. Tap twice on the screen with three fingers to undo your last action once more. The text will reappear.
  6. Place the text cursor to the right of the statement.

    You can drag with two fingers on the...



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.