iosmacosswiftuimultiplatformlaunch-screen

Is it possible to skip launchscreen.storyboard file when running a multiplatform SwiftUI app on macOS?


I selected Multiplatform template when creating a SwiftUI app in Xcode (it's Xcode 14.0 beta, in case it matters). My purpose is to run the app on iOS. I selected Multiplatform template just because I thought it would be fun to see how it runs on macOS.

In WWDC 2020, Apple introduced an Info.plist based approach to implement launch screen for SwiftUI apps. Unfortunately that approach was broken in Xcode 13. My experiment shows it's still not working in Xcode 14.0 beta, so I work around the issue by using a storyboard file to implement launch screen.

However, since storyboard is based on UIKit, that means it doesn't work on macOS. That explains why Xcode reported the following error when I tried to run the app on macOS:

iOS storyboard doesn't support device type 'mac'

So I wonder, given the fact that the Info.plist based approach is broken in Xcode 13 and 14, how does one implement launch screen in a multiplatform app? Is it possible to skip the storyboard file on macOS? I checked around in Xcode but didn't find a way.

An additional question: which is the common approach to write app on macOS, writing a multiplatform app as I described above or writing two separate apps, one for iOS and one for macOS? Thanks.


Solution

  • I've found that this works for a multiplatform app:

    1. Go to Build Phases -> Copy Bundle Resources
    2. Click on the dropdown for the storyboard resources
    3. Select iOS only

    (Screenshot is from XCode 14 beta)

    Copy Bundle Resources