Skip to content

Commit

Permalink
Add JSC for Bridgless (#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

Reviewed By: philIip

Differential Revision: D47025704

fbshipit-source-id: 5779d3ffd9ed037e6f6dee6c64cc65835f370a5b
  • Loading branch information
Lulu Wu authored and facebook-github-bot committed Jul 24, 2023
1 parent 42d6745 commit 3965158
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 196 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,13 +90,13 @@ Pod::Spec.new do |s|

if is_new_arch_enabled
s.dependency "React-BridgelessCore"
if ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == "1"
s.dependency "React-BridgelessApple"
if use_hermes
s.dependency "React-BridgelessHermes"
end
s.dependency "React-BridgelessApple"
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
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 3965158

Please sign in to comment.