What's the best practices recommendation for creating new projects?
In Xcode it seems I could go either way, either an iOS/iPadOS app and select the 'Mac' checkbox (Catalyst) or use the new Universal app template which creates specific iOS and Mac targets.
They both use SwiftUI, so it's not 100% clear what the 'correct' way to go.
In Xcode it seems I could go either way, either an iOS/iPadOS app and select the 'Mac' checkbox (Catalyst) or use the new Universal app template which creates specific iOS and Mac targets.
They both use SwiftUI, so it's not 100% clear what the 'correct' way to go.
(Copying/pasting my answer to a similar question)
There are a lot of possible paths for creating a multi platform app — which path you choose will depend on your team and the app you’re hoping to create.
If you’re primarily using SwiftUI, you can try using the new multi platform app project template in Xcode 12. This template configures a group for shared code that you can use for data, app structure, and common interface elements. Then you can use the platform-specific groups for iOS or macOS to flesh out platform-specific assets and views to your liking. As an example, the Fruta sample code project uses this technique to create an app that looks great on iPhone, iPad, and Mac.
https://developer.apple.com/documentation/swiftui/fruta_building_a_feature-rich_app_with_swiftui
Personally, if you’re already planning on making a SwiftUI-heavy app and either don’t need UIKit while building your Mac app, or are fine learning & utilizing AppKit when you need to, try the multiplatform app template.
If you go down the Mac Catalyst route — which is great (and native) — you will need to put effort in when choosing to adopt the Mac Idiom, if you prefer your app better fitting the Mac system experience.
https://developer.apple.com/documentation/uikit/mac_catalyst/choosing_a_user_interface_idiom_for_your_mac_app
In either case, you may want to focus on a single platform while initially iterating on your interface to make sure you have a great experience and story — then adapt it to fit the next platform, utilizing its strengths.
There are a lot of possible paths for creating a multi platform app — which path you choose will depend on your team and the app you’re hoping to create.
If you’re primarily using SwiftUI, you can try using the new multi platform app project template in Xcode 12. This template configures a group for shared code that you can use for data, app structure, and common interface elements. Then you can use the platform-specific groups for iOS or macOS to flesh out platform-specific assets and views to your liking. As an example, the Fruta sample code project uses this technique to create an app that looks great on iPhone, iPad, and Mac.
https://developer.apple.com/documentation/swiftui/fruta_building_a_feature-rich_app_with_swiftui
Personally, if you’re already planning on making a SwiftUI-heavy app and either don’t need UIKit while building your Mac app, or are fine learning & utilizing AppKit when you need to, try the multiplatform app template.
If you go down the Mac Catalyst route — which is great (and native) — you will need to put effort in when choosing to adopt the Mac Idiom, if you prefer your app better fitting the Mac system experience.
https://developer.apple.com/documentation/uikit/mac_catalyst/choosing_a_user_interface_idiom_for_your_mac_app
In either case, you may want to focus on a single platform while initially iterating on your interface to make sure you have a great experience and story — then adapt it to fit the next platform, utilizing its strengths.