name: shareplay-developer
description: Build, integrate, and troubleshoot SharePlay GroupActivities features, including GroupActivity definitions, activation flows, GroupSession lifecycle, messaging and journals, ShareLink and SharePlay UI surfaces, and visionOS spatial coordination. Use when implementing or debugging SharePlay experiences across Apple platforms, especially visionOS.
SharePlay Developer
Description and Goals
This skill provides comprehensive guidance for implementing SharePlay experiences with the GroupActivities framework. It covers activity definition, session lifecycle, state synchronization, UI surfaces, and visionOS spatial coordination.
Goals
- Enable developers to build SharePlay experiences across Apple platforms
- Guide proper GroupActivity definition and activation
- Support GroupSession lifecycle management
- Help implement state synchronization with messaging and journals
- Enable spatial coordination for visionOS experiences
What This Skill Should Do
When implementing SharePlay features, this skill should:
- Guide activity setup - Help you define GroupActivity types and metadata
- Handle activation - Show how to check eligibility and activate SharePlay
- Manage sessions - Demonstrate GroupSession lifecycle and participant management
- Sync state - Provide patterns for messaging and journal-based synchronization
- Coordinate spatially - Show how to use SystemCoordinator for visionOS spatial experiences
- Present UI - Guide use of ShareLink and other SharePlay UI surfaces
Load the appropriate reference file from the tables below for detailed usage, code examples, and best practices.
Quick Start Workflow
- Add the Group Activities capability and
com.apple.developer.group-session entitlement in Xcode.
- Define a
GroupActivity type per experience and keep its data minimal and Codable.
- Provide
GroupActivityMetadata with a clear title, type, and fallback URL.
- Check
GroupStateObserver.isEligibleForGroupSession and activate or present SharePlay UI.
- Listen for sessions with
for await session in Activity.sessions() and store the session strongly.
- Configure
SystemCoordinator before join() when spatial personas or immersive spaces are involved.
- Call
session.join() only after UI and state are ready.
- Sync state with
GroupSessionMessenger (small, time-sensitive) or GroupSessionJournal (attachments).
- Observe
activeParticipants and send a state snapshot for late joiners.
- Call
leave() or end() and cancel tasks when the session invalidates.
Information About the Skill
Core Concepts
Activity Definition
- Use
GroupActivity to define the shareable experience and keep payloads minimal.
- Provide
GroupActivity.metadata with title, subtitle, preview image, and fallback URL.
- Set
GroupActivityMetadata.type to a matching ActivityType value.
- Use
GroupActivityActivationResult from prepareForActivation() to decide activation.
- Use
GroupActivityTransferRepresentation for ShareLink and share sheets.
Session Lifecycle and Participants
- Use
GroupSession to manage the live activity; call join(), leave(), or end().
- Observe
GroupSession.state, activeParticipants, and isLocallyInitiated to drive UI.
- Use
GroupSession.sceneSessionIdentifier to map sessions to scenes when needed.
- Call
requestForegroundPresentation() when the activity needs the app visible.
- Use
GroupSession.showNotice(_:) or postEvent(_:) for system playback notices.
Messaging and Transfer
- Use
GroupSessionMessenger for small messages (<= 256 KB).
- Use
.reliable delivery for critical state and .unreliable for high-frequency updates.
- Use
GroupSessionJournal for attachments and large data (<= 100 MB).
UI Surfaces to Start SharePlay
- Use
ShareLink with Transferable + GroupActivityTransferRepresentation in SwiftUI.
- Use
GroupActivitySharingController in UIKit/AppKit when no FaceTime call is active.
- Use
NSItemProvider.registerGroupActivity(...) in share sheets when needed.
visionOS Spatial Coordination
- Use
SystemCoordinator from GroupSession.systemCoordinator for spatial layout.
- Set
spatialTemplatePreference and supportsGroupImmersiveSpace as needed.
- Use
localParticipantStates and remoteParticipantStates to track poses.
- Use
groupActivityAssociation(_:) to choose the primary scene.
Reference Files
| Reference |
When to Use |
[REFERENCE.md](references/REFERENCE.md) |
When looking for GroupActivities-focused code samples and excerpts. |
Implementation Patterns
- Send a full state snapshot when new participants join.
- Keep UI state separate from shared game state to reduce message churn.
- Use
GroupSessionMessenger for transient actions and GroupSessionJournal for durable data.
- Prefer AVFoundation coordinated playback for media sync.
Pitfalls and Checks
- Keep
GroupActivity data minimal; send state changes via messenger or journal.
- Store strong references to
GroupSession, GroupSessionMessenger, and GroupSessionJournal.
- Join only when UI and state are ready; call
leave() on teardown.
- Handle late joiners by sending the current state snapshot on
activeParticipants change.
1---2name: shareplay-developer3description: Build, integrate, and troubleshoot SharePlay GroupActivities features, including GroupActivity definitions, activation flows, GroupSession lifecycle, messaging and journals, ShareLink and SharePlay UI4---5
6---
7
8## name: shareplay-developer
9description: Build, integrate, and troubleshoot SharePlay GroupActivities features, including GroupActivity definitions, activation flows, GroupSession lifecycle, messaging and journals, ShareLink and SharePlay UI surfaces, and visionOS spatial coordination. Use when implementing or debugging SharePlay experiences across Apple platforms, especially visionOS.
10
11# SharePlay Developer
12
13## Description and Goals
14
15This skill provides comprehensive guidance for implementing SharePlay experiences with the GroupActivities framework. It covers activity definition, session lifecycle, state synchronization, UI surfaces, and visionOS spatial coordination.
16
17### Goals
18
19- Enable developers to build SharePlay experiences across Apple platforms
20- Guide proper GroupActivity definition and activation
21- Support GroupSession lifecycle management
22- Help implement state synchronization with messaging and journals
23- Enable spatial coordination for visionOS experiences
24
25## What This Skill Should Do
26
27When implementing SharePlay features, this skill should:
28
291. **Guide activity setup** - Help you define GroupActivity types and metadata
302. **Handle activation** - Show how to check eligibility and activate SharePlay
313. **Manage sessions** - Demonstrate GroupSession lifecycle and participant management
324. **Sync state** - Provide patterns for messaging and journal-based synchronization
335. **Coordinate spatially** - Show how to use SystemCoordinator for visionOS spatial experiences
346. **Present UI** - Guide use of ShareLink and other SharePlay UI surfaces
35
36Load the appropriate reference file from the tables below for detailed usage, code examples, and best practices.
37
38### Quick Start Workflow
39
401. Add the Group Activities capability and `com.apple.developer.group-session` entitlement in Xcode.
412. Define a `GroupActivity` type per experience and keep its data minimal and `Codable`.
423. Provide `GroupActivityMetadata` with a clear title, type, and fallback URL.
434. Check `GroupStateObserver.isEligibleForGroupSession` and activate or present SharePlay UI.
445. Listen for sessions with `for await session in Activity.sessions()` and store the session strongly.
456. Configure `SystemCoordinator` before `join()` when spatial personas or immersive spaces are involved.
467. Call `session.join()` only after UI and state are ready.
478. Sync state with `GroupSessionMessenger` (small, time-sensitive) or `GroupSessionJournal` (attachments).
489. Observe `activeParticipants` and send a state snapshot for late joiners.
4910. Call `leave()` or `end()` and cancel tasks when the session invalidates.
50
51## Information About the Skill
52
53### Core Concepts
54
55#### Activity Definition
56
57- Use `GroupActivity` to define the shareable experience and keep payloads minimal.
58- Provide `GroupActivity.metadata` with title, subtitle, preview image, and fallback URL.
59- Set `GroupActivityMetadata.type` to a matching `ActivityType` value.
60- Use `GroupActivityActivationResult` from `prepareForActivation()` to decide activation.
61- Use `GroupActivityTransferRepresentation` for `ShareLink` and share sheets.
62
63#### Session Lifecycle and Participants
64
65- Use `GroupSession` to manage the live activity; call `join()`, `leave()`, or `end()`.
66- Observe `GroupSession.state`, `activeParticipants`, and `isLocallyInitiated` to drive UI.
67- Use `GroupSession.sceneSessionIdentifier` to map sessions to scenes when needed.
68- Call `requestForegroundPresentation()` when the activity needs the app visible.
69- Use `GroupSession.showNotice(_:)` or `postEvent(_:)` for system playback notices.
70
71#### Messaging and Transfer
72
73- Use `GroupSessionMessenger` for small messages (<= 256 KB).
74- Use `.reliable` delivery for critical state and `.unreliable` for high-frequency updates.
75- Use `GroupSessionJournal` for attachments and large data (<= 100 MB).
76
77#### UI Surfaces to Start SharePlay
78
79- Use `ShareLink` with `Transferable` + `GroupActivityTransferRepresentation` in SwiftUI.
80- Use `GroupActivitySharingController` in UIKit/AppKit when no FaceTime call is active.
81- Use `NSItemProvider.registerGroupActivity(...)` in share sheets when needed.
82
83#### visionOS Spatial Coordination
84
85- Use `SystemCoordinator` from `GroupSession.systemCoordinator` for spatial layout.
86- Set `spatialTemplatePreference` and `supportsGroupImmersiveSpace` as needed.
87- Use `localParticipantStates` and `remoteParticipantStates` to track poses.
88- Use `groupActivityAssociation(_:)` to choose the primary scene.
89
90### Reference Files
91
92
93| Reference | When to Use |
94| ----------------------------------------- | ------------------------------------------------------------------- |
95| `[REFERENCE.md](references/REFERENCE.md)` | When looking for GroupActivities-focused code samples and excerpts. |
96
97
98### Implementation Patterns
99
100- Send a full state snapshot when new participants join.
101- Keep UI state separate from shared game state to reduce message churn.
102- Use `GroupSessionMessenger` for transient actions and `GroupSessionJournal` for durable data.
103- Prefer AVFoundation coordinated playback for media sync.
104
105### Pitfalls and Checks
106
107- Keep `GroupActivity` data minimal; send state changes via messenger or journal.
108- Store strong references to `GroupSession`, `GroupSessionMessenger`, and `GroupSessionJournal`.
109- Join only when UI and state are ready; call `leave()` on teardown.
110- Handle late joiners by sending the current state snapshot on `activeParticipants` change.
111