Hello, I come here as an iOS developer asking a bit of a broad question. For the past year, I've been building an app intended for iOS, iPadOS, and macOS. Although written almost entirely in SwiftUI, I have a bit of UIKit in it, specifically a UITextView. (Side note: I've considered using the new SwiftUI TextEditor but it doesn't appear to have the functionality I need.)
When I started, I set up my Xcode project with one target that deploys to iPhone, iPad, and Mac, so that the iPad version could run on Mac as a Catalyst app. Now that I'm building against the iOS 14 beta, I selected "Optimize Interface for Mac" so that my app can look more like a native macOS app on Mac. However, after watching some more of the WWDC 2020 videos, and downloading sample projects, I'm noticing that Apple is clearly favoring separate iOS and macOS targets for SwiftUI projects. And creating a new Xcode project with the "App" template creates two separate targets as well.
Maybe this answer is buried in a WWDC video I haven't watched yet, but I'm trying to understand what exactly are the tradeoffs for having two separate targets. If I switch to using separate iOS and macOS targets, will my app no longer be a Catalyst app? Will it be an AppKit app underneath the SwiftUI instead? And will I not be able to use UITextView on macOS anymore? If I'm already using "Optimize Interface for Mac", are there any benefits to separate targets? Lastly, I noticed that one of the videos mentioned a new simple method to declare a settings window for macOS using #if os(macOS) Settings { SettingsView() } #endif. I have not been able to make this actually show up on my app on macOS Big Sur, would it only work with a separate macOS target?
Thank you so much!
When I started, I set up my Xcode project with one target that deploys to iPhone, iPad, and Mac, so that the iPad version could run on Mac as a Catalyst app. Now that I'm building against the iOS 14 beta, I selected "Optimize Interface for Mac" so that my app can look more like a native macOS app on Mac. However, after watching some more of the WWDC 2020 videos, and downloading sample projects, I'm noticing that Apple is clearly favoring separate iOS and macOS targets for SwiftUI projects. And creating a new Xcode project with the "App" template creates two separate targets as well.
Maybe this answer is buried in a WWDC video I haven't watched yet, but I'm trying to understand what exactly are the tradeoffs for having two separate targets. If I switch to using separate iOS and macOS targets, will my app no longer be a Catalyst app? Will it be an AppKit app underneath the SwiftUI instead? And will I not be able to use UITextView on macOS anymore? If I'm already using "Optimize Interface for Mac", are there any benefits to separate targets? Lastly, I noticed that one of the videos mentioned a new simple method to declare a settings window for macOS using #if os(macOS) Settings { SettingsView() } #endif. I have not been able to make this actually show up on my app on macOS Big Sur, would it only work with a separate macOS target?
Thank you so much!