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

fix(ios): deprecate :use_turbomodule for :use_fabric #1766

Merged
merged 1 commit into from
Jan 16, 2024
Merged
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
1 change: 0 additions & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ workspace 'Example.xcworkspace'
options = {
:fabric_enabled => false,
:hermes_enabled => false,
:turbomodule_enabled => false,
}

use_test_app! options do |target|
Expand Down
2 changes: 1 addition & 1 deletion ios/ReactTestApp/ReactInstance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class ReactInstance: NSObject, RNXHostConfig {

super.init()

#if USE_TURBOMODULE
#if USE_FABRIC
RCTEnableTurboModule(true)
#endif

Expand Down
27 changes: 4 additions & 23 deletions ios/pod_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
def fabric_enabled?(options, react_native_version)
return true if new_architecture_enabled?(options, react_native_version)

supports_new_architecture = supports_new_architecture?(react_native_version)
supports_new_architecture && options[:fabric_enabled]
end

def find_file(file_name, current_dir)
return if current_dir.expand_path.to_s == '/'

Expand All @@ -16,7 +9,8 @@ def find_file(file_name, current_dir)

def new_architecture_enabled?(options, react_native_version)
supports_new_architecture = supports_new_architecture?(react_native_version)
supports_new_architecture && ENV.fetch('RCT_NEW_ARCH_ENABLED', options[:turbomodule_enabled])
supports_new_architecture && ENV.fetch('RCT_NEW_ARCH_ENABLED',
options[:fabric_enabled] || options[:turbomodule_enabled])
end

def resolve_module(request, start_dir = Pod::Config.instance.installation_root)
Expand Down Expand Up @@ -48,29 +42,16 @@ def try_pod(name, podspec, project_root)

def use_new_architecture!(options)
new_arch_enabled = new_architecture_enabled?(options, v(1_000, 0, 0))

if new_arch_enabled || options[:fabric_enabled]
Pod::UI.warn(
'As of writing, Fabric is still experimental and subject to change. ' \
'For more information, please see ' \
'https://reactnative.dev/docs/next/new-architecture-intro.'
)
ENV['RCT_NEW_ARCH_ENABLED'] = '1'
end

return unless new_arch_enabled

Pod::UI.warn(
'As of writing, TurboModule is still experimental and subject to change. ' \
'For more information, please see ' \
'As of writing, New Architecture (Fabric) is still experimental and ' \
'subject to change. For more information, please see ' \
'https://reactnative.dev/docs/next/new-architecture-intro.'
)

# At the moment, Fabric and TurboModule code are intertwined. We need to
# enable Fabric for some code that TurboModule relies on.
options[:fabric_enabled] = true
options[:new_arch_enabled] = true
options[:turbomodule_enabled] = true
ENV['RCT_NEW_ARCH_ENABLED'] = '1'
end

Expand Down
17 changes: 6 additions & 11 deletions ios/test_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,7 @@ def make_project!(xcodeproj, project_root, target_platform, options)
build_number = platform_config('buildNumber', project_root, target_platform)
build_settings['PRODUCT_BUILD_NUMBER'] = build_number || '1'

use_fabric = fabric_enabled?(options, rn_version)
use_turbomodule = new_architecture_enabled?(options, rn_version)

use_new_arch = new_architecture_enabled?(options, rn_version)
app_project = Xcodeproj::Project.open(xcodeproj_dst)
app_project.native_targets.each do |target|
case target.name
Expand All @@ -321,24 +319,22 @@ def make_project!(xcodeproj, project_root, target_platform, options)
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << version_macro
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'USE_FABRIC=1' if use_fabric
if enable_cxx17_removed_unary_binary_function
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] <<
'_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION=1'
end
if use_turbomodule
if use_new_arch
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'FOLLY_NO_CONFIG=1'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'RCT_NEW_ARCH_ENABLED=1'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'USE_TURBOMODULE=1'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'USE_FABRIC=1'
end

build_settings.each do |setting, value|
config.build_settings[setting] = value
end

