-
Notifications
You must be signed in to change notification settings - Fork 94
Migrate from react-native-reanimated
to react-native-worklets
with backward compatibility
#731
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
Changes from all commits
1ab9b13
a3f46db
bbb432a
40b237c
e77ccf3
864ab7c
52d57be
8136e19
0fd3c5f
3a79358
49b7213
8c55455
2e125b8
955060b
d5134ad
1e3ab8b
423312b
a8a5765
ad71c95
15c34d5
a1b25f6
7f50fee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -5,8 +5,18 @@ react_native_json = JSON.parse(File.read(File.join(react_native_node_modules_dir | |||||||||
react_native_minor_version = react_native_json['version'].split('.')[1].to_i | ||||||||||
|
||||||||||
pods_root = Pod::Config.instance.project_pods_root | ||||||||||
react_native_reanimated_node_modules_dir = ENV['REACT_NATIVE_REANIMATED_NODE_MODULES_DIR'] || File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('react-native-reanimated/package.json')"`) | ||||||||||
react_native_reanimated_node_modules_dir_from_pods_root = Pathname.new(react_native_reanimated_node_modules_dir).relative_path_from(pods_root).to_s | ||||||||||
|
||||||||||
worklets_installed = system(%Q[ | ||||||||||
cd "#{Pod::Config.instance.installation_root}" && | ||||||||||
node -e "require.resolve('react-native-worklets/package.json')" > /dev/null 2>&1 | ||||||||||
]) | ||||||||||
Comment on lines
+9
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The worklets_installed variable is being set twice with different logic. Line 9-12 uses system() to check if worklets can be resolved, but lines 13-14 overwrite this with a different check. This could lead to inconsistent detection results.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's a valid comment - I forgot to remove the previous logic of calculating |
||||||||||
react_native_worklets_path = `cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('react-native-worklets/package.json')"` | ||||||||||
worklets_installed = react_native_worklets_path != "" | ||||||||||
worklets_package_name = worklets_installed ? 'react-native-worklets' : 'react-native-reanimated' | ||||||||||
|
||||||||||
react_native_worklets_or_reanimated_node_modules_dir = ENV['REACT_NATIVE_WORKLETS_NODE_MODULES_DIR'] || ENV['REACT_NATIVE_REANIMATED_NODE_MODULES_DIR'] || | ||||||||||
File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('#{worklets_package_name}/package.json')"`) | ||||||||||
react_native_worklets_or_reanimated_node_modules_dir_from_pods_root = Pathname.new(react_native_worklets_or_reanimated_node_modules_dir).relative_path_from(pods_root).to_s | ||||||||||
|
||||||||||
package = JSON.parse(File.read(File.join(__dir__, "package.json"))) | ||||||||||
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' | ||||||||||
|
@@ -24,15 +34,23 @@ Pod::Spec.new do |s| | |||||||||
|
||||||||||
s.source_files = "apple/**/*.{h,m,mm}", "cpp/**/*.{h,cpp}" | ||||||||||
|
||||||||||
s.dependency "RNReanimated/worklets" | ||||||||||
if worklets_installed | ||||||||||
s.dependency "RNWorklets" | ||||||||||
else | ||||||||||
s.dependency "RNReanimated/worklets" | ||||||||||
end | ||||||||||
|
||||||||||
s.xcconfig = { | ||||||||||
xcconfig = { | ||||||||||
"OTHER_CFLAGS" => "$(inherited) -DREACT_NATIVE_MINOR_VERSION=#{react_native_minor_version}", | ||||||||||
"HEADER_SEARCH_PATHS" => [ | ||||||||||
"\"$(PODS_ROOT)/#{react_native_reanimated_node_modules_dir_from_pods_root}/apple\"", | ||||||||||
"\"$(PODS_ROOT)/#{react_native_reanimated_node_modules_dir_from_pods_root}/Common/cpp\"", | ||||||||||
"\"$(PODS_ROOT)/#{react_native_worklets_or_reanimated_node_modules_dir_from_pods_root}/apple\"", | ||||||||||
"\"$(PODS_ROOT)/#{react_native_worklets_or_reanimated_node_modules_dir_from_pods_root}/Common/cpp\"", | ||||||||||
].join(' '), | ||||||||||
} | ||||||||||
if worklets_installed | ||||||||||
xcconfig["OTHER_CFLAGS"] << " -DWORKLETS_INSTALLED=1" | ||||||||||
tomekzaw marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
end | ||||||||||
s.xcconfig = xcconfig | ||||||||||
|
||||||||||
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/cpp\"" } | ||||||||||
|
||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.