Are Xcode library Custom views/modifiers iOS14 only?

Is the custom view/modifier backwards compatible with SwiftUI on iOS 13? Or does it require iOS 14

Replies

The API that is used to declare the items (LibraryContentProvider etc) is iOS 14, but you can guard against it's usage when building for iOS 13 with @available and Xcode will still pick it up correctly, so the following compiles for iOS 13 and still populates your library.

Code Block
@available(iOS 14.0, *)
struct LibraryContent : LibraryContentProvider {
  @LibraryContentBuilder
  var views: [LibraryItem] {
    LibraryItem(
      Text("Hello WWDC!"),
      title: "Custom View In The Library"
    )
  }
}