Contents

AppExtensionPoint

A type you use to declare your host app’s extension points and bind to them from app extensions.

Declaration

struct AppExtensionPoint

Mentioned in

Overview

Use this type both to declare your app’s supported extension points and to bind to those extension points. To declare an extension point your app supports, extend this type by adding a static variable with the details of your extension point. Annotate your variable with the AppExtensionPoint.Definition property wrapper and specify the name and other attributes of your extension point. The following example adds two extension point with different configurations:

extension AppExtensionPoint {
    @Definition
    static var MySecureFeature : AppExtensionPoint {
        Name(“MySecureFeature”)
        UserInterface(false)
        EnhancedSecurity(true)
    }

    @Definition
    static var MyInterfaceFeature : AppExtensionPoint {
        Name(“MyInterfaceFeature”)
        UserInterface(true)
    }

}

In addition to defining your app’s extension points, use this type in an app extension to bind to an extension point. In your app extension’s source code, add a variable that contains the AppExtensionPoint type. Set the value of that variable to the extension point identifier you support. Annotate your variable declaration with the AppExtensionPoint.Bind property wrapper, as shown in the following example:

struct MyAppExtension: AppExtension {
    @AppExtensionPoint.Bind
    var boundAppExtensionPoint: AppExtensionPoint {
        AppExtensionPoint.Identifier(name “MySecureFeature”)
    }
}

To make extension point and binding information available at runtime, use the compiler to add the relevant information to your built products. In your Xcode project, add the EX_ENABLE_EXTENSION_POINT_GENERATION flag to the build settings of your host app and app extension. When the value of the flag is true, the compiler collects the target’s extension point definitions or bindings and writes them to the target’s bundle. For example, it creates a special file in the host app’s bundle and adds the extension point definitions to that file. The system collects definition and binding information at installation time and uses it to match the host app to relevant app extensions.

Topics

Creating an app-extension point

Declaring an extension point

Binding to an extension point

Detecting app extensions

Getting error codes

Protocols

Structures

See Also

Extension-point management