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
An iOS Developer's Guide to SwiftUI
An iOS Developer's Guide to SwiftUI

An iOS Developer's Guide to SwiftUI: Design and build beautiful apps quickly and easily with minimum code

eBook
€8.99 €26.99
Paperback
€33.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
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

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

An iOS Developer's Guide to SwiftUI

Exploring the Environment – Xcode, Playgrounds, and SwiftUI

This chapter is an introduction to the tools used when working with SwiftUI, the new, exciting, efficient, and simple-to-use Apple framework for user interfaces (UIs). We’re going to cover the following main topics in this chapter:

  • Exploring Xcode and SwiftUI
  • Creating a multi-platform SwiftUI project
  • Using Swift Playgrounds to test fragments of code
  • Adding tests
  • The App submission process

By the end of this chapter, you will learn how to create a project from scratch. You will also learn how to create a project using the project templates and how to add tests and preview your SwiftUI views code.

Note

The opinions expressed in this book are solely those of the author and do not necessarily reflect the views or policies of his employers or other entities. Any reference to organizations, events, or individuals is purely fictional and intended for illustrative purposes only. Resemblance...

Technical requirements

You will require a recent Apple computer to run the examples and code in this book. In general, the more RAM and more powerful your system, the better. This book has been tested on an Intel MacBook Pro running macOS 13.6 (Ventura) with 16 GB of RAM. It will work just as fine on a more recent Apple Silicon machine.

To follow this chapter and the rest of the book, you will be required to install Xcode version 15.0 or later.

If you want to run code on a physical device with Xcode 15.0, you will be able to use the async/await pattern in concurrent programming for devices running at least iOS 13. We suggest updating your device to iOS 17 or later to follow this book.

The complete projects and code samples for the examples discussed in the book can be found under the GitHub repository: https://github.com/PacktPublishing/An-iOS-Developer-s-Guide-to-SwiftUI.

Exploring SwiftUI with Xcode

In this section, we are going to look into the Xcode UI in the context of a SwiftUI project.

Xcode is quite a large topic by itself. We will focus on SwiftUI and explain enough about how Xcode usage differs in SwiftUI from UIKit to get you started, how to create a SwiftUI project, and add targets for various Apple platforms. Also, we will explain how to add tests to a project.

A brief tour of Xcode

Xcode is an integrated development environment (IDE) for developing any code on any device that Apple produces. Xcode is therefore a massive and complex app capable of supporting many different types of projects and technologies. Not all of these types of projects are relevant to SwiftUI, so we will limit ourselves to Swift as a language and SwiftUI as a UI framework. In the past, the only supported language for app development was Objective-C and the only supported UI framework was different for each device platform, notably UIKit for iOS and AppKit...

Your first SwiftUI project

In this section, we will look into the process of creating a new project supporting SwiftUI. We will first look into the easiest and quickest way to create a SwiftUI project. Then, we’ll learn how to create a multi-platform project and at the end, there’s also a multi-platform exercise for you to practice.

Creating a SwiftUI project

To create an app, start by clicking on Create New Project… on the initial Welcome Xcode screen. Be warned that this part is likely to change graphically and in terms of the options presented, with newer versions of Xcode.

I will teach you how to create a basic project with an app template or a multi-platform project from scratch, but we can’t cover all the other options for all of the different kinds of projects Xcode can generate.

The following is the easiest and quickest way to create a basic project using an app template:

  1. Create an app for your desired platform by selecting Create...

Previews and the simulator

Now, for the sake of simplicity, we will start again by creating a simple single-view project.

You can create a new project from the Xcode menu: File | New | Project.

You will see that Xcode will automatically create a simple project and create a view struct and a preview struct inside the ContentView.swift file.

The first struct inside this file describes a simple SwiftUI view (Text) and the second struct is used to pre-render it so that you can have an idea of the finished result without the need to launch the simulator.

You can have multiple previews, even for different devices simultaneously, but that depends heavily on the memory available on your system and has been somewhat error prone in the past.

