Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always install all the pods #41588

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ use_hermes = ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == '1'

new_arch_enabled_flag = (is_new_arch_enabled ? " -DRCT_NEW_ARCH_ENABLED" : "")
is_fabric_enabled = is_new_arch_enabled || ENV["RCT_FABRIC_ENABLED"]
fabric_flag = (is_fabric_enabled ? " -DRN_FABRIC_ENABLED" : "")
hermes_flag = (use_hermes ? " -DUSE_HERMES" : "")
other_cflags = "$(inherited)" + folly_flags + new_arch_enabled_flag + fabric_flag + hermes_flag
other_cflags = "$(inherited)" + folly_flags + new_arch_enabled_flag + hermes_flag

header_search_paths = [
"$(PODS_TARGET_SRCROOT)/../../ReactCommon",
Expand Down Expand Up @@ -81,42 +80,33 @@ Pod::Spec.new do |s|
add_dependency(s, "React-NativeModulesApple")
add_dependency(s, "React-runtimescheduler")
add_dependency(s, "React-RCTFabric", :framework_name => "RCTFabric")

if is_new_arch_enabled
add_dependency(s, "React-RuntimeCore")
add_dependency(s, "React-RuntimeApple")
if use_hermes
s.dependency "React-RuntimeHermes"
end
end
add_dependency(s, "React-RuntimeCore")
add_dependency(s, "React-RuntimeApple")
add_dependency(s, "React-Fabric", :additional_framework_paths => ["react/renderer/components/view/platform/cxx"])
add_dependency(s, "React-graphics", :additional_framework_paths => ["react/renderer/graphics/platform/ios"])
add_dependency(s, "React-utils")
add_dependency(s, "React-debug")
add_dependency(s, "React-rendererdebug")

if use_hermes
s.dependency "React-hermes"
s.dependency "React-RuntimeHermes"
else
s.dependency "React-jsc"
end

if is_new_arch_enabled
add_dependency(s, "React-Fabric", :additional_framework_paths => ["react/renderer/components/view/platform/cxx"])
add_dependency(s, "React-graphics", :additional_framework_paths => ["react/renderer/graphics/platform/ios"])
add_dependency(s, "React-utils")
add_dependency(s, "React-debug")
add_dependency(s, "React-rendererdebug")

rel_path_from_pods_root_to_app = Pathname.new(ENV['APP_PATH']).relative_path_from(Pod::Config.instance.installation_root)
rel_path_from_pods_to_app = Pathname.new(ENV['APP_PATH']).relative_path_from(File.join(Pod::Config.instance.installation_root, 'Pods'))
rel_path_from_pods_root_to_app = Pathname.new(ENV['APP_PATH']).relative_path_from(Pod::Config.instance.installation_root)
rel_path_from_pods_to_app = Pathname.new(ENV['APP_PATH']).relative_path_from(File.join(Pod::Config.instance.installation_root, 'Pods'))


s.script_phases = {
:name => "Generate Legacy Components Interop",
:script => "
s.script_phases = {
:name => "Generate Legacy Components Interop",
:script => "
WITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"
source $WITH_ENVIRONMENT
${NODE_BINARY} ${REACT_NATIVE_PATH}/scripts/codegen/generate-legacy-interop-components.js -p #{rel_path_from_pods_to_app} -o ${REACT_NATIVE_PATH}/Libraries/AppDelegate
",
:execution_position => :before_compile,
:input_files => ["#{rel_path_from_pods_root_to_app}/react-native.config.js"],
:output_files => ["${REACT_NATIVE_PATH}/Libraries/AppDelegate/RCTLegacyInteropComponents.mm"],
}
end
",
:execution_position => :before_compile,
:input_files => ["#{rel_path_from_pods_root_to_app}/react-native.config.js"],
:output_files => ["${REACT_NATIVE_PATH}/Libraries/AppDelegate/RCTLegacyInteropComponents.mm"],
}
end
2 changes: 1 addition & 1 deletion packages/react-native/React/React-RCTFabric.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Pod::Spec.new do |s|
s.framework = ["JavaScriptCore", "MobileCoreServices"]
s.pod_target_xcconfig = {
"HEADER_SEARCH_PATHS" => header_search_paths,
"OTHER_CFLAGS" => "$(inherited) -DRN_FABRIC_ENABLED" + " " + folly_flags,
"OTHER_CFLAGS" => "$(inherited) " + folly_flags,
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20"
}.merge!(ENV['USE_FRAMEWORKS'] != nil ? {
"PUBLIC_HEADERS_FOLDER_PATH" => "#{module_name}.framework/Headers/#{header_dir}"
Expand Down
4 changes: 0 additions & 4 deletions packages/react-native/ReactCommon/jsc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ target_link_libraries(jscruntime
jsi
glog)

# TODO: Remove this flag when ready.
# Android has this enabled by default, but the flag is still needed for iOS.
target_compile_options(jscruntime PRIVATE -DRN_FABRIC_ENABLED)

if(NOT ${CMAKE_BUILD_TYPE} MATCHES Debug)
target_compile_options(jscruntime PRIVATE -DNDEBUG)
endif()
13 changes: 0 additions & 13 deletions packages/react-native/ReactCommon/jsc/JSCRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,7 @@ class JSCRuntime : public jsi::Runtime {
static JSStringRef stringRef(const jsi::String& str);
static JSStringRef stringRef(const jsi::PropNameID& sym);
static JSObjectRef objectRef(const jsi::Object& obj);

#ifdef RN_FABRIC_ENABLED
static JSObjectRef objectRef(const jsi::WeakObject& obj);
#endif

// Factory methods for creating String/Object
jsi::Symbol createSymbol(JSValueRef symbolRef) const;
Expand Down Expand Up @@ -1065,23 +1062,15 @@ jsi::Array JSCRuntime::getPropertyNames(const jsi::Object& obj) {
}

jsi::WeakObject JSCRuntime::createWeakObject(const jsi::Object& obj) {
#ifdef RN_FABRIC_ENABLED
// TODO: revisit this implementation
JSObjectRef objRef = objectRef(obj);
return make<jsi::WeakObject>(makeObjectValue(objRef));
#else
throw std::logic_error("Not implemented");
#endif
}

jsi::Value JSCRuntime::lockWeakObject(const jsi::WeakObject& obj) {
#ifdef RN_FABRIC_ENABLED
// TODO: revisit this implementation
JSObjectRef objRef = objectRef(obj);
return jsi::Value(createObject(objRef));
#else
throw std::logic_error("Not implemented");
#endif
}

jsi::Array JSCRuntime::createArray(size_t length) {
Expand Down Expand Up @@ -1527,12 +1516,10 @@ JSObjectRef JSCRuntime::objectRef(const jsi::Object& obj) {
return static_cast<const JSCObjectValue*>(getPointerValue(obj))->obj_;
}

#ifdef RN_FABRIC_ENABLED
JSObjectRef JSCRuntime::objectRef(const jsi::WeakObject& obj) {
// TODO: revisit this implementation
return static_cast<const JSCObjectValue*>(getPointerValue(obj))->obj_;
}
#endif

void JSCRuntime::checkException(JSValueRef exc) {
if (JSC_UNLIKELY(exc)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/ReactCommon/jsc/React-jsc.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ Pod::Spec.new do |s|
s.dependency "React-jsi", version

s.subspec "Fabric" do |ss|
ss.pod_target_xcconfig = { "OTHER_CFLAGS" => "$(inherited) -DRN_FABRIC_ENABLED" }
ss.pod_target_xcconfig = { "OTHER_CFLAGS" => "$(inherited)" }
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -93,33 +93,13 @@ def testGenerateReactCodegenPodspec_whenItHasNotBeenAlreadyGenerated_generatesIt
# ========================== #
# Test - GetReactCodegenSpec #
# ========================== #

def testGetReactCodegenSpec_whenFabricDisabledAndNoScriptPhases_generatesAPodspec
# Arrange
FileMock.files_to_read('package.json' => '{ "version": "99.98.97"}')

# Act
podspec = CodegenUtils.new().get_react_codegen_spec(
'package.json',
:fabric_enabled => false,
:hermes_enabled => true,
:script_phases => nil,
:file_manager => FileMock
)

# Assert
assert_equal(podspec, get_podspec_no_fabric_no_script())
assert_equal(Pod::UI.collected_messages, [])
end

def testGetReactCodegenSpec_whenFabricEnabledAndScriptPhases_generatesAPodspec
# Arrange
FileMock.files_to_read('package.json' => '{ "version": "99.98.97"}')

# Act
podspec = CodegenUtils.new().get_react_codegen_spec(
'package.json',
:fabric_enabled => true,
:hermes_enabled => true,
:script_phases => "echo Test Script Phase",
:file_manager => FileMock
Expand All @@ -138,7 +118,7 @@ def testGetReactCodegenSpec_whenUseFrameworksAndNewArch_generatesAPodspec
# Act
podspec = CodegenUtils.new().get_react_codegen_spec(
'package.json',
:fabric_enabled => true,

:hermes_enabled => true,
:script_phases => nil,
:file_manager => FileMock
Expand Down Expand Up @@ -380,11 +360,9 @@ def testUseReactCodegenDiscovery_whenParametersAreGood_executeCodegen
:app_path => app_path,
:config_file_dir => "",
:config_key => "codegenConfig",
:fabric_enabled => false,
:react_native_path => "../node_modules/react-native"}
])
assert_equal(codegen_utils_mock.get_react_codegen_spec_params, [{
:fabric_enabled => false,
:folly_version=>"2023.08.07.00",
:package_json_file => "#{app_path}/ios/../node_modules/react-native/package.json",
:script_phases => "echo TestScript"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,17 @@ def get_react_codegen_script_phases(
)
@get_react_codegen_script_phases_params.push({
app_path: app_path,
fabric_enabled: fabric_enabled,
config_file_dir: config_file_dir,
react_native_path: react_native_path,
config_key: config_key
})
return @react_codegen_script_phases
end

def get_react_codegen_spec(package_json_file, folly_version: '2023.08.07.00', fabric_enabled: false, hermes_enabled: true, script_phases: nil)
def get_react_codegen_spec(package_json_file, folly_version: '2023.08.07.00', hermes_enabled: true, script_phases: nil)
@get_react_codegen_spec_params.push({
package_json_file: package_json_file,
folly_version: folly_version,
fabric_enabled: fabric_enabled,
script_phases: script_phases
})
return @react_codegen_spec
Expand Down
62 changes: 0 additions & 62 deletions packages/react-native/scripts/cocoapods/__tests__/utils-test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -790,68 +790,6 @@ def test_updateSearchPaths_whenNotUseFrameworks_addsSearchPaths
end
end

# ============================= #
# Test - Apply Flags For Fabric #
# ============================= #
def test_applyFlagsForFabric_whenFabricEnabled_addsTheFlag
# Arrange
first_target = prepare_target("FirstTarget")
second_target = prepare_target("SecondTarget")
third_target = prepare_target("ThirdTarget", "com.apple.product-type.bundle")
user_project_mock = UserProjectMock.new("a/path", [
prepare_config("Debug"),
prepare_config("Release"),
],
:native_targets => [
first_target,
second_target
]
)
pods_projects_mock = PodsProjectMock.new([third_target], {"hermes-engine" => {}})
installer = InstallerMock.new(pods_projects_mock, [
AggregatedProjectMock.new(user_project_mock)
])

# Act
ReactNativePodsUtils.apply_flags_for_fabric(installer, fabric_enabled: true)

# Assert
user_project_mock.build_configurations.each do |config|
received_cflags = config.build_settings["OTHER_CFLAGS"]
expected_cflags = "$(inherited) -DRN_FABRIC_ENABLED"
assert_equal(received_cflags, expected_cflags)
end

end

def test_applyFlagsForFabric_whenFabricDisabled_doNothing
# Arrange
first_target = prepare_target("FirstTarget")
second_target = prepare_target("SecondTarget")
third_target = prepare_target("ThirdTarget", "com.apple.product-type.bundle")
user_project_mock = UserProjectMock.new("/a/path", [
prepare_config("Debug"),
prepare_config("Release"),
],
:native_targets => [
first_target,
second_target
]
)
pods_projects_mock = PodsProjectMock.new([third_target], {"hermes-engine" => {}})
installer = InstallerMock.new(pods_projects_mock, [
AggregatedProjectMock.new(user_project_mock)
])

# Act
ReactNativePodsUtils.apply_flags_for_fabric(installer, fabric_enabled: false)

# Assert
user_project_mock.build_configurations.each do |config|
assert_equal(config.build_settings["OTHER_CFLAGS"], "$(inherited)")
end
end

# ============================== #
# Test - Apply ATS configuration #
# ============================== #
Expand Down
13 changes: 3 additions & 10 deletions packages/react-native/scripts/cocoapods/codegen_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ def generate_react_codegen_podspec!(spec, codegen_output_dir, file_manager: File
#
# Parameters
# - package_json_file: the path to the `package.json`, required to extract the proper React Native version
# - fabric_enabled: whether fabric is enabled or not.
# - hermes_enabled: whether hermes is enabled or not.
# - script_phases: whether we want to add some build script phases or not.
# - file_manager: a class that implements the `File` interface. Defaults to `File`, the Dependency can be injected for testing purposes.
def get_react_codegen_spec(package_json_file, folly_version: '2023.08.07.00', fabric_enabled: false, hermes_enabled: true, script_phases: nil, file_manager: File)
def get_react_codegen_spec(package_json_file, folly_version: '2023.08.07.00', hermes_enabled: true, script_phases: nil, file_manager: File)
package = JSON.parse(file_manager.read(package_json_file))
version = package['version']
new_arch_disabled = ENV['RCT_NEW_ARCH_ENABLED'] != "1"
Expand Down Expand Up @@ -136,18 +135,13 @@ def get_react_codegen_spec(package_json_file, folly_version: '2023.08.07.00', fa
"React-NativeModulesApple": [],
"glog": [],
"DoubleConversion": [],
}
}

if fabric_enabled
spec[:'dependencies'].merge!({
'React-graphics': [],
'React-rendererdebug': [],
'React-Fabric': [],
'React-debug': [],
'React-utils': [],
});
end
}
}

if hermes_enabled
spec[:'dependencies'].merge!({
Expand Down Expand Up @@ -313,7 +307,6 @@ def use_react_native_codegen_discovery!(
react_codegen_spec = codegen_utils.get_react_codegen_spec(
file_manager.join(relative_installation_root, react_native_path, "package.json"),
:folly_version => folly_version,
:fabric_enabled => fabric_enabled,
:hermes_enabled => hermes_enabled,
:script_phases => script_phases
)
Expand Down
9 changes: 0 additions & 9 deletions packages/react-native/scripts/cocoapods/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,6 @@ def self.apply_xcode_15_patch(installer, xcodebuild_manager: Xcodebuild)

end

def self.apply_flags_for_fabric(installer, fabric_enabled: false)
fabric_flag = "-DRN_FABRIC_ENABLED"
if fabric_enabled
self.add_compiler_flag_to_project(installer, fabric_flag)
else
self.remove_compiler_flag_from_project(installer, fabric_flag)
end
end

private

def self.add_build_settings_to_pod(installer, settings_name, settings_value, target_pod_name, configuration)
Expand Down
13 changes: 3 additions & 10 deletions packages/react-native/scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def use_react_native! (

ReactNativePodsUtils.warn_if_not_on_arm64()

build_codegen!(prefix, relative_path_from_current)

# The Pods which should be included in all projects
pod 'FBLazyVector', :path => "#{prefix}/Libraries/FBLazyVector"
pod 'RCTRequired', :path => "#{prefix}/Libraries/Required"
Expand Down Expand Up @@ -174,15 +176,7 @@ def use_react_native! (
# If the New Arch is turned off, we will use the Old Renderer, though.
# RNTester always installed Fabric, this change is required to make the template work.
setup_fabric!(:react_native_path => prefix)

if !fabric_enabled
relative_installation_root = Pod::Config.instance.installation_root.relative_path_from(Pathname.pwd)
build_codegen!(prefix, relative_installation_root)
end

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

pods_to_update = LocalPodspecPatch.pods_to_update(:react_native_path => prefix)
if !pods_to_update.empty?
Expand Down Expand Up @@ -281,7 +275,6 @@ def react_native_post_install(
ReactNativePodsUtils.update_search_paths(installer)
ReactNativePodsUtils.set_use_hermes_build_setting(installer, hermes_enabled)
ReactNativePodsUtils.set_node_modules_user_settings(installer, react_native_path)
ReactNativePodsUtils.apply_flags_for_fabric(installer, fabric_enabled: fabric_enabled)
ReactNativePodsUtils.apply_xcode_15_patch(installer)
ReactNativePodsUtils.apply_ats_config(installer)
ReactNativePodsUtils.updateOSDeploymentTarget(installer)
Expand Down
Loading