Usage Commands Cloud Contributors

App Extensions

Product Types

iOS applications have a wide range of app extension types (Notification Service, Intents, Widgets, etc…).

Some of those extensions have dedicated product types (e.g. .messagesExtension), while others may be represented using the generic .appExtension product type.

For example, this is how a Notification Service Extension can be declared:

let project = Project(name: "App",
targets: [
Target(name: "App",
platform: .iOS,
product: .app,
bundleId: "io.tuist.App",
infoPlist: "Info.plist",
sources: ["Sources/**"],
dependencies: [
.target(name: "NotificationServiceExtension"),
]),
Target(name: "NotificationServiceExtension",
platform: .iOS,
product: .appExtension,
bundleId: "io.tuist.App.NotificationServiceExtension",
infoPlist: .extendingDefault(with: [
"CFBundleDisplayName": "$(PRODUCT_NAME)",
"NSExtension": [
"NSExtensionPointIdentifier": "com.apple.usernotifications.service",
"NSExtensionPrincipalClass": "$(PRODUCT_MODULE_NAME).NotificationService"
]
]),
sources: "NotificationServiceExtension/**",
dependencies: [
]),
])
Copy the content

Info Plist Keys

Different app extensions have a different set of Info.plist key requirements, one of the main ones is the NSExtensionPointIdentifier key that identifies the extension type.

For example, here is a list of some of the extension types and their corresponding identifier value:

ExtensionNSExtensionPointIdentifier
Intents Extensioncom.apple.intents-service
Intents UI Extensioncom.apple.intents-ui-service
Notification Servicecom.apple.usernotifications.service
Widgets Extensioncom.apple.widgetkit-extension

Knowing the different key/value requirements may be needed when leveraging the auto-generated Info.plist file (see Info Plist).

To find out what the identifier for an extension type is or any other required key, you can examine the values within an existing Info.plist file (if one exists), or create a new sample project using the Xcode UI with the desired app extension target and examine the Info.plist file created by Xcode.

Associating Extensions With Applications

To associate or include extensions within an application, the application target needs to declare a dependency on the corresponding extension targets.

For example:

let project = Project(name: "App",
targets: [
Target(name: "App",
platform: .iOS,
product: .app,
bundleId: "io.tuist.App",
infoPlist: "Info.plist",
sources: ["Sources/**"],
dependencies: [
.target(name: "NotificationServiceExtension"),
.target(name: "WidgetExtension"),
// ...
]),
// ...
])
Copy the content

By using this website, you agree to our cookie policy.