Creating a multiplatform version of the app sharing the same target
When you create a new app using Xcode 15, a multiplatform target is used by default. The multiplatform target allows us to share a single target for iOS, iPadOS, macOS, visionOS, and tvOS, while the watchOS app remains in a separate target.
SwiftUI is in its fifth iteration and Apple is making a big push to use SwiftUI as the preferred framework for multiplatform apps. Many SwiftUI views behave differently depending on the platform used to run the app. SwiftUI takes care of the configuration automatically, while also providing configuration options to further refine the platform-specific behavior.
This recipe shows how to create an app for iOS, iPadOS, and macOS, and best practices when targeting multiplatform apps in SwiftUI.
Getting ready
Download the chapter materials from GitHub: