Skip to content

Commit

Permalink
CocoaPods: Split React-jsc out of React-jsi (#35031)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #35031

The React-jsi Pod was serving two purposes: building JSI, and configuring JavaScriptCore as the JS engine.

By splitting the React-jsi Pod into React-jsi and React-jsi, we can start working towards de-coupling the JSI dependency from any particular JS engine.

Pods that depended on React-jsi, now depend on React-jsi and React-jsc.
One exception to this is React-hermes, which is only installed when Hermes is enabled, and thus does not require JavaScriptCore.
Upcoming commits should take care of removing the React-jsc dependency when Hermes is enabled, but it is out of scope for this commit.

Changelog:
[iOS][Changed] - The JSC Runtime is now provided by the React-jsc Pod instead of React-jsi. Libraries that declared a dependency on React-jsi in order to specifically create a JSC runtime (`makeJSCRuntime()`) will need to add React-jsc to their dependencies.

Reviewed By: dmytrorykun

Differential Revision: D40442603

fbshipit-source-id: b9b21146b9deb401f80cfef76a87c9867754a953
  • Loading branch information
hramos authored and facebook-github-bot committed Oct 20, 2022
1 parent 7383c00 commit 6b129d8
Show file tree
Hide file tree
Showing 26 changed files with 86 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Libraries/Blob/React-RCTBlob.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ Pod::Spec.new do |s|
s.dependency "React-Codegen", version
s.dependency "ReactCommon/turbomodule/core", version
s.dependency "React-jsi", version
s.dependency "React-jsc", version
s.dependency "React-Core/RCTBlobHeaders", version
s.dependency "React-Core/RCTWebSocket", version
s.dependency "React-RCTNetwork", version
s.dependency "React-jsi", version
end
1 change: 1 addition & 0 deletions Libraries/Image/React-RCTImage.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Pod::Spec.new do |s|
s.dependency "RCTTypeSafety", version
s.dependency "ReactCommon/turbomodule/core", version
s.dependency "React-jsi", version
s.dependency "React-jsc", version
s.dependency "React-Core/RCTImageHeaders", version
s.dependency "React-RCTNetwork", version
end
1 change: 1 addition & 0 deletions Libraries/LinkingIOS/React-RCTLinking.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ Pod::Spec.new do |s|
s.dependency "React-Core/RCTLinkingHeaders", version
s.dependency "ReactCommon/turbomodule/core", version
s.dependency "React-jsi", version
s.dependency "React-jsc", version
end
1 change: 1 addition & 0 deletions Libraries/NativeAnimation/React-RCTAnimation.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ Pod::Spec.new do |s|
s.dependency "RCTTypeSafety", version
s.dependency "ReactCommon/turbomodule/core", version
s.dependency "React-jsi", version
s.dependency "React-jsc", version
s.dependency "React-Core/RCTAnimationHeaders", version
end
1 change: 1 addition & 0 deletions Libraries/Network/React-RCTNetwork.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ Pod::Spec.new do |s|
s.dependency "RCTTypeSafety", version
s.dependency "ReactCommon/turbomodule/core", version
s.dependency "React-jsi", version
s.dependency "React-jsc", version
s.dependency "React-Core/RCTNetworkHeaders", version
end
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ Pod::Spec.new do |s|
s.dependency "React-Core/RCTPushNotificationHeaders", version
s.dependency "ReactCommon/turbomodule/core", version
s.dependency "React-jsi", version
s.dependency "React-jsc", version
end
1 change: 1 addition & 0 deletions Libraries/Settings/React-RCTSettings.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ Pod::Spec.new do |s|
s.dependency "RCTTypeSafety", version
s.dependency "ReactCommon/turbomodule/core", version
s.dependency "React-jsi", version
s.dependency "React-jsc", version
s.dependency "React-Core/RCTSettingsHeaders", version
end
1 change: 1 addition & 0 deletions Libraries/Vibration/React-RCTVibration.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ Pod::Spec.new do |s|
s.dependency "React-Codegen", version
s.dependency "ReactCommon/turbomodule/core", version
s.dependency "React-jsi", version
s.dependency "React-jsc", version
s.dependency "React-Core/RCTVibrationHeaders", version
end
1 change: 1 addition & 0 deletions React-Core.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Pod::Spec.new do |s|
s.dependency "React-cxxreact", version
s.dependency "React-perflogger", version
s.dependency "React-jsi", version
s.dependency "React-jsc", version
s.dependency "React-jsiexecutor", version
s.dependency "Yoga"
s.dependency "glog"
Expand Down
1 change: 1 addition & 0 deletions React/CoreModules/React-CoreModules.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ Pod::Spec.new do |s|
s.dependency "React-RCTImage", version
s.dependency "ReactCommon/turbomodule/core", version
s.dependency "React-jsi", version
s.dependency "React-jsc", version
end
1 change: 1 addition & 0 deletions React/FBReactNativeSpec/FBReactNativeSpec.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Pod::Spec.new do |s|
s.dependency "RCTTypeSafety", version
s.dependency "React-Core", version
s.dependency "React-jsi", version
s.dependency "React-jsc", version
s.dependency "ReactCommon/turbomodule/core", version

use_react_native_codegen!(s, {
Expand Down
1 change: 1 addition & 0 deletions ReactCommon/React-Fabric.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Pod::Spec.new do |s|
s.dependency "RCTTypeSafety", version
s.dependency "ReactCommon/turbomodule/core", version
s.dependency "React-jsi", version
s.dependency "React-jsc", version

s.subspec "animations" do |ss|
ss.dependency folly_dep_name, folly_version
Expand Down
1 change: 1 addition & 0 deletions ReactCommon/React-bridging.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ Pod::Spec.new do |s|

s.dependency "RCT-Folly", folly_version
s.dependency "React-jsi", version
s.dependency "React-jsc", version
end
1 change: 1 addition & 0 deletions ReactCommon/ReactCommon.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Pod::Spec.new do |s|
ss.dependency "React-Core", version
ss.dependency "React-cxxreact", version
ss.dependency "React-jsi", version
ss.dependency "React-jsc", version
ss.dependency "RCT-Folly", folly_version
s.dependency "React-logger", version
ss.dependency "DoubleConversion"
Expand Down
1 change: 1 addition & 0 deletions ReactCommon/cxxreact/React-cxxreact.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ Pod::Spec.new do |s|
s.dependency "React-runtimeexecutor", version
s.dependency "React-perflogger", version
s.dependency "React-jsi", version
s.dependency "React-jsc", version
s.dependency "React-logger", version
end
2 changes: 1 addition & 1 deletion ReactCommon/hermes/React-hermes.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ boost_compiler_flags = '-Wno-documentation'
Pod::Spec.new do |s|
s.name = "React-hermes"
s.version = version
s.summary = "-" # TODO
s.summary = "Hermes engine for React Native"
s.homepage = "https://reactnative.dev/"
s.license = package['license']
s.author = "Facebook, Inc. and its affiliates"
Expand Down
42 changes: 42 additions & 0 deletions ReactCommon/jsi/React-jsc.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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.

require "json"

package = JSON.parse(File.read(File.join(__dir__, "..", "..", "package.json")))
version = package['version']

source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in.
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Pod::Spec.new do |s|
s.name = "React-jsc"
s.version = version
s.summary = "JavaScriptCore engine for React Native"
s.homepage = "https://reactnative.dev/"
s.license = package["license"]
s.author = "Facebook, Inc. and its affiliates"
s.platforms = { :ios => "12.4" }
s.source = source
s.source_files = "JSCRuntime.{cpp,h}"
s.exclude_files = "**/test/*"
s.framework = "JavaScriptCore"
s.dependency "React-jsi", version

s.default_subspec = "Default"

s.subspec "Default" do
# no-op
end

s.subspec "Fabric" do |ss|
ss.pod_target_xcconfig = { "OTHER_CFLAGS" => "$(inherited) -DRN_FABRIC_ENABLED" }
end
end
28 changes: 4 additions & 24 deletions ReactCommon/jsi/React-jsi.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,21 @@ else
source[:tag] = "v#{version}"
end

folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
folly_version = '2021.07.22.00'
boost_compiler_flags = '-Wno-documentation'

Pod::Spec.new do |s|
s.name = "React-jsi"
s.version = version
s.summary = "-" # TODO
s.summary = "JavaScript Interface layer for React Native"
s.homepage = "https://reactnative.dev/"
s.license = package["license"]
s.author = "Facebook, Inc. and its affiliates"
s.platforms = { :ios => "12.4" }
s.source = source
s.source_files = "**/*.{cpp,h}"
s.source_files = "jsi/*.{cpp,h}"
s.exclude_files = [
"jsi/JSIDynamic.{h,cpp}",
"jsi/jsilib-*.{h,cpp}",
"jsi/jsilib-posix.cpp",
"jsi/jsilib-windows.cpp",
"**/test/*"
]
s.framework = "JavaScriptCore"
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\"" }
s.header_dir = "jsi"
s.default_subspec = "Default"

s.dependency "boost", "1.76.0"
s.dependency "DoubleConversion"
s.dependency "RCT-Folly", folly_version
s.dependency "glog"

s.subspec "Default" do
# no-op
end

s.subspec "Fabric" do |ss|
ss.pod_target_xcconfig = { "OTHER_CFLAGS" => "$(inherited) -DRN_FABRIC_ENABLED" }
end
end
1 change: 1 addition & 0 deletions ReactCommon/jsi/React-jsidynamic.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ Pod::Spec.new do |s|
s.dependency "RCT-Folly", folly_version
s.dependency "glog"
s.dependency "React-jsi", version
s.dependency "React-jsc", version
end
1 change: 1 addition & 0 deletions ReactCommon/runtimeexecutor/React-runtimeexecutor.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ Pod::Spec.new do |s|
s.header_dir = "ReactCommon"

s.dependency "React-jsi", version
s.dependency "React-jsc", version
end
1 change: 1 addition & 0 deletions packages/rn-tester/RCTTest/React-RCTTest.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ Pod::Spec.new do |s|
s.dependency "React-CoreModules", version
s.dependency "ReactCommon/turbomodule/core", version
s.dependency "React-jsi", version
s.dependency "React-jsc", version
end
1 change: 1 addition & 0 deletions scripts/cocoapods/__tests__/codegen_utils-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ def get_podspec_no_fabric_no_script
"RCTTypeSafety": ["99.98.97"],
"React-Core": ["99.98.97"],
"React-jsi": ["99.98.97"],
"React-jsc": ["99.98.97"],
"ReactCommon/turbomodule/core": ["99.98.97"]
}
}
Expand Down
11 changes: 9 additions & 2 deletions scripts/cocoapods/__tests__/fabric-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

require "test/unit"
require_relative "../fabric.rb"
require_relative "../utils.rb"
require_relative "./test_utils/podSpy.rb"

class FabricTest < Test::Unit::TestCase
Expand All @@ -13,6 +14,13 @@ def setup
podSpy_cleanUp()
end

def teardown
podSpy_cleanUp()
end

# ================== #
# TEST - setupFabric #
# ================== #
def test_setupFabric_installsPods
# Arrange
prefix = "../.."
Expand All @@ -30,7 +38,7 @@ def check_installed_pods(prefix)
check_pod("React-Fabric", :path => "#{prefix}/ReactCommon")
check_pod("React-rncore", :path => "#{prefix}/ReactCommon")
check_pod("React-graphics", :path => "#{prefix}/ReactCommon/react/renderer/graphics")
check_pod("React-jsi/Fabric", :path => "#{prefix}/ReactCommon/jsi")
check_pod("React-jsc/Fabric", :path => "#{prefix}/ReactCommon/jsi")
check_pod("React-RCTFabric", :path => "#{prefix}/React", :modular_headers => true)
check_pod("RCT-Folly/Fabric", :podspec => "#{prefix}/third-party-podspecs/RCT-Folly.podspec")
end
Expand All @@ -45,5 +53,4 @@ def check_pod(name, path: nil, modular_headers: nil, podspec: nil)

assert_equal(params, expected_params)
end

end
1 change: 1 addition & 0 deletions scripts/cocoapods/codegen_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def get_react_codegen_spec(package_json_file, folly_version: '2021.07.22.00', fa
"RCTTypeSafety": [version],
"React-Core": [version],
"React-jsi": [version],
"React-jsc": [version],
"ReactCommon/turbomodule/core": [version]
}
}
Expand Down
20 changes: 9 additions & 11 deletions scripts/cocoapods/fabric.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@
# LICENSE file in the root directory of this source tree.


# It sets up the faric dependencies.
# It sets up the Fabric dependencies.
#
# @parameter prefix: prefix to use to reach react-native
# @parameter new_arch_enabled: whether the new arch is enabled or not
# @parameter codegen_output_dir: the directory where the code is generated
def setup_fabric!(prefix)
pod 'React-Fabric', :path => "#{prefix}/ReactCommon"
pod 'React-rncore', :path => "#{prefix}/ReactCommon"
pod 'React-graphics', :path => "#{prefix}/ReactCommon/react/renderer/graphics"
pod 'React-jsi/Fabric', :path => "#{prefix}/ReactCommon/jsi"
pod 'React-RCTFabric', :path => "#{prefix}/React", :modular_headers => true
pod 'RCT-Folly/Fabric', :podspec => "#{prefix}/third-party-podspecs/RCT-Folly.podspec"
# @parameter react_native_path: relative path to react-native
def setup_fabric!(react_native_path)
pod 'React-Fabric', :path => "#{react_native_path}/ReactCommon"
pod 'React-rncore', :path => "#{react_native_path}/ReactCommon"
pod 'React-graphics', :path => "#{react_native_path}/ReactCommon/react/renderer/graphics"
pod 'React-jsc/Fabric', :path => "#{react_native_path}/ReactCommon/jsi"
pod 'React-RCTFabric', :path => "#{react_native_path}/React", :modular_headers => true
pod 'RCT-Folly/Fabric', :podspec => "#{react_native_path}/third-party-podspecs/RCT-Folly.podspec"
end
1 change: 1 addition & 0 deletions scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def use_react_native! (
pod 'React-bridging', :path => "#{prefix}/ReactCommon"
pod 'React-cxxreact', :path => "#{prefix}/ReactCommon/cxxreact"
pod 'React-jsi', :path => "#{prefix}/ReactCommon/jsi"
pod 'React-jsc', :path => "#{prefix}/ReactCommon/jsi"
pod 'React-jsidynamic', :path => "#{prefix}/ReactCommon/jsi"
pod 'React-jsiexecutor', :path => "#{prefix}/ReactCommon/jsiexecutor"
pod 'React-jsinspector', :path => "#{prefix}/ReactCommon/jsinspector"
Expand Down

0 comments on commit 6b129d8

Please sign in to comment.