$npx -y skills add rshankras/claude-code-apple-skills --skill deep-linkingGenerate deep linking infrastructure with URL schemes, Universal Links, and App Intents for Siri/Shortcuts. Use when handling custom URL schemes, Universal Links/Associated Domains, or routing to specific content from external sources.
| 1 | # Deep Linking Generator |
| 2 | |
| 3 | Generate deep linking infrastructure with URL schemes, Universal Links, and App Intents for Siri/Shortcuts. |
| 4 | |
| 5 | ## When This Skill Activates |
| 6 | |
| 7 | - User wants to handle custom URL schemes (myapp://) |
| 8 | - User mentions Universal Links or Associated Domains |
| 9 | - User wants Siri Shortcuts or App Intents |
| 10 | - User needs to navigate to specific content from external sources |
| 11 | |
| 12 | ## Pre-Generation Checks |
| 13 | |
| 14 | Before generating, verify: |
| 15 | |
| 16 | 1. **Existing Deep Link Handling** |
| 17 | ```bash |
| 18 | # Check for existing URL handling |
| 19 | grep -r "onOpenURL\|open.*url\|handleOpen" --include="*.swift" | head -5 |
| 20 | ``` |
| 21 | |
| 22 | 2. **URL Scheme in Info.plist** |
| 23 | ```bash |
| 24 | # Check for CFBundleURLTypes |
| 25 | find . -name "Info.plist" -exec grep -l "CFBundleURLSchemes" {} \; |
| 26 | ``` |
| 27 | |
| 28 | 3. **Associated Domains Entitlement** |
| 29 | ```bash |
| 30 | find . -name "*.entitlements" -exec grep -l "associated-domains" {} \; |
| 31 | ``` |
| 32 | |
| 33 | ## Configuration Questions |
| 34 | |
| 35 | ### 1. URL Scheme |
| 36 | - What custom URL scheme? (e.g., `myapp`) |
| 37 | - This enables `myapp://path/to/content` links |
| 38 | |
| 39 | ### 2. Universal Links |
| 40 | - **Yes** - Handle HTTPS links (requires AASA file on server) |
| 41 | - **No** - Custom URL scheme only |
| 42 | |
| 43 | ### 3. App Intents / Siri Shortcuts |
| 44 | - **Yes** - Enable voice commands and Shortcuts app |
| 45 | - **No** - URL-based deep linking only |
| 46 | |
| 47 | ### 4. Link Types |
| 48 | - Profile: `/users/{id}` |
| 49 | - Content: `/items/{id}` |
| 50 | - Actions: `/actions/share`, `/actions/create` |
| 51 | - Custom routes based on app needs |
| 52 | |
| 53 | ## Generated Files |
| 54 | |
| 55 | ### Core Infrastructure |
| 56 | ``` |
| 57 | Sources/DeepLinking/ |
| 58 | ├── DeepLinkRouter.swift # Central router |
| 59 | ├── DeepLink.swift # Route definitions |
| 60 | └── UniversalLinkHandler.swift # Universal link processing |
| 61 | ``` |
| 62 | |
| 63 | ### App Intents (Optional) |
| 64 | ``` |
| 65 | Sources/AppIntents/ |
| 66 | ├── OpenContentIntent.swift # Open specific content |
| 67 | ├── AppShortcuts.swift # Shortcuts provider |
| 68 | └── ContentEntity.swift # Entities for Spotlight/Siri |
| 69 | ``` |
| 70 | |
| 71 | ### Server Files (Universal Links) |
| 72 | ``` |
| 73 | .well-known/ |
| 74 | └── apple-app-site-association # AASA file template |
| 75 | ``` |
| 76 | |
| 77 | ## Key Features |
| 78 | |
| 79 | ### Route Definitions |
| 80 | |
| 81 | ```swift |
| 82 | enum DeepLink: Equatable { |
| 83 | case home |
| 84 | case profile(userId: String) |
| 85 | case item(itemId: String) |
| 86 | case settings |
| 87 | case action(ActionType) |
| 88 | |
| 89 | enum ActionType { |
| 90 | case share(itemId: String) |
| 91 | case create |
| 92 | } |
| 93 | } |
| 94 | ``` |
| 95 | |
| 96 | ### URL Parsing |
| 97 | |
| 98 | ```swift |
| 99 | extension DeepLink { |
| 100 | init?(url: URL) { |
| 101 | guard let components = URLComponents(url: url, resolvingAgainstBaseURL: true) else { |
| 102 | return nil |
| 103 | } |
| 104 | |
| 105 | let pathComponents = components.path.split(separator: "/").map(String.init) |
| 106 | |
| 107 | switch pathComponents { |
| 108 | case ["users", let userId]: |
| 109 | self = .profile(userId: userId) |
| 110 | case ["items", let itemId]: |
| 111 | self = .item(itemId: itemId) |
| 112 | case ["settings"]: |
| 113 | self = .settings |
| 114 | default: |
| 115 | self = .home |
| 116 | } |
| 117 | } |
| 118 | } |
| 119 | ``` |
| 120 | |
| 121 | ### SwiftUI Integration |
| 122 | |
| 123 | ```swift |
| 124 | @main |
| 125 | struct MyApp: App { |
| 126 | @State private var router = DeepLinkRouter() |
| 127 | |
| 128 | var body: some Scene { |
| 129 | WindowGroup { |
| 130 | ContentView() |
| 131 | .environment(router) |
| 132 | .onOpenURL { url in |
| 133 | router.handle(url) |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | ``` |
| 139 | |
| 140 | ## App Intents Integration |
| 141 | |
| 142 | ### OpenIntent for Navigation |
| 143 | |
| 144 | ```swift |
| 145 | struct OpenItemIntent: OpenIntent { |
| 146 | static let title: LocalizedStringResource = "Open Item" |
| 147 | |
| 148 | @Parameter(title: "Item") |
| 149 | var target: ItemEntity |
| 150 | |
| 151 | func perform() async throws -> some IntentResult { |
| 152 | await router.navigate(to: .item(itemId: target.id)) |
| 153 | return .result() |
| 154 | } |
| 155 | } |
| 156 | ``` |
| 157 | |
| 158 | ### App Shortcuts |
| 159 | |
| 160 | ```swift |
| 161 | struct AppShortcuts: AppShortcutsProvider { |
| 162 | static var appShortcuts: [AppShortcut] { |
| 163 | AppShortcut( |
| 164 | intent: OpenItemIntent(), |
| 165 | phrases: [ |
| 166 | "Open \(\.$target) in \(.applicationName)", |
| 167 | "Show \(\.$target)" |
| 168 | ], |
| 169 | shortTitle: "Open Item", |
| 170 | systemImageName: "doc" |
| 171 | ) |
| 172 | } |
| 173 | } |
| 174 | ``` |
| 175 | |
| 176 | ## Required Capabilities |
| 177 | |
| 178 | ### URL Scheme (Info.plist) |
| 179 | ```xml |
| 180 | <key>CFBundleURLTypes</key> |
| 181 | <array> |
| 182 | <dict> |
| 183 | <key>CFBundleURLSchemes</key> |
| 184 | <array> |
| 185 | <string>myapp</string> |
| 186 | </array> |
| 187 | <key>CFBundleURLName</key> |
| 188 | <string>com.yourcompany.myapp</string> |
| 189 | </dict> |
| 190 | </array> |
| 191 | ``` |
| 192 | |
| 193 | ### Universal Links (Entitlements) |
| 194 | ```xml |
| 195 | <key>com.apple.developer.associated-domains</key> |
| 196 | <array> |
| 197 | <string>applinks:yourapp.com</string> |
| 198 | <string>applinks:www.yourapp.com</string> |
| 199 | </array> |
| 200 | ``` |
| 201 | |
| 202 | ### Server Configuration (AASA) |
| 203 | |
| 204 | Host at `https://yourapp.com/.well-known/apple-app-site-ass |