A Swift demo project showcasing how to build dynamic App Shortcuts using AppIntents, integrate them with Spotlight Search, and personalize them with custom icons (e.g., balloons).
This project demonstrates clean architecture with dependency injection and persistent shortcut storage.
- β iOS 16+ App Intents usage
- β
Spotlight integration with
AppEntityand custom images - β Dynamic shortcut generation using mock models
- β
Persistence with
UserDefaults - β Thematic shortcut icons (Red, Green, Blue balloons)
- β Modular code with protocol-based dependency injection
DKAppIntentModeldefines shortcut data (UUID, name, image name)DKAppEntityconforms toAppEntity, enabling Spotlight visibilityDKAppIntentis triggered when the user selects a shortcutDKShortcutsHandlerinitializes and stores balloon shortcut modelsDKAppEntityManagerpersists data usingUserDefaultsDisplayRepresentationis used to show custom icons in Spotlight
Balloon-themed icons are used to represent each shortcut.
DisplayRepresentation(
title: "\(model.name)",
image: .init(named: model.imageIdentifier)
)
A protocol DKAppEntityManagerProtocol is used to enable testable and decoupled logic.
It is injected like this:
let handler = DKShortcutsHandler(entityManager: DKAppEntityManager.shared)
handler.initializeShortcuts()
Follow these steps to test the demo and see your shortcuts in action:
-
Launch the App
- It initializes three balloon shortcuts: Red, Green, and Blue
-
Trigger a Shortcut
- Open the Shortcuts app or pull down on the home screen to use Spotlight
- Search for one of the shortcuts: e.g.,
"Red Balloon"
-
Tap to Execute
- The shortcut appears with its custom icon and name
- Tapping it triggers the
AppIntent(via deep link or simulated action)
