Contents

LibraryContentProvider

A source of Xcode library and code completion content.

Declaration

protocol LibraryContentProvider

Overview

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 views property, and returning an array of LibraryItem instances initialized with the views you want to publish:

struct LibraryViewContent: LibraryContentProvider {
    var views: [LibraryItem] {
        LibraryItem(MyView())
    }
}

Add view modifiers by implementing the modifiers(base:) 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 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.

Topics

Adding Views

Adding Modifiers

Building Arrays

See Also

Library customization