Structuring Your Code to Support App Extensions

Move your back-end services to a private framework so your app and app extensions can use them.


An app extension is an agent that acts on behalf of your app, vending services or providing information to the system when asked. Because they extend your app’s behavior, app extensions often need access to the same back-end services and data that your app uses.

If your app and app extension share services, consider structuring your code in the following way:

  • Implement your core services in a private shared framework. A private shared framework lets you place the code for accessing your services in one code module and use that code from multiple targets. Shared frameworks minimize the size of both executables and make testing easier by ensuring that each executable uses the same code path.

  • Use a shared container to store common resources. Put relevant images and data files into a shared container so your app and app extension can use them. You enable shared container support in the Capabilities tab of each target.

See Also

Siri Intents

Creating an Intents App Extension

Add and configure an Intents app extension in your Xcode project.

Dispatching Intents to Handler Objects

Provide SiriKit with an object capable of handling a given intent.

Resolving and Handling Intents

Resolve, confirm, and handle user requests for your app’s services.

protocol INIntentHandlerProviding

The interface for dispatching intents to the custom objects that handle those intents.

Extension-Related Classes

Learn about the classes you use to build your Intents extension.