8
8
9
9
import Foundation
10
10
import GitHawkRoutes
11
+ import Crashlytics
11
12
12
13
private func register< T: Routable & RoutePerformable > (
13
14
route: T . Type ,
@@ -18,6 +19,16 @@ private func register<T: Routable & RoutePerformable>(
18
19
19
20
private var hasSwizzledChildViewController = false
20
21
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
+
21
32
extension UIViewController {
22
33
23
34
fileprivate class func swizzleChildViewController( ) {
@@ -68,30 +79,20 @@ extension UIViewController {
68
79
}
69
80
}
70
81
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
-
81
82
// MARK: Remove after migration
82
83
83
84
func route_push( to controller: UIViewController ) {
84
- if router == nil { print ( " ERROR: router was not wired up " ) }
85
+ if router == nil { logMissingRouter ( ) }
85
86
router? . push ( from: self , to: controller)
86
87
}
87
88
88
89
func route_detail( to controller: UIViewController ) {
89
- if router == nil { print ( " ERROR: router was not wired up " ) }
90
+ if router == nil { logMissingRouter ( ) }
90
91
router? . detail ( controller: controller)
91
92
}
92
93
93
94
func route_present( to controller: UIViewController ) {
94
- if router == nil { print ( " ERROR: router was not wired up " ) }
95
+ if router == nil { logMissingRouter ( ) }
95
96
router? . present ( from: self , to: controller)
96
97
}
97
98
0 commit comments