Is SwiftUI backwards-compatible with iOS 12.x and older?

Solution 1:

I just checked it out in Xcode 11 and can confirm it won't be backwards-compatible, as can be seen in SwiftUI's View implementation:

/// A piece of user interface.
///
/// You create custom views by declaring types that conform to the `View`
/// protocol. Implement the required `body` property to provide the content
/// and behavior for your custom view.
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol View : _View {

    /// The type of view representing the body of this view.
    ///
    /// When you create a custom view, Swift infers this type from your
    /// implementation of the required `body` property.
    associatedtype Body : View

    /// Declares the content and behavior of this view.
    var body: Self.Body { get }
}

Solution 2:

SwiftUI and Combine use Opaque-Return-Types in Swift 5.1 and since Opaque-Return-Types (alongside other features) are implemented in Swift 5.1 and due to the nature of their implementation, they can not be back deployed to Swift 5.0(unlike DSL or Property-Wrappers), and because iOS 13 is the earliest iOS SDK that contains Swift 5.1 runtime in the OS, so the answer to the question is no and SwiftUI and Combine can not be used on earlier versions of iOS.

Unless, Apple provides a way to bundle Swift 5.1 runtime (or future releases) with the application like it used to do with earlier Swift versions, but since it will increase App-size and add overhead to the whole system again, I doubt this will ever happen.

It might be backward compatible

Swift 5.1 is not released yet and SwiftUI uses features such as opaque return types, DSL, propertyDelegate(introduced in WWDC as propertyWrapper) and etc, which will be available only in Swift 5.1. Since Swift 5 is binary stable, I guess it was not possible to use embedded swift-frameworks inside Xcode11, hence they’ve re-implemented these features in Cocoa’s core and marked them as iOS13+ available until Swift 5.1 gets released.

My assumptions are based on the fact that, Ordered Collection Diffing and DSL are going to be available in Swift 5.1 and have no correlations with Xcode or Apple’s eco-system, but they’re also marked as @available(iOS13,...). This means that they had to mark everything using Swift 5.1 features with the iOS availability attribute. Some of them will get removed once Swift 5.1 gets released, but we can’t be sure about SwiftUI and Combine unless Apple tells otherwise. This is also mentioned in DSL’s proposal:

Implementation: PR. Note that the implementation in the Xcode developer preview uses a somewhat simpler transformation than that described here. The linked PR reflects the implementation in the preview but is under active development to match this proposal.

So backward incompatibility limitation might be lifted when Swift 5.1 gets released, but it really needs to be clarified by Apple team.

Solution 3:

I don't think so, because all libraries are already annotated for iOS 13 or higher.

Also, in the documentation, Apple clearly mentions the supported versions:

  • iOS13.0+ beta
  • macOS10.15+ beta
  • tvOS 13.0+ beta
  • watchOS 6.0+ beta

enter image description here