Skip to content

Commit

Permalink
Prevent DevLauncherController from removing fabric root view
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieldonadel committed May 26, 2023
1 parent c4409fb commit 60f711f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
13 changes: 10 additions & 3 deletions packages/expo-dev-launcher/expo-dev-launcher.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ Pod::Spec.new do |s|
]
}

s.xcconfig = {
'GCC_PREPROCESSOR_DEFINITIONS' => "EX_DEV_LAUNCHER_VERSION=#{s.version}"
}
new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'

other_c_flags = '$(inherited)'
dev_launcher_url = ENV['EX_DEV_LAUNCHER_URL'] || ""
Expand All @@ -43,6 +41,15 @@ Pod::Spec.new do |s|
other_swift_flags += ' -DEX_DEV_CLIENT_NETWORK_INSPECTOR'
end

if new_arch_enabled
other_c_flags += ' -DRN_FABRIC_ENABLED -DRCT_NEW_ARCH_ENABLED'
end

s.xcconfig = {
'GCC_PREPROCESSOR_DEFINITIONS' => "EX_DEV_LAUNCHER_VERSION=#{s.version}",
'OTHER_CFLAGS' => other_c_flags,
}

# Swift/Objective-C compatibility
s.pod_target_xcconfig = {
'DEFINES_MODULE' => 'YES',
Expand Down
12 changes: 11 additions & 1 deletion packages/expo-dev-launcher/ios/EXDevLauncherController.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#import <EXDevLauncher-Swift.h>
#endif

#ifdef RCT_NEW_ARCH_ENABLED
#import <React/RCTSurfaceView.h>
#endif

@import EXManifests;
@import EXDevMenu;

Expand Down Expand Up @@ -563,12 +567,18 @@ - (void)onAppContentDidAppear
[[NSNotificationCenter defaultCenter] removeObserver:self name:RCTContentDidAppearNotification object:nil];

dispatch_async(dispatch_get_main_queue(), ^{
#ifdef RCT_NEW_ARCH_ENABLED
#define EXPECTED_ROOT_VIEW RCTSurfaceView
#else
#define EXPECTED_ROOT_VIEW RCTRootView
#endif
NSArray<UIView *> *views = [[[self->_window rootViewController] view] subviews];
for (UIView *view in views) {
if (![view isKindOfClass:[RCTRootContentView class]]) {
if (![view isKindOfClass:[EXPECTED_ROOT_VIEW class]]) {
[view removeFromSuperview];
}
}
#undef EXPECTED_ROOT_VIEW
});
}

Expand Down

0 comments on commit 60f711f

Please sign in to comment.