You can give each preview a name, by using the previewDisplayName modifier on the content view in the preview, for example, name the currently rendered device iPod.

You can also change the desired rendered device in code using the previewDevice...

Playgrounds

Swift Playgrounds is an excellent way to test Swift code without creating an app or a complete project.

Unfortunately, Swift Playgrounds was developed for UIKit and does not completely support SwiftUI.

In Xcode, there is an option to create a Playground containing a view, but that will create a view with ViewController using UIKit, not SwiftUI, and that’s not ideal for our purposes.

You can, however, start with an empty Playground and create your view in code with SwiftUI and then set it as the current view by using PlaygroundPage.current.setLiveView(ContentView()).

Your code will look like this:

import SwiftUI
import PlaygroundSupport
struct ContentView: View {
    var body: some View {
        Text("I love SwiftUI")
    }
}
PlaygroundPage.current.setLiveView(ContentView())

However, the support for SwiftUI in Swift Playgrounds is far from ideal, and not updated...

The app submission process

When submitting iOS and macOS applications to the Apple App Store, there are a number of steps to follow, such as getting certificates generated and creating mobile provisioning profiles.

You will need to use both the Apple Developer website and Xcode.

Certificates identify you as the developer of your apps and ensure the security and integrity of your apps. Different certificates will be required for development and distribution.

Certificates

There are two main types of certificates that are relevant to app development:

  • Development certificate: This is used to authorize the installation of applications on physical devices while developing the application.
  • Distribution certificate: This is required for application distribution in the App Store or ad hoc (on selected specific devices, the latter usually for testing purposes).

    Additional certificates can be needed for specific purposes, for example, enabling push messages.

The...

Summary

We have just covered some initial ground.

You should now be able to create your projects and add several target platforms to them.

You have been given a brief introduction about using Xcode to create and modify a simple text view, and you should be able to preview, modify, and run your first very simple app with static text and a color background.

You have seen the basics of project creation; you know how to modify a project to add tests or support for another platform on your own.

You know the limits and advantages of Swift Playgrounds rather than previews and can solve the most common Xcode problems you face as a SwiftUI beginner.

In the next chapter, we will explore SwiftUI views and their modifiers in greater detail, and we will create more complex screens.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Learn how to structure and maintain clean app architecture
  • Under the guidance of industry expert Michele Fadda, build well-structured, maintainable, and high-performance applications
  • Understand the declarative functional approach and focus on asynchronous programming within the context of SwiftUI
  • Purchase of the print or Kindle book includes a free PDF eBook

Description

– SwiftUI transforms Apple Platform app development with intuitive Swift code for seamless UI design. – Explore SwiftUI's declarative programming: define what the app should look like and do, while the OS handles the heavy lifting. – Hands-on approach covers SwiftUI fundamentals and often-omitted parts in introductory guides. – Progress from creating views and modifiers to intricate, responsive UIs and advanced techniques for complex apps. – Focus on new features in asynchronous programming and architecture patterns for efficient, modern app design. – Learn UIKit and SwiftUI integration, plus how to run tests for SwiftUI applications. – Gain confidence to harness SwiftUI's full potential for building professional-grade apps across Apple devices.

Who is this book for?

– This book is for iOS developers interested in mastering SwiftUI, software developers with extensive iOS development experience using UIkit transitioning to SwiftUI, as well as mobile consultants and engineers who want to gain an in-depth understanding of the framework. – Newcomers equipped with knowledge of Swift, UIkit, XCode, and asynchronous programming will find this book invaluable for launching a career in mobile software development with iOS.

