I'm trying to implement screen recording app using ReplayKit(Swift). It seems when I'm going outside the app, stops background record. After trying some documents, so far I understand I need to implement Broadcast Extension. If my understanding is right, then So please give me some programming guide about that.
Asked
Active
Viewed 2,548 times
1
-
Please check if this is possible. I don't think it is. – Cesare Mar 22 '20 at 15:34
-
Already there are some apps in iTunes having that feature. https://apps.apple.com/us/app/record-it-screen-recorder/id1245356545 – emraz Mar 23 '20 at 03:48
-
Have a look at https://stackoverflow.com/questions/68766698/how-can-i-get-my-app-to-show-in-the-screen-broadcast – Salman Khalid Apr 07 '23 at 10:59
2 Answers
2
You need to implement Broadcast Extension. Process is given below:
- Create a new Xcode project
- Import ReplayKit
- Add a UIView in storyboard and change its class to RPSystemBroadcastPickerView in storyboard Identity Inspector
- File > New > Target > Broadcast Upload Extension
- Xcode > Project Navigator > Targets > Select Extension > General > Change Deployment Info > Match with your main project
- Click on View created in step 3 should pop up view for broadcast.

Salman Khalid
- 543
- 5
- 23
1
Try this library
OR this one:
import ScreenCapture
let recorder = ScreenCapture.recordScreen("/path/to/save/to.mp4")
recorder.start()
...
recorder.stop()
let movieUrl = recorder.destination
Otherwise you could do:
import ReplayKit
import UIKit
class ViewController: UIViewController, RPPreviewViewControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Start", style: .plain, target: self, action: #selector(startRecording))
}
@objc func startRecording() {
let recorder = RPScreenRecorder.shared()
recorder.startRecording{ [unowned self] (error) in
if let unwrappedError = error {
print(unwrappedError.localizedDescription)
} else {
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Stop", style: .plain, target: self, action: #selector(self.stopRecording))
}
}
}
@objc func stopRecording() {
let recorder = RPScreenRecorder.shared()
recorder.stopRecording { [unowned self] (preview, error) in
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Start", style: .plain, target: self, action: #selector(self.startRecording))
if let unwrappedPreview = preview {
unwrappedPreview.previewControllerDelegate = self
self.present(unwrappedPreview, animated: true)
}
}
}
func previewControllerDidFinish(_ previewController: RPPreviewViewController) {
dismiss(animated: true)
}
}
Replay Kit only record it's current app screen, whenever the app becomes background, the recording will be stopped and that's by-design.

Peter
- 68
- 9
-
Above code only record the app screen but not record the entire iPhone screen. Like the app .. https://apps.apple.com/us/app/go-record-screen-recorder/id1345200849 – emraz Mar 21 '20 at 18:27