I have a simple app with an iOS target that is configured for iPhone, iPad, and Mac, making it a Catalyst - https://developer.apple.com/mac-catalyst/ app. On Xcode 12.0 Beta 1, I tried adding a Settings - https://developer.apple.com/documentation/swiftui/settings scene to my app. The documentation page says it is compatible with both macOS 11.0+ and Mac Catalyst 14.0+. The entirety of my app is this:
import SwiftUI
@main
struct TestSettingsApp: App {
	@SceneBuilder var body: some Scene {
		WindowGroup {
			Text("Hello, world!").padding()
		}
		#if os(macOS)
		Settings {
			Text("Settings here.")
		}
		#endif
	}
}
Based on the WWDC 2020 What's new in SwiftUI video - https://developer.apple.com/videos/play/wwdc2020/10041/ (4:50), I would expect this to automatically add a "Preferences..." menu option, which would show "Settings here." However, this option never shows up. I also tried replacing #if os(macOS) with #if targetEnvironment(macCatalyst), which had no effect.
Post
Replies
Boosts
Views
Activity
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!