This is how Xcode knows which files to include and build for which platforms. Taking a look at the Shared/ContentView.swift file shows that it is added to the iOS and macOS targets. Looking at the SwiftUIMultiplatform (watchOS) WatchKit Extension/ContentView.swift file shows it is only included in the watchOS (extension) target. To see this expand the right Xcode panel click on the File Inspector and take a look at the “Target Membership” section: Xcode knows which files to use for any given platform based on the target(s) that the file is added to. You will notice that the same files appear in the Shared directory. Platform Scoped FilesĮxpand the “SwiftUIMultiplatform (watchOS) WatchKit Extension” directory to see the files that have been automatically added. The steps are the same as above and you can check the git history of the repo to see this being added. We can do the same to add a tvOS platform. The “WatchKit Extension” target/directory are where the majority of our changes will take place. Once this has been added you will see new directories and targets that relate to watchOS. Select the “watchOS” tab and then the “Watch App” target: To do this click on the ‘+’ symbol at the bottom of the targets list (see above screenshot). Therefore we will need to add watchOS and tvOS as targets. We would like our project to be truly multi (Apple) platform and run on: This gets us started but only covers two of Apple’s platforms. When you set this up you should see the following targets have automatically been setup for you along with three top level directories called Shared, iOS and macOS: To create a project of this type navigate to File > New > Project > Multiplatform > App. Right out of the box Xcode provides a project type called “Multiplatform”. The dependencies used to produce this blog, screenshots and code are:Ĭode accompanying this blog post can be found on Github. This blog will take a look at a basic setup for a multi-platform SwiftUI app. This allows a developer to focus on what their application should look and behave like rather than how it should achieve this. It is a declarative framework that attempts to abstract away many of the differences between the Apple platforms. One such technology is SwiftUI - Apple state that “ SwiftUI is an innovative, exceptionally simple way to build user interfaces across all Apple platforms”. Apple are introducing technologies that lower the complexity of supporting their additional platforms such as watchOS and tvOS. iOS 15 introduces SharePlay in FaceTime, Live Text using on-device intelligence, redesigned Notifications, and more. Most native application development tends to focus on the main device families such as phones and tablets. Apple previews major updates to FaceTime, new Focus features to reduce distraction, enhanced on-device intelligence to discover information, and more ways to explore the world using Maps, Weather, and Wallet.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |