14
14
#import < React/RCTUtils.h>
15
15
#import < React/RCTVersion.h>
16
16
17
- #if DEBUG
17
+ #import " React+Compatibility.h "
18
18
19
- void swizzleSelector (Class class, SEL originalSelector, SEL swizzledSelector)
20
- {
21
- Method originalMethod = class_getInstanceMethod (class, originalSelector);
22
- Method swizzledMethod = class_getInstanceMethod (class, swizzledSelector);
23
-
24
- BOOL didAddMethod = class_addMethod (class,
25
- originalSelector,
26
- method_getImplementation (swizzledMethod),
27
- method_getTypeEncoding (swizzledMethod));
28
- if (didAddMethod) {
29
- class_replaceMethod (class,
30
- swizzledSelector,
31
- method_getImplementation (originalMethod),
32
- method_getTypeEncoding (originalMethod));
33
- } else {
34
- method_exchangeImplementations (originalMethod, swizzledMethod);
35
- }
36
- }
19
+ #if DEBUG
37
20
38
21
// MARK: - RCTRedBoxWindow
39
22
@@ -56,11 +39,11 @@ + (void)load
56
39
static dispatch_once_t onceToken;
57
40
dispatch_once (&onceToken, ^{
58
41
Class class = [self class ];
59
- swizzleSelector (class,
60
- @selector (showErrorMessage:withStack:isUpdate: ),
61
- @selector (rta_showErrorMessage:withStack:isUpdate: ));
62
- swizzleSelector (class, @selector (dismiss ), @selector (rta_dismiss ));
63
- swizzleSelector (class, @selector (makeKeyAndVisible ), @selector (rta_makeKeyAndVisible ));
42
+ RTASwizzleSelector (class,
43
+ @selector (showErrorMessage:withStack:isUpdate: ),
44
+ @selector (rta_showErrorMessage:withStack:isUpdate: ));
45
+ RTASwizzleSelector (class, @selector (dismiss ), @selector (rta_dismiss ));
46
+ RTASwizzleSelector (class, @selector (makeKeyAndVisible ), @selector (rta_makeKeyAndVisible ));
64
47
});
65
48
}
66
49
@@ -103,9 +86,9 @@ + (void)initialize
103
86
}
104
87
105
88
if (@available (iOS 13.0 , *)) {
106
- swizzleSelector ([self class ],
107
- @selector (showMessage:color:backgroundColor: ),
108
- @selector (rta_showMessage:color:backgroundColor: ));
89
+ RTASwizzleSelector ([self class ],
90
+ @selector (showMessage:color:backgroundColor: ),
91
+ @selector (rta_showMessage:color:backgroundColor: ));
109
92
}
110
93
}
111
94
0 commit comments