Can package use @available to manage functionality while maintaining backwards compatibility?

I'm building a package which does some standard 'interface with a remote' server work.
That stuff can support older OSs, so I set my package to

platforms: [.iOS(.v10),.macOS(.v10_13),.tvOS(.v10),.watchOS(.v5)],

I also want to include some SwiftUI utilities for displaying content to the user. I have marked these with
@available** (macOS 10.15.0,iOS 13.0, *)

e.g.

import SwiftUI

@available(macOS 10.15.0,iOS 13.0, *)
public struct SignupEmailView: View {
    var text:SignupText
    var close:()->Void

...

This works fine when I add the package to an app. I can build and run the app and all is dandy.
As soon as I try to archive the app to publish it though, I get a host of errors of the form

Cannot find type 'View' in scope

XCode seems to be falling over at every SwiftUI class. It seems to be ignoring the @available annotations when building for release - though it is fine with them in dev.

What's going on (and can I fix it?)

thanks in advance :)

Is is probably this:

Archiving probably builds for all architectures, whereas your other builds may only involve the particular architecture of the current device.

Brilliant - thanks for the pointer.

Changing to iOS11+ does indeed sort this. That's 'backward' enough for my purposes.

Terms of Service

Privacy Policy

Cookie Policy