88
99import Foundation
1010import GitHawkRoutes
11+ import Crashlytics
1112
1213private func register< T: Routable & RoutePerformable > (
1314 route: T . Type ,
@@ -18,6 +19,16 @@ private func register<T: Routable & RoutePerformable>(
1819
1920private var hasSwizzledChildViewController = false
2021
22+ private func logMissingRouter( ) {
23+ let trace = Thread . callStackSymbols. joined ( separator: " \n " )
24+ print ( " ERROR: Router not wired up. Callsite: " )
25+ print ( trace)
26+ Answers . logCustomEvent (
27+ withName: " missing-router " ,
28+ customAttributes: [ " trace " : trace]
29+ )
30+ }
31+
2132extension UIViewController {
2233
2334 fileprivate class func swizzleChildViewController( ) {
@@ -68,30 +79,20 @@ extension UIViewController {
6879 }
6980 }
7081
71- func route_push( route: Routable & RoutePerformable ) {
72- if router == nil { print ( " ERROR: router was not wired up " ) }
73- router? . handle ( route: route, from: self )
74- }
75-
76- func route_detail( route: Routable & RoutePerformable ) {
77- if router == nil { print ( " ERROR: router was not wired up " ) }
78- router? . handle ( route: route, from: nil )
79- }
80-
8182 // MARK: Remove after migration
8283
8384 func route_push( to controller: UIViewController ) {
84- if router == nil { print ( " ERROR: router was not wired up " ) }
85+ if router == nil { logMissingRouter ( ) }
8586 router? . push ( from: self , to: controller)
8687 }
8788
8889 func route_detail( to controller: UIViewController ) {
89- if router == nil { print ( " ERROR: router was not wired up " ) }
90+ if router == nil { logMissingRouter ( ) }
9091 router? . detail ( controller: controller)
9192 }
9293
9394 func route_present( to controller: UIViewController ) {
94- if router == nil { print ( " ERROR: router was not wired up " ) }
95+ if router == nil { logMissingRouter ( ) }
9596 router? . present ( from: self , to: controller)
9697 }
9798
0 commit comments