Skip to content
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
28 changes: 28 additions & 0 deletions ios/pod_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,31 @@ def resolve_module(request)
def try_pod(name, podspec, project_root)
pod name, :podspec => podspec if File.exist?(File.join(project_root, podspec))
end

def use_new_architecture!(options)
new_arch_enabled = new_architecture_enabled?(options, 10_000_000)

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-app-renderer-ios.'
)
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 ' \
'https://reactnative.dev/docs/next/new-architecture-app-modules-ios.'
)

# 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
4 changes: 3 additions & 1 deletion ios/test_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ def react_native_path(project_root, target_platform)

def react_native_pods(version)
v = version.release
if v == Gem::Version.new('0.0.0') || v >= Gem::Version.new('0.68')
if v == Gem::Version.new('0.0.0') || v >= Gem::Version.new('0.70')
'use_react_native-0.70'
elsif v >= Gem::Version.new('0.68')
'use_react_native-0.68'
elsif v >= Gem::Version.new('0.64')
'use_react_native-0.64'
Expand Down
26 changes: 0 additions & 26 deletions ios/use_react_native-0.68.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,6 @@

require_relative('pod_helpers')

def use_new_architecture!(options)
new_arch_enabled = new_architecture_enabled?(options, 10_000_000)

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-app-renderer-ios.'
)
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 ' \
'https://reactnative.dev/docs/next/new-architecture-app-modules-ios.'
)
# 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[:turbomodule_enabled] = true
ENV['RCT_NEW_ARCH_ENABLED'] = '1'
end

def include_react_native!(options)
react_native = options[:path]
flipper_versions = options[:rta_flipper_versions]
Expand Down
39 changes: 39 additions & 0 deletions ios/use_react_native-0.70.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
require 'open3'

require_relative('pod_helpers')

def include_react_native!(options)
react_native = options[:path]
flipper_versions = options[:rta_flipper_versions]
project_root = options[:rta_project_root]
target_platform = options[:rta_target_platform]

require_relative(File.join(project_root, react_native, 'scripts', 'react_native_pods'))

if target_platform == :ios && flipper_versions
Pod::UI.warn(
'use_flipper is deprecated from 0.70; use the flipper_configuration ' \
'option in the use_test_app! function instead if you don\'t need to ' \
'support older versions of react-native.'
)
options[:flipper_configuration] = FlipperConfiguration.enabled(['Debug'], flipper_versions)
end

use_new_architecture!(options)
use_react_native!(options.except(:turbomodule_enabled,
:rta_flipper_versions,
:rta_project_root,
:rta_target_platform))

# If we're using react-native@main, we'll also need to prepare
# `react-native-codegen`.
codegen = File.join(project_root, react_native, 'packages', 'react-native-codegen')
Open3.popen3('yarn build', :chdir => codegen) if File.directory?(codegen)

lambda { |installer|
react_native_post_install(installer)
if defined?(__apply_Xcode_12_5_M1_post_install_workaround)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
}
end
35 changes: 18 additions & 17 deletions test/test_test_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,24 @@ def test_package_version
end

def test_react_native_pods
assert_equal('use_react_native-0.68', react_native_pods(Gem::Version.new('1000.0.0')))

assert_equal('use_react_native-0.68', react_native_pods(Gem::Version.new('0.68.0')))
assert_equal('use_react_native-0.68', react_native_pods(Gem::Version.new('0.68.0-rc.1')))

assert_equal('use_react_native-0.64', react_native_pods(Gem::Version.new('0.67.3')))
assert_equal('use_react_native-0.64', react_native_pods(Gem::Version.new('0.66.4')))
assert_equal('use_react_native-0.64', react_native_pods(Gem::Version.new('0.65.1')))

assert_equal('use_react_native-0.64', react_native_pods(Gem::Version.new('0.64.3')))
assert_equal('use_react_native-0.64', react_native_pods(Gem::Version.new('0.64.0')))

assert_equal('use_react_native-0.63', react_native_pods(Gem::Version.new('0.63.4')))
assert_equal('use_react_native-0.63', react_native_pods(Gem::Version.new('0.63.0')))

assert_equal('use_react_native-0.62', react_native_pods(Gem::Version.new('0.62.2')))
assert_equal('use_react_native-0.62', react_native_pods(Gem::Version.new('0.62.0')))
[
['1000.0.0', '0.70'],
['0.70.0', '0.70'],
['0.70.0-rc.1', '0.70'],
['0.68.0', '0.68'],
['0.68.0-rc.1', '0.68'],
['0.67.3', '0.64'],
['0.66.4', '0.64'],
['0.65.1', '0.64'],
['0.64.3', '0.64'],
['0.64.0', '0.64'],
['0.63.4', '0.63'],
['0.63.0', '0.63'],
['0.62.2', '0.62'],
['0.62.0', '0.62'],
].each do |target, profile|
assert_equal("use_react_native-#{profile}", react_native_pods(Gem::Version.new(target)))
end

assert_raises(RuntimeError) do
react_native_pods(Gem::Version.new('0.61.5'))
Expand Down