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
Mastering iOS 18 Development
Mastering iOS 18 Development

Mastering iOS 18 Development: Take your iOS development experience to the next level with iOS, Xcode, Swift, and SwiftUI

Arrow left icon
Profile Icon Avi Tsadok
Arrow right icon
€8.99 €25.99
eBook Nov 2024 418 pages 1st Edition
eBook
€8.99 €25.99
Paperback
€31.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Avi Tsadok
Arrow right icon
€8.99 €25.99
eBook Nov 2024 418 pages 1st Edition
eBook
€8.99 €25.99
Paperback
€31.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€8.99 €25.99
Paperback
€31.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

Mastering iOS 18 Development

What’s New in iOS 18

Apple introduced iOS 18 in WWDC 2024 as part of its annual developer’s conference, alongside macOS, tvOS, iPadOS, watchOS, and visionOS.

Utilizing our app’s latest features and capabilities in each major OS release gives us a competitive advantage. Here are the reasons why Apple chose to improve particular domains in the SDK – market research or technology trends are good enough reasons to adopt new technologies.

However, to understand iOS 18 improvements, we first must understand the background for this version – that’s one of this chapter’s goals.

In this chapter, we will cover the following topics:

  • Understanding iOS 18 background
  • Exploring Swift Testing
  • Learning about the new Swift Data improvements
  • Trying the new zoom transition
  • Adding a floating tab bar to our iPad apps
  • Having more control over scroll views in SwiftUI
  • Changing the text rendering behavior
  • Positioning...

Technical requirements

For this chapter, it’s essential to download Xcode version 16.0 or higher from the App Store.

Ensure that you’re operating on the most recent version of macOS (Ventura or newer). Just search for Xcode in the App Store, choose the latest version, and proceed with the download. Open Xcode and complete any further setup instructions that appear. After Xcode is completely up and running, you can begin.

This chapter includes many code examples, and can be found in the following GitHub repository:

https://github.com/PacktPublishing/Mastering-iOS-18-Development/tree/main/Chapter%201

Understanding iOS 18 background

Releasing a major iOS version is always a big deal, even if it’s the 18th already. Let’s try to analyze the iOS SDK before iOS 18:

  • SwiftUI is becoming more mature and capable. However, some features, such as complex animations or transitions, gesture handling, navigation, and drawing, remain challenging to implement using SwiftUI.
  • Core Data is the go-to framework for most iOS developers as a solution for storing data persistently.
  • While XCTest is considered a robust and convenient testing framework, it lacks features that are commonly available on other platforms, such as parameterized testing and better testing organization.
  • WidgetKit’s popularity proves that the ability to show information at a glance is crucial in today’s world.

No one can argue that this list is important. However, one critical topic that Apple didn’t focus on until WWDC 2024 is artificial intelligence.

The rise of...

Introducing Swift Testing

Swift Testing is a new framework with a new and refreshing approach to testing. Swift Testing contains modern features such as macros, which work with structs instead of classes and can tag tests and test suites.

Swift Testing is supposed to replace XCTest, which was introduced in 2013 as part of Xcode 5. XCTest belongs to older times when Objective-C was the dominant language. However, Swift took over, and Apple understood that iOS developers needed a modern testing framework.

Here’s a simple test function:

