Using the same widget extension for both iOS and WatchOS

Isn't it possible to use the same widgetkit extension for both iOS and WatchOS?

In the WWDC's BackyarBirds project from Apple, I can see the widget extension is added to both the multiplatform (including iOS) and the watch targets. I can also see that the SwiftUI code even uses macros to check which platform the code is running on.

However, I'm having several issues with adding the same extension to both targets. When I add it to the watch target, I get a build error that I'm trying to embed an application that also builds for iOS and that is not allowed for the watch app.

Not sure if any code here is helpful, but this is my widget UI code:

struct AkvaWidget: Widget {
    private let kind = "Akva Widget"
    
    var families: [WidgetFamily] {
        #if os(iOS)
        return [.accessoryCircular, .accessoryRectangular, .systemSmall]
        #elseif os(watchOS)
        return [.accessoryCircular, .accessoryRectangular, .accessoryInline, .accessoryCorner]
        #endif
    }
    
    var body: some WidgetConfiguration {
        StaticConfiguration(
            kind: kind,
            provider: AkvaSnapshotTimelineProvider()
        ) { entry in
            AkvaWidgetView(entry: entry)
        }
        .configurationDisplayName("Akva")
        .description("Keep track of your water intake.")
        .supportedFamilies(families)
    }
}

There is a walkthrough in the WWDC22 session Complications and widgets reloaded which suggests duplicating your existing Widget target, modifying the base SDK and embedding it in the watch app to achieve this using the same code.

Did you figure it out? I'm trying to use my current iOS widgets in WatchOS 10 but they don't even show up on my watch after adding WatchOS to my current WidgetsExtension target...

Using the same widget extension for both iOS and WatchOS
 
 
Q