config.build_settings['OTHER_SWIFT_FLAGS'] ||= ['$(inherited)']
config.build_settings['OTHER_SWIFT_FLAGS'] << '-DUSE_FABRIC' if use_fabric
config.build_settings['OTHER_SWIFT_FLAGS'] << '-DUSE_TURBOMODULE' if use_turbomodule
config.build_settings['OTHER_SWIFT_FLAGS'] << '-DUSE_FABRIC' if use_new_arch
if single_app.is_a? String
config.build_settings['OTHER_SWIFT_FLAGS'] << '-DENABLE_SINGLE_APP_MODE'
end
Expand Down Expand Up @@ -370,8 +366,7 @@ def make_project!(xcodeproj, project_root, target_platform, options)
:macos => config.resolve_build_setting('MACOSX_DEPLOYMENT_TARGET'),
},
:react_native_version => rn_version,
:use_fabric => use_fabric,
:use_turbomodule => use_turbomodule,
:use_new_arch => use_new_arch,
:code_sign_identity => code_sign_identity || '',
:development_team => development_team || '',
}
Expand All @@ -385,7 +380,7 @@ def use_test_app_internal!(target_platform, options)
project_target = make_project!(xcodeproj, project_root, target_platform, options)
xcodeproj_dst, platforms = project_target.values_at(:xcodeproj_path, :platforms)

if project_target[:use_turbomodule] || project_target[:react_native_version] >= v(0, 73, 0)
if project_target[:use_new_arch] || project_target[:react_native_version] >= v(0, 73, 0)
install! 'cocoapods', :deterministic_uuids => false
end

Expand Down
4 changes: 2 additions & 2 deletions scripts/test-matrix.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ function configure(platform, { hermes, newArch }) {
}
if (newArch) {
content = content.replace(
":turbomodule_enabled => false",
":turbomodule_enabled => true"
":fabric_enabled => false",
":fabric_enabled => true"
);
}
fs.writeFileSync(podfile, content);
Expand Down
28 changes: 4 additions & 24 deletions test/test_pod_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,20 @@
require_relative('../ios/pod_helpers')

class TestPodHelpers < Minitest::Test
def test_fabric_enabled?
ENV.delete('RCT_NEW_ARCH_ENABLED')

refute(fabric_enabled?({}, 0))
refute(fabric_enabled?({}, v(0, 68, 0)))

# Fabric is first publicly available in 0.68, but we'll require 0.71
refute(fabric_enabled?({ :fabric_enabled => true }, v(0, 70, 999)))
assert(fabric_enabled?({ :fabric_enabled => true }, v(0, 71, 0)))

# TurboModule implies Fabric
refute(fabric_enabled?({ :turbomodule_enabled => true }, v(0, 70, 999)))
assert(fabric_enabled?({ :turbomodule_enabled => true }, v(0, 71, 0)))

# `RCT_NEW_ARCH_ENABLED` enables everything
ENV['RCT_NEW_ARCH_ENABLED'] = '1'

refute(fabric_enabled?({}, v(0, 70, 999)))
assert(fabric_enabled?({}, v(0, 71, 0)))
end

def test_new_architecture_enabled?
ENV.delete('RCT_NEW_ARCH_ENABLED')

refute(new_architecture_enabled?({}, 0))
refute(new_architecture_enabled?({}, v(0, 71, 0)))

# New architecture is first publicly available in 0.68, but we'll require 0.71
refute(new_architecture_enabled?({ :fabric_enabled => true }, v(0, 70, 999)))
assert(new_architecture_enabled?({ :fabric_enabled => true }, v(0, 71, 0)))

# TODO: `:turbomodule_enabled` is scheduled for removal in 4.0
kelset marked this conversation as resolved.
Show resolved Hide resolved
refute(new_architecture_enabled?({ :turbomodule_enabled => true }, v(0, 70, 999)))
assert(new_architecture_enabled?({ :turbomodule_enabled => true }, v(0, 71, 0)))

# Fabric does not imply TurboModule
refute(new_architecture_enabled?({ :fabric_enabled => true }, v(0, 71, 0)))

# `RCT_NEW_ARCH_ENABLED` enables everything
ENV['RCT_NEW_ARCH_ENABLED'] = '1'

Expand Down
Loading