Skip to content

Commit

Permalink
[dev-launcher][ios] Add support for Fabric
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieldonadel committed Apr 20, 2023
1 parent 56debae commit b83ea26
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 18 deletions.
82 changes: 78 additions & 4 deletions apps/fabric-tester/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,58 @@ PODS:
- ExpoModulesCore
- EXFont (11.1.1):
- ExpoModulesCore
- EXJSONUtils (0.5.1)
- EXManifests (0.5.1):
- ExpoModulesCore
- Expo (48.0.1):
- ExpoModulesCore
- expo-dev-client (2.1.4):
- EXManifests
- expo-dev-launcher
- expo-dev-menu
- expo-dev-menu-interface
- EXUpdatesInterface
- expo-dev-launcher (2.1.4):
- EXManifests
- expo-dev-launcher/Main (= 2.1.4)
- expo-dev-menu
- expo-dev-menu-interface
- ExpoModulesCore
- EXUpdatesInterface
- React-Core
- expo-dev-launcher/Main (2.1.4):
- EXManifests
- expo-dev-launcher/Unsafe
- expo-dev-menu
- expo-dev-menu-interface
- ExpoModulesCore
- EXUpdatesInterface
- React-Core
- expo-dev-launcher/Unsafe (2.1.4):
- EXManifests
- expo-dev-menu
- expo-dev-menu-interface
- ExpoModulesCore
- EXUpdatesInterface
- React-Core
- expo-dev-menu (2.1.3):
- expo-dev-menu/Main (= 2.1.3)
- expo-dev-menu-interface (1.1.1)
- expo-dev-menu/Main (2.1.3):
- EXManifests
- expo-dev-menu-interface
- expo-dev-menu/Vendored
- ExpoModulesCore
- React-Core
- expo-dev-menu/SafeAreaView (2.1.3):
- ExpoModulesCore
- expo-dev-menu/Vendored (2.1.3):
- expo-dev-menu/SafeAreaView
- ExpoAppleAuthentication (6.0.1):
- ExpoModulesCore
- ExpoBlur (12.2.2):
- ExpoBlur (12.3.0):
- ExpoModulesCore
- ExpoImage (1.1.0):
- ExpoImage (1.2.1):
- ExpoModulesCore
- SDWebImage (~> 5.15.0)
- SDWebImageAVIFCoder (~> 0.9.4)
Expand All @@ -39,6 +84,7 @@ PODS:
- EXSplashScreen (0.18.1):
- ExpoModulesCore
- React-Core
- EXUpdatesInterface (0.9.1)
- FBLazyVector (0.71.6)
- FBReactNativeSpec (0.71.6):
- RCT-Folly (= 2021.07.22.00)
Expand Down Expand Up @@ -763,14 +809,21 @@ DEPENDENCIES:
- EXConstants (from `../../../packages/expo-constants/ios`)
- EXFileSystem (from `../../../packages/expo-file-system/ios`)
- EXFont (from `../../../packages/expo-font/ios`)
- EXJSONUtils (from `../../../packages/expo-json-utils/ios`)
- EXManifests (from `../../../packages/expo-manifests/ios`)
- Expo (from `../../../packages/expo`)
- expo-dev-client (from `../../../packages/expo-dev-client/ios`)
- expo-dev-launcher (from `../../../packages/expo-dev-launcher`)
- expo-dev-menu (from `../../../packages/expo-dev-menu`)
- expo-dev-menu-interface (from `../../../packages/expo-dev-menu-interface/ios`)
- ExpoAppleAuthentication (from `../../../packages/expo-apple-authentication/ios`)
- ExpoBlur (from `../../../packages/expo-blur/ios`)
- ExpoImage (from `../../../packages/expo-image/ios`)
- ExpoKeepAwake (from `../../../packages/expo-keep-awake/ios`)
- ExpoLinearGradient (from `../../../packages/expo-linear-gradient/ios`)
- ExpoModulesCore (from `../../../packages/expo-modules-core`)
- EXSplashScreen (from `../../../packages/expo-splash-screen/ios`)
- EXUpdatesInterface (from `../../../packages/expo-updates-interface/ios`)
- FBLazyVector (from `../../../node_modules/react-native/Libraries/FBLazyVector`)
- FBReactNativeSpec (from `../../../node_modules/react-native/React/FBReactNativeSpec`)
- glog (from `../../../node_modules/react-native/third-party-podspecs/glog.podspec`)
Expand Down Expand Up @@ -841,8 +894,20 @@ EXTERNAL SOURCES:
:path: "../../../packages/expo-file-system/ios"
EXFont:
:path: "../../../packages/expo-font/ios"
EXJSONUtils:
:path: "../../../packages/expo-json-utils/ios"
EXManifests:
:path: "../../../packages/expo-manifests/ios"
Expo:
:path: "../../../packages/expo"
expo-dev-client:
:path: "../../../packages/expo-dev-client/ios"
expo-dev-launcher:
:path: "../../../packages/expo-dev-launcher"
expo-dev-menu:
:path: "../../../packages/expo-dev-menu"
expo-dev-menu-interface:
:path: "../../../packages/expo-dev-menu-interface/ios"
ExpoAppleAuthentication:
:path: "../../../packages/expo-apple-authentication/ios"
ExpoBlur:
Expand All @@ -857,6 +922,8 @@ EXTERNAL SOURCES:
:path: "../../../packages/expo-modules-core"
EXSplashScreen:
:path: "../../../packages/expo-splash-screen/ios"
EXUpdatesInterface:
:path: "../../../packages/expo-updates-interface/ios"
FBLazyVector:
:path: "../../../node_modules/react-native/Libraries/FBLazyVector"
FBReactNativeSpec:
Expand Down Expand Up @@ -939,14 +1006,21 @@ SPEC CHECKSUMS:
EXConstants: f348da07e21b23d2b085e270d7b74f282df1a7d9
EXFileSystem: a736b6854370a36e4daee79b1f2b5bbc9df18bf4
EXFont: 6ea3800df746be7233208d80fe379b8ed74f4272
EXJSONUtils: de3ed1d52896922dab84c7c475b9165a2e786a56
EXManifests: 959d55f89999c7240f3c4bb558a4f20865ee6036
Expo: 79deb55f33fab1b232232868a74713772943238d
expo-dev-client: 71c7a10806a324e4312c1cac34d4a439670d2c3b
expo-dev-launcher: 2a7a59ebf448e41afc861715d1ed675657436be5
expo-dev-menu: 114dd1db5b95dab5a157f205896dd29351634f81
expo-dev-menu-interface: 6c82ae323c4b8724dead4763ce3ff24a2108bdb1
ExpoAppleAuthentication: 7bd5e4150d59e8df37aa80b425850ae88adf9e65
ExpoBlur: fac3c6318fdf409dd5740afd3313b2bd52a35bac
ExpoImage: 80221ee353e8e7f1afee71fdbc8099ae61f394f2
ExpoBlur: b0d995dbfc725fc5b7ee60da076131995300815d
ExpoImage: 09d394e082cdd18d946f10a522d566dfca019fb8
ExpoKeepAwake: 69f5f627670d62318410392d03e0b5db0f85759a
ExpoLinearGradient: 496147427ac1a8ee4738e016e94fc19ba2f3a00a
ExpoModulesCore: e093fd5d0fafc8d5c1d2c8c44f40811475315bf3
EXSplashScreen: cd7fb052dff5ba8311d5c2455ecbebffe1b7a8ca
EXUpdatesInterface: 353553ad3df1507f0d9e814a3dd79c7053606acd
FBLazyVector: a83ceaa8a8581003a623facdb3c44f6d4f342ac5
FBReactNativeSpec: e66130899b31cbeb133f8fe1fc7002aa710b0268
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
Expand Down
33 changes: 28 additions & 5 deletions apps/fabric-tester/ios/fabrictester.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/fabric-tester/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"expo-av": "~13.2.0",
"expo-blur": "~12.3.0",
"expo-camera": "~13.2.0",
"expo-dev-client": "~2.1.0",
"expo-image": "^1.0.0-alpha.4",
"expo-linear-gradient": "~12.1.0",
"expo-splash-screen": "~0.18.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/expo-dev-launcher/expo-dev-launcher.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Pod::Spec.new do |s|
s.swift_version = '5.2'
s.source = { :git => 'https://github.com/github_account/expo-development-client.git', :tag => "#{s.version}" }
s.static_framework = true
s.source_files = 'ios/**/*.{h,m,swift,cpp}'
s.preserve_paths = 'ios/**/*.{h,m,swift}'
s.source_files = 'ios/**/*.{h,m,mm,swift,cpp}'
s.preserve_paths = 'ios/**/*.{h,m,mm,swift}'
s.exclude_files = 'ios/Unsafe/**/*.{h,m,mm,swift,cpp}', 'ios/Tests/**/*.{h,m,swift}'
s.requires_arc = true
s.header_dir = 'EXDevLauncher'
Expand Down Expand Up @@ -71,7 +71,7 @@ Pod::Spec.new do |s|
end

