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 authored and Gabriel Donadel committed May 16, 2023
1 parent 39dfe6a commit 4398423
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 17 deletions.
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.

5 changes: 3 additions & 2 deletions apps/fabric-tester/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
"expo-av": "~13.3.0",
"expo-blur": "~12.3.0",
"expo-camera": "~13.3.0",
"expo-dev-client": "^2.2.1",
"expo-image": "^1.0.0-alpha.4",
"expo-linear-gradient": "~12.2.0",
"expo-splash-screen": "~0.19.0",
"expo-status-bar": "~1.5.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.71.7",
"react-native-web": "~0.18.10",
"expo-status-bar": "~1.5.0"
"react-native-web": "~0.18.10"
},
"devDependencies": {
"@babel/core": "^7.20.0"
Expand Down
8 changes: 5 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 @@ -61,6 +61,8 @@ Pod::Spec.new do |s|
s.dependency "expo-dev-menu"
s.dependency "ExpoModulesCore"

install_modules_dependencies(s)

s.subspec 'Unsafe' do |unsafe|
unsafe.source_files = 'ios/Unsafe/**/*.{h,m,mm,swift,cpp}'
unsafe.compiler_flags = '-x objective-c++ -std=c++1z -fno-objc-arc' # Disable Automatic Reference Counting
Expand All @@ -71,7 +73,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 @@ -16,6 +16,8 @@
#import "EXDevLauncherUpdatesHelper.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 @@ -265,12 +267,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
62 changes: 61 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9116,6 +9116,40 @@ expo-asset-utils@~3.0.0:
resolved "https://registry.yarnpkg.com/expo-asset-utils/-/expo-asset-utils-3.0.0.tgz#2c7ddf71ba9efacf7b46c159c1c650114a2f14dc"
integrity sha512-CgIbNvTqKqQi1lrlptmwoaCMu4ZVOZf8tghmytlor23CjIOuorw6cfuOqiqWkJLz23arTt91maYEU9XLMPB23A==

expo-dev-launcher@2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/expo-dev-launcher/-/expo-dev-launcher-2.2.1.tgz#db9eec550487400cdac9c2aeedd3b6791fd49469"
integrity sha512-TP9SOrNIKF5Whju7uhtBsJeOvf9idUSg7snhHNVRpm2mA5kReckeD3PFv4HsvBHdnrfoslpeq4spOdS6UUx3XA==
dependencies:
expo-dev-menu "2.2.0"
resolve-from "^5.0.0"
semver "^7.3.5"

expo-dev-menu-interface@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/expo-dev-menu-interface/-/expo-dev-menu-interface-1.1.1.tgz#8a0d979f62d9a192696f66a77f75d8fab79e604b"
integrity sha512-doT+7WrSBnxCcTGZw9QIEZoL+43U4RywbG8XZwbhkcsFWGsh9scp0y/bv3ieFHxRtIdImxbxOoYh7fy1O6g28w==

expo-dev-menu@2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/expo-dev-menu/-/expo-dev-menu-2.2.0.tgz#849ec3601f1dc228ad2858e4a25614a72932a61c"
integrity sha512-ImRUD7IVyLme7t3S+pNsOOgCBorkriVNo+ryEmkAjzRTKlpiklhoc1GEdQUU3qvO6e66gUguMbs4wnaP6o4NEw==
dependencies:
expo-dev-menu-interface "1.1.1"
semver "^7.3.5"

expo-json-utils@~0.5.0:
version "0.5.1"
resolved "https://registry.yarnpkg.com/expo-json-utils/-/expo-json-utils-0.5.1.tgz#fcb01050b8aa66592eea2024a48979f2d090c6f9"
integrity sha512-Y5boshyf40vPjwxNnOIfacZPNkOymecZRQ1k+TSXlq6gnw5XRsnM5hnP0VLVYhdv8x+9CX6E1fDsDUNvsK38Dg==

expo-manifests@~0.5.0:
version "0.5.2"
resolved "https://registry.yarnpkg.com/expo-manifests/-/expo-manifests-0.5.2.tgz#60f91ad196cd5a37248c28c6f307df806c5a27ad"
integrity sha512-WnsTlE2le3pV/B/AJPKTOSjb2K9AT1mPDCfQxTQ/KMCwF95saoXYt2OPF3hxZNaMAV6VIAhXgd5Y6wpcH9ruPQ==
dependencies:
expo-json-utils "~0.5.0"

expo-progress@^0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/expo-progress/-/expo-progress-0.0.2.tgz#0d42470f8f1f019d3ae0f1da377c9bca891f3dd8"
Expand Down Expand Up @@ -10930,6 +10964,11 @@ inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, i
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==

inherits@2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1"
integrity sha512-8nWq2nLTAwd02jTqJExUYFSD/fKq6VH9Y/oG2accc/kdI0V98Bag8d5a4gi3XHz73rDWa2PvTtvcWYquKqSENA==

inherits@2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
Expand Down Expand Up @@ -18867,7 +18906,28 @@ util.promisify@~1.0.0:
has-symbols "^1.0.1"
object.getownpropertydescriptors "^2.1.0"

util@0.10.3, util@^0.10.3, util@^0.11.0, util@^0.12.0, util@~0.12.4:
util@0.10.3:
version "0.10.3"
resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9"
integrity sha512-5KiHfsmkqacuKjkRkdV7SsfDJ2EGiPsK92s2MhNSY0craxjTdKTtqKsJaCWp4LW33ZZ0OPUv1WO/TFvNQRiQxQ==
dependencies:
inherits "2.0.1"

util@^0.10.3:
version "0.10.4"
resolved "https://registry.yarnpkg.com/util/-/util-0.10.4.tgz#3aa0125bfe668a4672de58857d3ace27ecb76901"
integrity sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==
dependencies:
inherits "2.0.3"

util@^0.11.0:
version "0.11.1"
resolved "https://registry.yarnpkg.com/util/-/util-0.11.1.tgz#3236733720ec64bb27f6e26f421aaa2e1b588d61"
integrity sha512-HShAsny+zS2TZfaXxD9tYj4HQGlBezXZMZuM/S5PKLLoZkShZiGk9o5CzukI1LVHZvjdvZ2Sj1aW/Ndn2NB/HQ==
dependencies:
inherits "2.0.3"

util@^0.12.0:
version "0.12.5"
resolved "https://registry.yarnpkg.com/util/-/util-0.12.5.tgz#5f17a6059b73db61a875668781a1c2b136bd6fbc"
integrity sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==
Expand Down

0 comments on commit 4398423

Please sign in to comment.