SwiftUI: iPhone, iPad, Mac in a single target

Viewed 130

at the moment I have a SwiftUI app that works great only on iPhone.

I would like to extend the layout compatibility to the iPad and the Mac and I'm looking for a best practice to present conditionally the views depending of the platform.

Everything I have found is the "multi target strategy", so one target for each platform with his files.

But I would like to keep just one target so the release process would be easier, and I also would like to avoid all the time the if statements to check on witch platform the user is running the app.

Any best practice or any suggestion?

1 Answers

You should start with iPad, which you can use as a single target. Just expand the supported devices to include iPad and then fine tune your presentation there. Once that's done, expand that target again to mac via catalyst and again, fine tune.

But just so you know, I have been left wanting with SwiftUI support on iPad (take "split view" in NavigationView which doesn't allow you to always have the sidebar showing in portrait as a single example.) And I have found SwiftUI support on Mac to be pretty abysmal so far, so you do have your work cut out for you. Good luck!

Related