Swift Package Manager "platforms" and Watch OS

I'm working on an app and want to include a Watch target.

My app uses Swift Package Manager and 1 package (that I created) for doing repetitive utilities such as showing a "Loading..." view (in iOS only)

The Swift Package Package has supported platforms set to:

platforms: [
        .iOS(.v14)
    ]

However, when I try to start editing my Watch OS SwiftUI ContentView, the preview errors out stating:

iOS storyboards do not support target device type "watch". (This is from the Swift Package's Loading.storyboard.)

The Swift Package is UIKit only - no Swift UI. The "Loading..." view I am using for iOS is a View Controller - obviously not meant for Watch OS.

I cannot run the target to the Watch app - it shows a lot of UIKit errors from the Swift Package, like Cannot find type 'UIView' in scope and on and on.

The Watch app does not need this package at all.

I thought that if the platforms does not specify .watchOS* then it wouldn't try to apply it to my Watch target.

How do I tell this target not to link/load this package?

I ended up doing this to files that used UIKit and WatchOS complained about them - not sure if this is the right way to do this - but I haven't heard any other solutions.

#if !os(watchOS)
import UIKit

public class GenericButton: UIButton {

....

}
#endif

And I also removed the StoryBoard that was in the package. And recreated the view programmatically (not optimal... But it works).

A little background on the setup: This is a legacy (old) app - created back in 2016! It has a Watch Extension - pre-Swift UI - and co-existed with this Swift Package without an issue. I decided to finally convert the Watch App to SwiftUI. This is when it complained about the Swift Package that had UIKit elements in it. (This Watch App is dependent on the iPhone for its data still. My guess is that if the Watch App was built independent of the iPhone, then this Package wouldn't be an issue since the Package is embedded in the iPhone and not an independent watch app.)

Swift Package Manager "platforms" and Watch OS
 
 
Q