@Test("Test view model increment function", .enabled(if: AppSettings.CanDecrement), .tags(.critical))
func testViewModelIncrement() async throws {
//         preparation
        let viewmodel = CounterViewModel()
        viewmodel.count = 5
//        execution
 ...

Introducing Swift Data Improvements

Swift Data was introduced in WWDC 2023 as part of iOS 17, and its goal was to replace the old but popular Core Data framework.

Swift Data provides a modern API based on Swift, which can help reduce friction when working with persistent stores. One of the trends we see in Apple development tools is moving away from GUI to code-based tools. A good example is SwiftUI – even though it is possible to drag and drop components to build a user interface, the primary way to do this is in code. The same goes for App Intents and Swift Package Managers. The data layer goes through the same concept – in Swift Data, we don’t have any data model editor, so we build our data model using only code.

For example, here’s how to create a data model for a Book entity:

@Model
class Book {
    var author: String
    var title: String
    var publishedDate: Date
}

At first...

Introducing zoom transition

This is a small improvement, but it may indicate an interesting direction Apple is taking with SwiftUI. In general, UIKit’s transitioning capabilities are very robust and provide us with the flexibility to create any transition we want. Even before that, from the beginning, UIKit had some nice built-in transitions we could use to make our navigation more appealing.

In iOS 18, Apple added a new transition that allows us to navigate to a new view using a zoom animation.

Let’s create an album grid that, when tapping on the album, transitions to a full album screen with a zoom animation:

    @Namespace() var namespace
    var body: some View {
        NavigationStack {
            ScrollView {
                LazyVGrid...

Adding a floating tab bar

iPad is not the focus of this book. This is not because iPadOS is unimportant but because most, if not all, of the topics we discuss here are also suitable for iPadOS.

However, there are special features that are relevant to iPadOS that are worth mentioning. One of them is the float tab bar.

The tab bar has existed in iOS since its very beginning. It allows users to navigate between different sections of an app. In both iOS and iPadOS, the tab is located at the bottom of the screen. While it looks perfectly fine on small devices, a tab bar on big screens seems stretched and doesn’t use the large space.

One solution for handling navigation in a iPadOS is to implement a sidebar – a view on the side that displays the different sections of the app.

In iPadOS 18, the position of the sidebar changed, and it is now located at the top of the screen, floating over the app content. Not only that; the user can also transition between a tab bar...

Having more control over scroll views

Controlling and observing scroll view behavior was part of the reason why UIKit developers hadn’t moved to SwiftUI yet.

Scroll views are crucial in mobile apps, not just because of the small screen, which often requires the user to scroll for more content, but also because they help reuse visible content to minimize memory usage or adjust our UI based on scroll position.

However, why is handling scroll views in SwiftUI more complex than in UIKit? We can think of two reasons:

  1. SwiftUI is relatively new: SwiftUI is still considered to be a new framework. Think how much time it took for UIKit to become a mature framework. Obviously, we can achieve this in several years and 17 years of development.
  2. Flexibility: Due to the imperative approach, UIKit gives us direct control over views. This means that we can adjust particular view parameters based on the scroll state. SwiftUI’s declarative nature sometimes makes achieving...

Changing the text rendering behavior

Handling texts on screen was also a very mature area where UIKit provided great frameworks such as TextKit. We could manipulate texts and create almost any effect that we wanted.

In iOS 18, Apple introduced TextRenderer, a protocol that can help us change the default behavior of our texts in SwiftUI.

Let’s say that we want a title with a different opacity for each line and even rotate the lines a bit. This creates a nice effect for the titles in our app. So, let’s see how to do that in SwiftUI:

struct CustomTextRenderer: TextRenderer {
    func draw(layout: Text.Layout, in ctx: inout
     GraphicsContext) {
        for (index, line) in layout.enumerated() {
            ctx.opacity = Double(index + 1) * 0.1
            ctx...

Positioning sub-views from another view

What does it mean to position sub-views from another view? While this description sounds weird and unclear, it is a nice addition to SwiftUI that can help us provide more dynamic and reusable content.

To understand what it means, let’s take the following code as an example:

struct NewsView: View {
    var body: some View {
        Text("Major Breakthrough in Renewable Energy: New Solar Panel Technology Promises 30% Efficiency Increase")
        Text("lobal Markets React to Sudden Interest Rate Hike: Stocks Tumble Across the Board")
        Text("Historic Peace Agreement Reached: Leaders Sign Pact to End Decades-Long Conflict")
        Text("Innovative AI Tool Revolutionizes Healthcare: Doctors Embrace Machine Learning...

Entering the AI revolution

AI and machine learning are not new areas for Apple and the iOS platform. Apple uses AI to adjust photos taken, suggest apps to users according to their usage, optimize battery charging, and many more.

For developers, Apple provides the CoreML framework and tools such as Create ML to help users train and create their own machine learning models.

However, the rising popularity of services such as ChatGPT and Gemini proved that CoreML is insufficient, and that Apple needs to integrate AI deeper into the system.

So, what did Apple prepare for us, the developers, regarding AI in iOS 18?

Apple integrated AI into iOS 18 by letting iOS understand what’s happening in the system and helping the user perform common tasks using natural language understanding, similar to ChatGPT.

For example, let’s say we’re working on a word-processing app and created an App Intent that allows the user to add an image to a document.

Until iOS 18...

Summary

There’s no other way of looking at iOS 18 than as an exciting one. The addition of Apple Intelligence is only part of the story – Apple took care of many system and SDK aspects such as testing, persistent data, UI, and more.

In this chapter, we explored the basics of the new Swift Testing framework, learned about Swift Data improvements, and discussed enhancements in SwiftUI such as zoom transition, floating tab bar, scroll views, and text rendering. We even scratched the surface of Apple Intelligence and tried to understand how it is integrated with App Intents. By now, you should be familiar with the most exciting and new topics in iOS 18.

A few code examples are just not enough. We are developers, and we need more! So, let’s jump straight into SwiftData and explore Apple’s new persistent data framework in the next chapter.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Stay up to date with the latest changes and improvements in iOS SDK and Swift programming language
  • Learn how you can improve user experience by focusing on customizing components and animations
  • Get to grips with advanced topics such as SwiftData and high-efficiency applications through an in-depth discussion
  • Purchase of the print or Kindle book includes a free PDF eBook

Description

Embark on a comprehensive iOS 18 development journey with Avi Tsadok, a veteran iOS developer and author of 4 books and over 40 tutorials and articles. A recognized public speaker, Avi has a knack for demystifying complex concepts and brings unparalleled expertise to the forefront of iOS 18 development education. This guide focuses on iOS 18 advancements, equipping developers with tools to maximize its potential. This book covers essential topics for seasoned developers, including Swift, SwiftUI, Xcode foundations, and the latest iOS SDK updates. You’ll get to grips with optimizing performance and understanding advanced architectural paradigms. By implementing the newest iOS updates, you’ll also explore intricate animation methods and harness a new framework, SwiftData that replaces Core Data for having persistent storage. The book builds your proficiency in advanced networking with URLSession and shows you how to conjure stunning visuals and adopt sophisticated testing techniques. You'll explore the world of machine learning with Apple’s Core ML diving into built-in frameworks like NLP, vision, and sound analysis to train and integrate your own models into iOS apps. By the end of the book, you'll possess skills to build exceptional apps, excel in advanced roles, and confidently tackle iOS development challenges.

Who is this book for?

If you are an experienced iOS developer looking to enhance your mobile development skills, create exceptional applications, and excel in advanced positions, this book is designed for you. To derive maximum benefit from this book and ensure a strong understanding of the advanced content, it is recommended that you have a solid foundation in Swift, SwiftUI, and Xcode.

What you will learn

  • Develop functional iOS applications on the iOS platform
  • Build intricate custom animations and UI elements
  • Master data handling and persistence in iOS apps
  • Utilize Combine for efficient data management
  • Harness the power of the neural engine through CoreML
  • Explore architectures and streamline programming with Swift Macros
  • Improve engagement by adding Widgets and App Intents

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Nov 08, 2024
Length: 418 pages
Edition : 1st
Language : English
ISBN-13 : 9781835463277
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 : Nov 08, 2024
Length: 418 pages
Edition : 1st
Language : English
ISBN-13 : 9781835463277
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
Banner background image

Table of Contents

19 Chapters
Part 1: Getting Started with iOS 18 Development Chevron down icon Chevron up icon
Chapter 1: What’s New in iOS 18 Chevron down icon Chevron up icon
Chapter 2: Simplifying Our Entities with SwiftData Chevron down icon Chevron up icon
Chapter 3: Understanding SwiftUI Observation Chevron down icon Chevron up icon
Chapter 4: Advanced Navigation with SwiftUI Chevron down icon Chevron up icon
Chapter 5: Enhancing iOS Applications with WidgetKit Chevron down icon Chevron up icon
Chapter 6: SwiftUI Animations and SF Symbols Chevron down icon Chevron up icon
Chapter 7: Improving Feature Exploration with TipKit Chevron down icon Chevron up icon
Chapter 8: Connecting and Fetching Data from the Network Chevron down icon Chevron up icon
Chapter 9: Creating Dynamic Graphs with Swift Charts Chevron down icon Chevron up icon
Part 2: Refine your iOS Development with Advanced Techniques Chevron down icon Chevron up icon
Chapter 10: Swift Macros Chevron down icon Chevron up icon
Chapter 11: Creating Pipelines with Combine Chevron down icon Chevron up icon
Chapter 12: Being Smart with Apple Intelligence and ML Chevron down icon Chevron up icon
Chapter 13: Exposing Your App to Siri with App Intents Chevron down icon Chevron up icon
Chapter 14: Improving the App Quality with Swift Testing Chevron down icon Chevron up icon
Chapter 15: Exploring Architectures for iOS Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon
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.