A source of Xcode library and code completion content.
Xcode discovers implementations of the `LibraryContentProvider` protocol in
your project or workspace and examines their contents for items that it can
add to the Xcode library. Add views by implementing the content provider's
computed ``DeveloperToolsSupport/LibraryContentProvider/views-25pdm``
property, and returning an array of ``DeveloperToolsSupport/LibraryItem``
instances initialized with the views you want to publish:
struct LibraryViewContent: LibraryContentProvider {
var views: [LibraryItem] {
LibraryItem(MyView())
}
}
Add view modifiers by implementing the
``DeveloperToolsSupport/LibraryContentProvider/modifiers(base:)-4svii``
method and similarly returning an array of library items initialized with
the modifiers you want to publish. For view modifiers, you also specify the
type to which the modifiers apply:
struct LibraryModifierContent: LibraryContentProvider {
func modifiers(base: MyView) -> [LibraryItem] {
LibraryItem(base.myModifier(value: MyValue()))
}
}
For modifiers that you define in an extension to
<doc://com.apple.documentation/documentation/SwiftUI/View>, you can provide
any view conformer as the `base`. For modifiers that you define on a
particular view type, provide that type as the `base`.
Members (1)
get · iOS 14.0+
views
Swift declaration
var views: [LibraryItem] { get }
The SwiftUI views that you want to add to the Xcode library.
Xcode adds the ``DeveloperToolsSupport/LibraryItem`` instances returned
by your implementation of this property to its Views library. The
following restrictions apply:
- You must instantiate the library items inline.
- If specified, the item's `title`, `category`, and `matchingSignature`
must be static strings and not `nil`.
- The item's `visible` value, if specified, must be a literal Boolean
value.
- The item's expression must be an instantiation. That is, it can't be
a reference.
Skipped declarations
1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.
LibraryContentProvider.modifiers(base:)
The iOS SDK compiler rejected this binding: cannot access associated type 'ModifierBase' from 'LibraryContentProvider'; use a concrete type or generic parameter base instead