Mobile Development 8 min read

How to Implement iOS Screen Sharing with ReplayKit: A Step‑by‑Step Guide

This article explains the background, evolution, and implementation steps of iOS screen sharing using Apple's ReplayKit framework, covering cross‑app sharing architecture, extension setup, data handling, UI controls, and key development considerations such as memory limits and inter‑process communication.

360 Zhihui Cloud Developer
360 Zhihui Cloud Developer
360 Zhihui Cloud Developer
How to Implement iOS Screen Sharing with ReplayKit: A Step‑by‑Step Guide

Background

iOS applications can implement screen sharing to allow users to broadcast their screen content as video during video calls or interactive live streams, enhancing interaction and communication efficiency. This feature is valuable in video conferencing, online education, and game live streaming scenarios.

Screen sharing can be achieved via two approaches: in‑app sharing and cross‑app sharing, with Apple's ReplayKit framework providing the necessary APIs.

ReplayKit Introduction

ReplayKit, introduced in iOS 9, enables developers to record and live‑stream screen content and audio, including microphone input. It offers simple APIs for screen capture, supports extensions for real‑time data processing, and has evolved through iOS versions to add features such as global recording, direct launch, and Loop Buffer for continuous short‑duration recording.

iOS 9: Initial release, supports in‑app screen and audio recording, generates MP4 files.

iOS 10: Added real‑time video data access for live streaming via extensions.

iOS 11: Supported global system‑wide recording via Control Center.

iOS 12: Introduced direct launch with RFSystemBroadcastPickerView , simplifying user workflow.

iOS 15: Added Loop Buffer for up to 15 seconds of continuous recording.

Cross‑App Sharing Process

The overall architecture for iOS video‑conference screen sharing using cross‑app sharing is illustrated below.

The sharing workflow includes:

User prepares the app.

User launches ReplayKit from Control Center.

ReplayKit Extension starts receiving audio‑video streams and pushes them to the server.

User stops recording from Control Center, ending the process.

Implementation Details

Key steps for developers:

Ensure devices run iOS 12.0+ and have sufficient performance (recommended iPhone X or later).

Create a Broadcast Upload Extension target in Xcode.

Configure an App Group to share data between the main app and the extension.

In the extension’s SampleHandler , implement broadcastStartedWithSetupInfo , broadcastPaused , broadcastResumed , and broadcastFinished to manage the sharing lifecycle. Process captured buffers in processSampleBuffer:withType: , handling video frames ( RPSampleBufferTypeVideo ) and audio frames ( RPSampleBufferTypeAudioApp , RPSampleBufferTypeAudioMic ) and forward them using a video‑cloud RTC SDK.

Provide UI controls in the app to start/stop sharing, typically using RPSystemBroadcastPickerView , or allow users to invoke sharing from Control Center.

Conclusion

ReplayKit has progressed from basic in‑app recording to system‑wide capture with advanced features like Loop Buffer, but its APIs remain complex and privacy‑focused, making implementation challenging. Developers must handle iOS version compatibility, memory limits (extension processes must stay under 50 MB), and inter‑process communication (via sockets, App Group NSUserDefaults , or CFNotificationCenter ). Improper termination can cause subsequent sharing attempts to fail, often requiring a device reboot.

mobile developmentiOSVideo StreamingReplayKitScreen Sharing
360 Zhihui Cloud Developer
Written by

360 Zhihui Cloud Developer

360 Zhihui Cloud is an enterprise open service platform that aims to "aggregate data value and empower an intelligent future," leveraging 360's extensive product and technology resources to deliver platform services to customers.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.