From 3b4263b739abd740105d41f45b6008ccd991f744 Mon Sep 17 00:00:00 2001 From: TizianoCoroneo Date: Wed, 28 Feb 2024 15:11:53 +0100 Subject: [PATCH] fix: fix swift name mangling for SwiftUI hosting controllers --- .../Helpers/Platforms/iOS/RSiOSScreenViewEvents.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/Classes/Helpers/Platforms/iOS/RSiOSScreenViewEvents.swift b/Sources/Classes/Helpers/Platforms/iOS/RSiOSScreenViewEvents.swift index 4877c729..4e9cc41f 100644 --- a/Sources/Classes/Helpers/Platforms/iOS/RSiOSScreenViewEvents.swift +++ b/Sources/Classes/Helpers/Platforms/iOS/RSiOSScreenViewEvents.swift @@ -42,7 +42,12 @@ extension UIViewController { @objc func rsViewDidAppear(_ animated: Bool) { - var name = NSStringFromClass(type(of: self)) + var name = String(describing: type(of: self)) + if name.starts(with: "UIHostingController") { + name.removeFirst("UIHostingController".count + 1) // Remove `UIHostingController<` + if name.hasSuffix(">") { name.removeLast(1) } // Remove last `>` + } + name = name.replacingOccurrences(of: "ViewController", with: "") let screenMessage = ScreenMessage(title: name, properties: ["automatic": true, "name": name]) UIViewController.client?.process(message: screenMessage)