s.test_spec 'Tests' do |test_spec|
test_spec.source_files = 'ios/Tests/**/*.{h,m,swift}'
test_spec.source_files = 'ios/Tests/**/*.{h,m,mm,swift}'
test_spec.dependency 'Quick'
test_spec.dependency 'Nimble'
test_spec.dependency "React-CoreModules"
Expand Down
11 changes: 11 additions & 0 deletions packages/expo-dev-launcher/ios/EXDevLauncherBridgeDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#import <React/RCTBridgeModule.h>
#import <React/RCTBridgeDelegate.h>
#import <React/RCTRootView.h>

@interface EXDevLauncherBridgeDelegate : NSObject

+ (RCTRootView *)createRootViewWithModuleName:(NSString *)moduleName
launchOptions:(NSDictionary * _Nullable)launchOptions
application:(UIApplication *)application;

@end
62 changes: 62 additions & 0 deletions packages/expo-dev-launcher/ios/EXDevLauncherBridgeDelegate.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#import <React/RCTRootView.h>

#import "EXDevLauncherController.h"
#import "EXDevLauncherRCTBridge.h"

#if RCT_NEW_ARCH_ENABLED
#import <React/CoreModulesPlugins.h>
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
#import <React/RCTSurfacePresenter.h>
#import <React/RCTSurfacePresenterBridgeAdapter.h>
#import <ReactCommon/RCTTurboModuleManager.h>
#import <react/config/ReactNativeConfig.h>


