mirror of
https://github.com/status-im/react-native.git
synced 2025-01-16 04:24:15 +00:00
clean up NSClassFromString in Libraries/
Reviewed By: adamjernst Differential Revision: D3794507 fbshipit-source-id: 5f6f8d3ccfcb8a7339532ca1c092750b85d622d2
This commit is contained in:
parent
16f76d4407
commit
8a8ac771b1
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#import <mach/mach_time.h>
|
#import <mach/mach_time.h>
|
||||||
#import <objc/message.h>
|
#import <objc/message.h>
|
||||||
|
#import <objc/runtime.h>
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
@ -434,7 +435,7 @@ BOOL RCTRunningInTestEnvironment(void)
|
|||||||
static BOOL isTestEnvironment = NO;
|
static BOOL isTestEnvironment = NO;
|
||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
dispatch_once(&onceToken, ^{
|
dispatch_once(&onceToken, ^{
|
||||||
isTestEnvironment = NSClassFromString(@"SenTestCase") || NSClassFromString(@"XCTest");
|
isTestEnvironment = objc_lookUpClass("SenTestCase") || objc_lookUpClass("XCTest");
|
||||||
});
|
});
|
||||||
return isTestEnvironment;
|
return isTestEnvironment;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
#import "RCTDevMenu.h"
|
#import "RCTDevMenu.h"
|
||||||
|
|
||||||
|
#import <objc/runtime.h>
|
||||||
|
|
||||||
#import "RCTAssert.h"
|
#import "RCTAssert.h"
|
||||||
#import "RCTBridge+Private.h"
|
#import "RCTBridge+Private.h"
|
||||||
#import "RCTDefines.h"
|
#import "RCTDefines.h"
|
||||||
@ -255,7 +257,7 @@ RCT_EXPORT_MODULE()
|
|||||||
// TODO: Move non-UI logic into separate RCTDevSettings module
|
// TODO: Move non-UI logic into separate RCTDevSettings module
|
||||||
- (void)connectPackager
|
- (void)connectPackager
|
||||||
{
|
{
|
||||||
Class webSocketManagerClass = NSClassFromString(@"RCTWebSocketManager");
|
Class webSocketManagerClass = objc_lookUpClass("RCTWebSocketManager");
|
||||||
id<RCTWebSocketProxy> webSocketManager = (id <RCTWebSocketProxy>)[webSocketManagerClass sharedInstance];
|
id<RCTWebSocketProxy> webSocketManager = (id <RCTWebSocketProxy>)[webSocketManagerClass sharedInstance];
|
||||||
NSURL *url = [self packagerURL];
|
NSURL *url = [self packagerURL];
|
||||||
if (url) {
|
if (url) {
|
||||||
@ -281,7 +283,7 @@ RCT_EXPORT_MODULE()
|
|||||||
if ([target isEqualToString:@"bridge"]) {
|
if ([target isEqualToString:@"bridge"]) {
|
||||||
if ([action isEqualToString:@"reload"]) {
|
if ([action isEqualToString:@"reload"]) {
|
||||||
if ([options[@"debug"] boolValue]) {
|
if ([options[@"debug"] boolValue]) {
|
||||||
_bridge.executorClass = NSClassFromString(@"RCTWebSocketExecutor");
|
_bridge.executorClass = objc_lookUpClass("RCTWebSocketExecutor");
|
||||||
}
|
}
|
||||||
[_bridge reload];
|
[_bridge reload];
|
||||||
}
|
}
|
||||||
@ -453,7 +455,7 @@ RCT_EXPORT_MODULE()
|
|||||||
[weakSelf reload];
|
[weakSelf reload];
|
||||||
}]];
|
}]];
|
||||||
|
|
||||||
Class jsDebuggingExecutorClass = NSClassFromString(@"RCTWebSocketExecutor");
|
Class jsDebuggingExecutorClass = objc_lookUpClass("RCTWebSocketExecutor");
|
||||||
if (!jsDebuggingExecutorClass) {
|
if (!jsDebuggingExecutorClass) {
|
||||||
[items addObject:[RCTDevMenuItem buttonItemWithTitle:[NSString stringWithFormat:@"%@ Debugger Unavailable", _webSocketExecutorName] handler:^{
|
[items addObject:[RCTDevMenuItem buttonItemWithTitle:[NSString stringWithFormat:@"%@ Debugger Unavailable", _webSocketExecutorName] handler:^{
|
||||||
UIAlertView *alert = RCTAlertView(
|
UIAlertView *alert = RCTAlertView(
|
||||||
@ -637,7 +639,7 @@ RCT_EXPORT_METHOD(reload)
|
|||||||
// needed to prevent overriding a custom executor with the default if a
|
// needed to prevent overriding a custom executor with the default if a
|
||||||
// custom executor has been set directly on the bridge
|
// custom executor has been set directly on the bridge
|
||||||
if (executorClass == Nil &&
|
if (executorClass == Nil &&
|
||||||
_bridge.executorClass != NSClassFromString(@"RCTWebSocketExecutor")) {
|
_bridge.executorClass != objc_lookUpClass("RCTWebSocketExecutor")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user