From 30d1eb788b30fa08f1aed9e068c06a2947b0c82d Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto <5731772+marandaneto@users.noreply.github.com> Date: Mon, 25 Mar 2024 13:46:51 +0100 Subject: [PATCH] chore: swiftui not supported for recording (#120) --- PostHog/Replay/PostHogReplayIntegration.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/PostHog/Replay/PostHogReplayIntegration.swift b/PostHog/Replay/PostHogReplayIntegration.swift index 63e165103..c4692d520 100644 --- a/PostHog/Replay/PostHogReplayIntegration.swift +++ b/PostHog/Replay/PostHogReplayIntegration.swift @@ -6,6 +6,7 @@ // #if os(iOS) import Foundation + import SwiftUI import UIKit import WebKit @@ -213,8 +214,20 @@ return } + if let controller = window.rootViewController { + if controller is AnyObjectUIHostingViewController { + hedgeLog("SwiftUI snapshot not supported.") + return + } + } + // TODO: offload conversion to off main thread generateSnapshot(window) } } + + private protocol AnyObjectUIHostingViewController: AnyObject {} + + extension UIHostingController: AnyObjectUIHostingViewController {} + #endif