$npx -y skills add rshankras/claude-code-apple-skills --skill live-activity-generatorGenerate ActivityKit Live Activity infrastructure with Dynamic Island layouts, Lock Screen presentation, and push-to-update support. Use when adding Live Activities to an iOS app.
| 1 | # Live Activity Generator |
| 2 | |
| 3 | Generate a complete ActivityKit Live Activity implementation with Dynamic Island layouts, Lock Screen presentation, activity lifecycle management, and push-to-update support. |
| 4 | |
| 5 | ## When This Skill Activates |
| 6 | |
| 7 | Use this skill when the user: |
| 8 | - Asks to "add Live Activities" or "add a Live Activity" |
| 9 | - Mentions "Dynamic Island" layouts |
| 10 | - Wants real-time status updates on the Lock Screen |
| 11 | - Asks about "ActivityKit" or "ActivityAttributes" |
| 12 | - Mentions "push-to-update" for live activities |
| 13 | - Wants to show ongoing progress (delivery tracking, sports scores, timers, workouts) |
| 14 | |
| 15 | ## Pre-Generation Checks |
| 16 | |
| 17 | ### 1. Project Context Detection |
| 18 | - [ ] Check for existing ActivityKit implementations |
| 19 | - [ ] Check for an existing widget extension target |
| 20 | - [ ] Verify deployment target is iOS 16.1+ |
| 21 | - [ ] Identify source file locations |
| 22 | |
| 23 | ### 2. Conflict Detection |
| 24 | Search for existing Live Activity code: |
| 25 | ``` |
| 26 | Glob: **/*Activity*.swift, **/*LiveActivity*.swift |
| 27 | Grep: "ActivityKit" or "ActivityAttributes" or "ActivityConfiguration" |
| 28 | ``` |
| 29 | |
| 30 | If an existing widget extension is found: |
| 31 | - Ask if the Live Activity should be added to the existing widget bundle |
| 32 | - Check for existing `WidgetBundle` to extend |
| 33 | |
| 34 | If Live Activity code already exists: |
| 35 | - Ask user whether to replace or extend |
| 36 | |
| 37 | ### 3. Required Capabilities |
| 38 | |
| 39 | **Live Activities require:** |
| 40 | - iOS 16.1+ deployment target |
| 41 | - `NSSupportsLiveActivities` set to `YES` in Info.plist |
| 42 | - A widget extension target (can share with existing WidgetKit widgets) |
| 43 | - For push updates: `NSSupportsLiveActivitiesFrequentUpdates` (optional, iOS 16.2+) |
| 44 | |
| 45 | ## Configuration Questions |
| 46 | |
| 47 | Ask user via AskUserQuestion: |
| 48 | |
| 49 | 1. **What is the Live Activity for?** (freeform) |
| 50 | - Examples: delivery tracking, sports score, workout timer, ride-sharing, food order |
| 51 | - This determines the attribute fields and content state |
| 52 | |
| 53 | 2. **What data should appear on the Lock Screen?** (freeform) |
| 54 | - Static data (set at start, does not change): e.g., restaurant name, order number |
| 55 | - Dynamic data (updated over time): e.g., ETA, driver location, score |
| 56 | |
| 57 | 3. **Dynamic Island layout needs?** |
| 58 | - Compact (leading + trailing) only |
| 59 | - Expanded (leading, trailing, center, bottom) only |
| 60 | - Both compact and expanded (recommended) |
| 61 | |
| 62 | 4. **Push-to-update support?** |
| 63 | - Yes -- server can update the activity remotely via APNs |
| 64 | - No -- updates only from the app process |
| 65 | |
| 66 | 5. **Alert configuration when ending?** |
| 67 | - Yes -- show a final alert on the Lock Screen when the activity ends |
| 68 | - No -- dismiss silently |
| 69 | |
| 70 | ## Generation Process |
| 71 | |
| 72 | ### Step 1: Determine File Locations |
| 73 | |
| 74 | Check project structure: |
| 75 | - If a widget extension target exists, add files there |
| 76 | - Otherwise, instruct user to create a Widget Extension target first |
| 77 | |
| 78 | For the activity manager (lives in the main app target): |
| 79 | - If `Sources/` exists --> `Sources/LiveActivity/` |
| 80 | - If `App/` exists --> `App/LiveActivity/` |
| 81 | - Otherwise --> `LiveActivity/` |
| 82 | |
| 83 | For the widget extension views: |
| 84 | - Place inside the existing widget extension directory (e.g., `MyAppWidgets/`) |
| 85 | |
| 86 | ### Step 2: Create Core Files |
| 87 | |
| 88 | Generate these files based on configuration answers: |
| 89 | |
| 90 | 1. **`{Name}ActivityAttributes.swift`** -- Shared between app and widget extension |
| 91 | - `ActivityAttributes` struct with static properties |
| 92 | - Nested `ContentState` with dynamic properties |
| 93 | 2. **`{Name}LiveActivityView.swift`** -- Widget extension file |
| 94 | - `ActivityConfiguration` with Lock Screen, Dynamic Island layouts |
| 95 | 3. **`{Name}ActivityManager.swift`** -- Main app target file |
| 96 | - Protocol-based manager for start, update, end, and push token handling |
| 97 | |
| 98 | ### Step 3: Generate Code from Templates |
| 99 | |
| 100 | Use the templates in **templates.md** and customize based on user answers: |
| 101 | - Replace placeholder attribute names with real fields |
| 102 | - Configure Dynamic Island regions based on layout choice |
| 103 | - Include or exclude push-to-update code |
| 104 | - Include or exclude alert configuration |
| 105 | |
| 106 | ## Info.plist Required |
| 107 | |
| 108 | ### Main App Target |
| 109 | ```xml |
| 110 | <key>NSSupportsLiveActivities</key> |
| 111 | <true/> |
| 112 | |
| 113 | <!-- Optional: for frequent push updates (iOS 16.2+) --> |
| 114 | <key>NSSupportsLiveActivitiesFrequentUpdates</key> |
| 115 | <true/> |
| 116 | ``` |
| 117 | |
| 118 | ## Output Format |
| 119 | |
| 120 | After generation, provide: |
| 121 | |
| 122 | ### Files Created |
| 123 | |
| 124 | ``` |
| 125 | Sources/LiveActivity/ |
| 126 | ├── {Name}ActivityAttributes.swift # Shared: attributes + content state |
| 127 | └── {Name}ActivityManager.swift # Main app: lifecycle management |
| 128 | |
| 129 | MyAppWidgets/ |
| 130 | ├── {Name}LiveActivityView.swift # Widget ext: all Live Activity UI |
| 131 | └── (update WidgetBundle if needed) |
| 132 | ``` |
| 133 | |
| 134 | ### Integration Steps |
| 135 | |
| 136 | **1. Add the widget extension target (if not present):** |
| 137 | - File > New > Target > Widget Extension |
| 138 | - Ensure "Include Live Activity" |