Skip to content

Commit

Permalink
fix: fix swift name mangling for SwiftUI hosting controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
TizianoCoroneo committed Feb 28, 2024
1 parent 22575f7 commit 3b4263b
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3b4263b

Please sign in to comment.