What you will learn

  • Get to grips with UI coding across Apple platforms using SwiftUI
  • Build modern apps, delving into complex architecture and asynchronous programming
  • Explore animations, graphics, and user gestures to build responsive UIs
  • Respond to asynchronous events and store and share data the modern way
  • Add advanced features by integrating SwiftUI and UIKit to enhance your apps
  • Gain proficiency in testing and debugging SwiftUI applications

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 03, 2024
Length: 446 pages
Edition : 1st
Language : English
ISBN-13 : 9781801817912
Vendor :
Apple
Languages :
Concepts :
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
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : May 03, 2024
Length: 446 pages
Edition : 1st
Language : English
ISBN-13 : 9781801817912
Vendor :
Apple
Languages :
Concepts :
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 97.97
An iOS Developer's Guide to SwiftUI
€33.99
SwiftUI Cookbook
€33.99
Swift Cookbook
€29.99
Total 97.97 Stars icon
Banner background image

Table of Contents

24 Chapters
Part 1: Simple Views Chevron down icon Chevron up icon
Chapter 1: Exploring the Environment – Xcode, Playgrounds, and SwiftUI Chevron down icon Chevron up icon
Chapter 2: Adding Basic UI Elements and Designing Layouts Chevron down icon Chevron up icon
Chapter 3: Adding Interactivity to a SwiftUI View Chevron down icon Chevron up icon
Part 2: Scrollable Views Chevron down icon Chevron up icon
Chapter 4: Iterating Views, Scroll Views, FocusState, Lists, and Scroll View Reader Chevron down icon Chevron up icon
Chapter 5: The Art of Displaying Grids Chevron down icon Chevron up icon
Part 3: SwiftUI Navigation Chevron down icon Chevron up icon
Chapter 6: Tab Bars and Modal View Presentation Chevron down icon Chevron up icon
Chapter 7: All About Navigation Chevron down icon Chevron up icon
Part 4: Graphics and Animation Chevron down icon Chevron up icon
Chapter 8: Creating Custom Graphics Chevron down icon Chevron up icon
Chapter 9: An Introduction to Animations in SwiftUI Chevron down icon Chevron up icon
Part 5: App Architecture Chevron down icon Chevron up icon
Chapter 10: App Architecture and SwiftUI Part I: Practical Tools Chevron down icon Chevron up icon
Chapter 11: App Architecture and SwiftUI Part II – the Theory Chevron down icon Chevron up icon
Part 6: Beyond Basics Chevron down icon Chevron up icon
Chapter 12: Persistence with Core Data Chevron down icon Chevron up icon
Chapter 13: Modern Structured Concurrency Chevron down icon Chevron up icon
Chapter 14: An Introduction to SwiftData Chevron down icon Chevron up icon
Chapter 15: Consuming REST Services in SwiftUI Chevron down icon Chevron up icon
Chapter 16: Exploring the Apple Vision Pro Chevron down icon Chevron up icon
Index 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 Full star icon Full star icon Half star icon 4.9
(11 Ratings)
5 star 90.9%
4 star 9.1%
3 star 0%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Dildeep Jul 18, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I recently read "iOS Developer's Guide to SwiftUI" and it has quickly become an invaluable resource in my iOS development journey. Whether you're a seasoned developer looking to transition from UIKit to SwiftUI or a newcomer eager to dive into the world of iOS development, this book is a fantastic guide that covers all the essentials and more.The book excels in breaking down the complex topics into manageable, easy-to-understand segments. Starting from the basics, it meticulously guides you through creating views and modifiers before progressing to more advanced and intricate user interface designs. The hands-on approach makes the learning process engaging and effective.One of the standout features of this book is its focus on the declarative programming approach, which is the backbone of SwiftUI. The explanations are clear, and the examples are practical, helping you to grasp how to structure and maintain clean app architecture. The book doesn't just stop at the basics; it dives deep into asynchronous programming and modern architecture patterns, ensuring you can build efficient and well-structured apps.The full-color images and diagrams are incredibly helpful, making it easier to follow along and visualize the concepts being discussed. Moreover, the integration of SwiftUI with other relevant frameworks is covered in detail, allowing you to create professional and responsive applications.The inclusion of chapters on animations, graphics, and user gestures is a huge plus, enabling you to build highly interactive and visually appealing UIs. The book also offers comprehensive insights into persistence with Core Data, structured concurrency, and consuming REST services in SwiftUI, which are crucial for developing modern apps.Additionally, the book's section on integrating SwiftUI with UIKit is invaluable for those transitioning from older projects or looking to enhance their current apps with SwiftUI features. The final chapters on testing and debugging SwiftUI applications provide essential techniques to ensure your apps are robust and error-free.Overall, "iOS Developer's Guide to SwiftUI" is a must-have for any iOS developer's library. The purchase of the print or Kindle version also includes a free PDF eBook, which is a great bonus for reading on the go. This book has greatly boosted my confidence in using SwiftUI and has equipped me with the skills to build professional-grade applications. Highly recommended!
Amazon Verified review Amazon
Andy F. Jun 11, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Full disclosure: I have only reviewed chapter 1 of this book as I am not very technical. I was basically curious to see what my genius friend has been busy writing.What Michele has achieved is very impressive. This is obviously a very technical book, but there's a lightness of touch here that almost feels as though we're just having a chat down the pub.I haven't had to rely on such technical manuals for years. But as the text here is so very readable, I'm sure this would be a super useful book for anyone looking to acquire these skills. The text is also populated with several relevant and helpful screenshots (which it must be said, is not always the case in books like this).Good work Mr. Fadda, I'm impressed.
Amazon Verified review Amazon
Danny Bolella Jun 04, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
As someone who loves working with SwiftUI, Michele has written a fantastic book that I’ll be referring to for quite some time. In particular, I really appreciated the chapters around Navigation and App Architecture (2 chapters on this, alone!). Michele presents well-rounded overview with some great guidance and helpful insights as to how and when to effectively pick and choose approaches. A great read!
Amazon Verified review Amazon
Goppinath Thurairajah May 30, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Despite its title, the book covers much more than just SwiftUI.The book is aimed at iOS developers looking to expand their knowledge by incorporating SwiftUI into their skill set. It is suitable for readers of all levels, from beginners to advanced.The book not only focuses on SwiftUI but also covers a wide range of topics, including:- Introduction to Xcode and app submission- Advanced usage of the Swift language- In-depth exploration of SwiftUI with animation- Modern concurrency and asynchronous programming- App architecture, clean architecture, SOLID principles, and GoF design patterns, along with system modelling using UML diagrams- Data persistence using CoreData and SwiftData- Modern networking and Swift serialization- Working in teams and group thinking- Exploring the Apple Vision ProThe book is logically divided into 16 chapters, with the latter 9 chapters delving into advanced topics. Throughout the book, the author provides external resources for further reading and references, as well as notes highlighting possible pitfalls. This reflects the author’s 30 years of experience in industrial software engineering in the book.In conclusion, this is a comprehensive resource that is beneficial for iOS developers at all levels of expertise. It’s a valuable addition to any iOS engineer’s collection and can also serve as a quick reference guide for non-linear reading.
Amazon Verified review Amazon
Nicholas Jun 18, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is for people who already have a grasp on swift and are looking to dig a little deeper into swiftUI specifically. He covers a little on xcode and even some bugs that we encounter which is helpful to be warned about because its confusing to encounter these things but he does not waste time talking about the most basic concepts related to swift in general which is a plus for me because Ive been developing for a while now and dont need these covered in every book I go through.The book does a good job using scaffolding as a teaching process. The author will introduce some basic concepts like how to construct views, then the next chapter you will learn how to let the user interact with those views. Overall its a really good flow and easy to follow.The book goes pretty in depth on navigation which is helpful because swiftUI handles navigation pretty differently from traditional swift.There are pictures in the book so you can compare the app he is walking you through building with the app on your screen to make sure you are following along correctly. If you get totally lost the source code is linked in the book so you can compare it to your project.The book also covers some newer concepts like SwiftData which I havent worked with before so that was cool and theres a chapter on the apple vision pro which I was pretty impressed with. Its basic stuff but the vision pro is hardly a year old at this point so its nice to even have some basic material to get us started.Overall I found this well organized and very accessible for developers who are familiar with swift but want to get their hands on swiftUI.
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.