-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[dev-launcher][dev-menu][ios] Add support for Fabric #22184
Changes from all commits
e1dc6be
9574d4c
951446d
e8533bd
3902f05
1dee398
1f4559c
c55e066
fcb57e4
34ba5b3
a2d9519
8eaf425
058bbcb
2fa425a
19ca50c
fc47c7d
609d4ea
51dba0c
8b05716
b503917
d618b14
6df071f
44258ef
50b24a2
b660581
1c82d92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#import <EXDevMenu/DevClientAppDelegate.h> | ||
#import <React/RCTRootView.h> | ||
|
||
@interface EXDevLauncherBridgeDelegate : DevClientAppDelegate | ||
|
||
- (RCTRootView *)createRootViewWithModuleName:(NSString *)moduleName | ||
launchOptions:(NSDictionary *_Nullable)launchOptions | ||
application:(UIApplication *)application; | ||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#import "EXDevLauncherBridgeDelegate.h" | ||
#import "EXDevLauncherController.h" | ||
|
||
#import <React/RCTBundleURLProvider.h> | ||
#if __has_include(<React_RCTAppDelegate/RCTAppSetupUtils.h>) | ||
// for importing the header from framework, the dash will be transformed to underscore | ||
#import <React_RCTAppDelegate/RCTAppSetupUtils.h> | ||
#else | ||
#import <React-RCTAppDelegate/RCTAppSetupUtils.h> | ||
#endif | ||
|
||
#ifdef RCT_NEW_ARCH_ENABLED | ||
|
||
static NSString *const kRNConcurrentRoot = @"concurrentRoot"; | ||
|
||
#endif | ||
|
||
@implementation EXDevLauncherBridgeDelegate | ||
|
||
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { | ||
return [[EXDevLauncherController sharedInstance] sourceURLForBridge:bridge]; | ||
} | ||
|
||
- (RCTRootView *)createRootViewWithModuleName:(NSString *)moduleName launchOptions:(NSDictionary * _Nullable)launchOptions application:(UIApplication *)application{ | ||
BOOL enableTM = NO; | ||
#if RCT_NEW_ARCH_ENABLED | ||
enableTM = YES; | ||
#endif | ||
|
||
RCTAppSetupPrepareApp(application, enableTM); | ||
|
||
self.bridge = [super createBridgeAndSetAdapterWithLaunchOptions:launchOptions]; | ||
|
||
NSMutableDictionary *initProps = [NSMutableDictionary new]; | ||
#ifdef RCT_NEW_ARCH_ENABLED | ||
initProps[kRNConcurrentRoot] = @YES; | ||
#endif | ||
|
||
|
||
return [super createRootViewWithBridge:self.bridge moduleName:moduleName initProps:initProps]; | ||
} | ||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2015-present 650 Industries. All rights reserved. | ||
#import <EXDevMenu/DevClientAppDelegate.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface EXRCTAppDelegateInterceptor : DevClientAppDelegate | ||
|
||
@property(nonatomic, weak) id<RCTBridgeDelegate> bridgeDelegate; | ||
@property(nonatomic, weak) id<RCTBridgeDelegate> interceptor; | ||
|
||
- (instancetype)initWithBridgeDelegate:(id<RCTBridgeDelegate>)bridgeDelegate interceptor:(id<RCTBridgeDelegate>)interceptor; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2018-present 650 Industries. All rights reserved. | ||
|
||
#import "EXRCTAppDelegateInterceptor.h" | ||
|
||
@implementation EXRCTAppDelegateInterceptor | ||
|
||
- (instancetype)initWithBridgeDelegate:(id<RCTBridgeDelegate>)bridgeDelegate interceptor:(id<RCTBridgeDelegate>)interceptor | ||
{ | ||
if (self = [super init]) { | ||
self.bridgeDelegate = bridgeDelegate; | ||
self.interceptor = interceptor; | ||
} | ||
return self; | ||
} | ||
|
||
- (BOOL)conformsToProtocol:(Protocol *)protocol | ||
{ | ||
return [self.bridgeDelegate conformsToProtocol:protocol]; | ||
} | ||
|
||
- (id)forwardingTargetForSelector:(SEL)selector | ||
{ | ||
if ([self isInterceptedSelector:selector]) { | ||
return self; | ||
} | ||
return self.bridgeDelegate; | ||
} | ||
|
||
- (BOOL)respondsToSelector:(SEL)selector | ||
{ | ||
if ([self isInterceptedSelector:selector]) { | ||
return YES; | ||
} | ||
return [self.bridgeDelegate respondsToSelector:selector]; | ||
} | ||
|
||
- (BOOL)isInterceptedSelector:(SEL)selector | ||
{ | ||
if ([self.interceptor respondsToSelector:selector]) { | ||
return YES; | ||
} | ||
return NO; | ||
} | ||
|
||
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { | ||
return [self.interceptor sourceURLForBridge:bridge]; | ||
} | ||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#import <EXDevMenu/DevClientAppDelegate.h> | ||
|
||
@interface ExpoDevLauncherBridgeDelegateHandler : DevClientAppDelegate | ||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#import "ExpoDevLauncherBridgeDelegateHandler.h" | ||
#import "EXDevLauncherController.h" | ||
|
||
|
||
@implementation ExpoDevLauncherBridgeDelegateHandler | ||
|
||
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { | ||
return [[EXDevLauncherController sharedInstance] sourceUrl]; | ||
} | ||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,8 +88,7 @@ export function useDevSettings() { | |
}, []); | ||
|
||
const openRNDevMenu = React.useCallback(async () => { | ||
await DevMenu.openDevMenuFromReactNative(); | ||
DevMenu.closeMenu(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does the closeMenu not necessary anymore? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not necessary anymore, we have to close this from the native side to ensure we first remove the expo-dev-menu overlay and then show the DevMenu from React Native otherwise both menus get closed. E.g. Screen.Recording.2023-06-19.at.11.14.07.movThat's the reason for the changes on packages/expo-dev-menu/ios/Modules/DevMenuInternalModule.swift |
||
DevMenu.openDevMenuFromReactNative(); | ||
}, []); | ||
|
||
const openJSInspector = React.useCallback(async () => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2015-present 650 Industries. All rights reserved. | ||
|
||
#import <React/RCTBridgeDelegate.h> | ||
#if __has_include(<React-RCTAppDelegate/RCTAppDelegate.h>) | ||
#import <React-RCTAppDelegate/RCTAppDelegate.h> | ||
#elif __has_include(<React_RCTAppDelegate/RCTAppDelegate.h>) | ||
// for importing the header from framework, the dash will be transformed to underscore | ||
#import <React_RCTAppDelegate/RCTAppDelegate.h> | ||
#endif | ||
|
||
@interface DevClientAppDelegate : RCTAppDelegate | ||
|
||
- (RCTBridge *)createBridgeAndSetAdapterWithLaunchOptions:(NSDictionary *_Nullable)launchOptions; | ||
|
||
@end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the difference of this and the
packages/expo-modules-core/ios/ReactDelegates/EXRCTBridgeDelegateInterceptor.h
? could we just keep one?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only difference is that this inherits from
DevClientAppDelegate
, that way we can callcreateBridgeAndSetAdapterWithLaunchOptions
insideExpoDevLauncherReactDelegateHandler