Skip to content

Commit

Permalink
Enable Bridgless for JSC and frameworks (facebook#38107)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#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: 3ae09a7ef83f2e76c76467d444088b171898883b
  • Loading branch information
Lulu Wu authored and facebook-github-bot committed Jul 11, 2023
1 parent 0f378d7 commit 2e91c56
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 195 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 @@ -92,9 +94,12 @@ Pod::Spec.new do |s|
s.dependency "React-BridgelessHermes"
end
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
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ Pod::Spec.new do |s|
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.exclude_files = "platform/ios/Hermes/*.{mm,h}"
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 @@ -52,5 +52,6 @@ Pod::Spec.new do |s|
s.dependency "hermes-engine"
else
s.dependency "React-jsc"
s.exclude_files = "hermes/*.{cpp,h}"
end
end
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: 3 additions & 3 deletions packages/react-native/scripts/cocoapods/bridgeless.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +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"
if ENV["USE_HERMES"] == nil || ENV["USE_HERMES"] == "1"
pod 'React-BridgelessApple', :path => "#{react_native_path}/ReactCommon/react/bridgeless"
if use_hermes
pod 'React-BridgelessHermes', :path => "#{react_native_path}/ReactCommon/react/bridgeless"
end
pod 'React-BridgelessApple', :path => "#{react_native_path}/ReactCommon/react/bridgeless"
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 2e91c56

Please sign in to comment.