Skip to content

Commit

Permalink
Enable Bridgless for JSC and frameworks (#38107)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #38107

This change makes bridgeless build with JSC and with all the frameworks settings.

## Changelog:
[iOS][Added] Support bridgeless with JSC and frameworks

Differential Revision: D47025704

fbshipit-source-id: 8490b44e827f78b4a02268c97b78501e653d74ad
  • Loading branch information
Lulu Wu authored and facebook-github-bot committed Jun 28, 2023
1 parent 6c51ba4 commit 30f4766
Show file tree
Hide file tree
Showing 12 changed files with 148 additions and 184 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ Pod::Spec.new do |s|
}
s.user_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/Headers/Private/React-Core\""}

use_hermes = ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == "1"

s.dependency "React-Core"
s.dependency "RCT-Folly"
s.dependency "RCTRequired"
Expand All @@ -88,11 +90,13 @@ Pod::Spec.new do |s|

if is_new_arch_enabled
s.dependency "React-BridgelessCore"
s.dependency "React-BridgelessHermes"
s.dependency "React-BridgelessApple"
if use_hermes
s.dependency "React-BridgelessHermes"
end
end

if ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == "1"
if use_hermes
s.dependency "React-hermes"
else
s.dependency "React-jsc"
Expand Down
6 changes: 5 additions & 1 deletion packages/react-native/React-Core.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ Pod::Spec.new do |s|
exclude_files = exclude_files.append("React/CxxBridge/JSCExecutorFactory.{h,mm}")
end
ss.exclude_files = exclude_files
ss.private_header_files = "React/Cxx*/*.h"
ss.private_header_files = [
"React/CxxLogUtils/*.h",
"React/CxxUtils/*.h",
"React/CxxModule/*.h"
]
end

s.subspec "DevSupport" do |ss|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ Pod::Spec.new do |s|
s.dependency "React-NativeModulesApple"
s.dependency "React-RCTFabric"
s.dependency "React-BridgelessCore"
s.dependency "React-BridgelessHermes"
s.dependency "React-Mapbuffer"
s.dependency "React-jserrorhandler"

if ENV["USE_HERMES"] == nil || ENV["USE_HERMES"] == "1"
s.dependency "hermes-engine"
s.dependency "React-BridgelessHermes"
s.exclude_files = "platform/ios/JSC/*.{mm,h}"
else
s.dependency "React-jsi"
s.dependency "React-jsc"
s.exclude_files = "platform/ios/hermes/*.{mm,h}"
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Pod::Spec.new do |s|
if ENV["USE_HERMES"] == nil || ENV["USE_HERMES"] == "1"
s.dependency "hermes-engine"
else
s.exclude_files = "hermes/*.{cpp,h}"
s.dependency "React-jsi"
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#import <React/RCTModuleData.h>
#import <React/RCTPerformanceLogger.h>
#import <React/RCTSurfacePresenter.h>
#import <ReactCommon/RCTLegacyUIManagerConstantsProvider.h>
#import <ReactCommon/RCTTurboModuleManager.h>
#import <ReactCommon/RuntimeExecutor.h>
#import <cxxreact/ReactMarker.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#import "RCTJSThreadManager.h"

// #import <PikaOptimizationsMacros/PikaOptimizationsMacros.h>
#import <React/RCTAssert.h>
#import <React/RCTCxxUtils.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#import <jsi/jsi.h>
#import <react/bridgeless/JSEngineInstance.h>

namespace facebook {
namespace react {

class RCTJscInstance : public JSEngineInstance {
public:
RCTJscInstance();

std::unique_ptr<jsi::Runtime> createJSRuntime() noexcept override;

~RCTJscInstance(){};
};
} // namespace react
} // namespace facebook
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#import "RCTJscInstance.h"
#include <jsc/JSCRuntime.h>

namespace facebook {
namespace react {

RCTJscInstance::RCTJscInstance() {}

std::unique_ptr<jsi::Runtime> RCTJscInstance::createJSRuntime() noexcept
{
return jsc::makeJSCRuntime();
}

} // namespace react
} // namespace facebook
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def check_installed_pods(prefix)
check_pod("React-FabricImage", :path => "#{prefix}/ReactCommon")
check_pod("React-graphics", :path => "#{prefix}/ReactCommon/react/renderer/graphics")
check_pod("React-RCTFabric", :path => "#{prefix}/React", :modular_headers => true)
check_pod("RCT-Folly/Fabric", :podspec => "#{prefix}/third-party-podspecs/RCT-Folly.podspec")
check_pod("RCT-Folly/Fabric", :podspec => "#{prefix}/third-party-podspecs/RCT-Folly.podspec", :modular_headers => true)
check_pod("React-ImageManager", :path => "#{prefix}/ReactCommon/react/renderer/imagemanager/platform/ios")
end

Expand Down
6 changes: 4 additions & 2 deletions packages/react-native/scripts/cocoapods/bridgeless.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
# Set up Bridgeless dependencies
#
# @parameter react_native_path: relative path to react-native
def setup_bridgeless!(react_native_path: "../node_modules/react-native")
def setup_bridgeless!(react_native_path: "../node_modules/react-native", use_hermes: true)
pod "React-jsitracing", :path => "#{react_native_path}/ReactCommon/hermes/executor/"
pod "React-runtimescheduler", :path => "#{react_native_path}/ReactCommon/react/renderer/runtimescheduler"
pod 'React-BridgelessCore', :path => "#{react_native_path}/ReactCommon/react/bridgeless"
pod 'React-BridgelessHermes', :path => "#{react_native_path}/ReactCommon/react/bridgeless"
pod 'React-BridgelessApple', :path => "#{react_native_path}/ReactCommon/react/bridgeless"
if use_hermes
pod 'React-BridgelessHermes', :path => "#{react_native_path}/ReactCommon/react/bridgeless"
end
end
2 changes: 1 addition & 1 deletion packages/react-native/scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def use_react_native! (
end

if new_arch_enabled
setup_bridgeless!(:react_native_path => prefix)
setup_bridgeless!(:react_native_path => prefix, :use_hermes => hermes_enabled)
end

# Flipper now build in Release mode but it is not linked to the Release binary (as specified by the Configuration option)
Expand Down
Loading

0 comments on commit 30f4766

Please sign in to comment.