development

App Groups

A shared data container that allows an App Clip, app extensions, and the parent app to read and write data to a common storage location on the same device.

App Groups enable data sharing between an app and its related components: App Clips, widgets, notification extensions, and other app extensions. They provide a shared UserDefaults container and a shared file directory that all group members can access.

How App Groups Work

When you enable App Groups in your entitlements, you specify a group identifier (e.g., group.com.yourcompany.yourapp). Any target that includes this group identifier in its entitlements can read and write to the shared container.

App Groups and App Clips

The most important use case for App Groups in modern development is data transfer between an App Clip and the full app. When a user interacts with your App Clip, you save their progress, preferences, or cart data to the shared container. When they later install and open the full app, it reads this data and provides a seamless continuation.

Configuration

  1. Enable “App Groups” capability in both your main app and App Clip targets in Xcode
  2. Create an App Group identifier in the Apple Developer portal
  3. Add the same group identifier to both targets
  4. Use UserDefaults(suiteName: "group.com.yourcompany.yourapp") to read and write shared data

Best Practices

  • Keep shared data lightweight (preferences, identifiers, small state)
  • Clean up App Clip data after the full app has migrated it
  • Don’t store sensitive information in the shared container without encryption
  • Both the App Clip and full app must handle the case where shared data does not exist