How to add a WatchOS app to a Multiplatform project and share the SwiftUI app lifecycle and root views.
- File > New > Target…
- Under the WatchOS tab, select App and press Next.
- Set the product name. Right now Xcode requires a different name than the existing multiplatform target but you can change it to match in a later step. You'll probably want to set your watch app to be "Watch App for Existing iOS App" for this workflow. Click Finish.
- Select your .xcodeproj and you'll see a new Watch App target (and test targets if you elected for them) in the Targets section of the sidebar.
- Select the Watch App and on the General tab you can change the Display Name to match your other targets.
- Click the Watch App target again while it's highlighted to edit the name. I changed mine from "{{Name}}Watch Watch App" to just "{{Name}} Watch App".
Under the {{Name}} Watch App target General tab, Deployment Info section, check "Supports Running Without iOS App Installation".
Delete the {{Name}}App.swift and ContentView.swift files in the Watch App directory. Then add the watch target to the lifecycle file and any views using the inspector.
If you included Core Data with the template then you'll also need to add the watch target to the persistence logic and model definition files.
I've had a few directory renames cause errors but Xcode was able to point me to where I needed to update configurations. Don't hesitate to share your solutions so we can all learn.