static NSString *const kRNConcurrentRoot = @"concurrentRoot";

#endif

#import "React/RCTAppSetupUtils.h"

@implementation EXDevLauncherBridgeDelegate : NSObject

+ (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);


RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:[EXDevLauncherController sharedInstance] launchOptions:launchOptions];

#if RCT_NEW_ARCH_ENABLED
facebook::react::ContextContainer::Shared _contextContainer;
_contextContainer = std::make_shared<facebook::react::ContextContainer const>();

std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
_reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>();
_contextContainer->insert("ReactNativeConfig", _reactNativeConfig);

RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
_bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge
contextContainer:_contextContainer];
bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
#endif

NSMutableDictionary *initProps = [NSMutableDictionary new];
#ifdef RCT_NEW_ARCH_ENABLED
initProps[kRNConcurrentRoot] = @YES;
#endif

BOOL enableFabric = NO;
#if RCT_NEW_ARCH_ENABLED
enableFabric = TRUE;
#endif

return RCTAppSetupDefaultRootView(bridge, moduleName, initProps, enableFabric);

}

@end
10 changes: 4 additions & 6 deletions packages/expo-dev-launcher/ios/EXDevLauncherController.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#import "EXDevLauncherAuth.h"
#import "RCTPackagerConnection+EXDevLauncherPackagerConnectionInterceptor.h"

#import "EXDevLauncherBridgeDelegate.h"

#if __has_include(<EXDevLauncher/EXDevLauncher-Swift.h>)
// For cocoapods framework, the generated swift header will be inside EXDevLauncher module
#import <EXDevLauncher/EXDevLauncher-Swift.h>
Expand Down Expand Up @@ -274,12 +276,8 @@ - (void)navigateToLauncher
}

[self _removeInitModuleObserver];

_launcherBridge = [[EXDevLauncherRCTBridge alloc] initWithDelegate:self launchOptions:_launchOptions];

RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:_launcherBridge
moduleName:@"main"
initialProperties:@{}];
UIApplication *application = [UIApplication sharedApplication];
UIView *rootView = [EXDevLauncherBridgeDelegate createRootViewWithModuleName:@"main" launchOptions:_launchOptions application:application];

[self _ensureUserInterfaceStyleIsInSyncWithTraitEnv:rootView];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#import <React/RCTRedBox.h>
#import <React/RCTLogBox.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTAppSetupUtils.h>

#pragma clang diagnostic pop

Expand Down

0 comments on commit b83ea26

Please sign in to comment.