Skip to content

Instantly share code, notes, and snippets.

@mrousavy
Created February 8, 2021 14:07
Show Gist options
  • Select an option

  • Save mrousavy/517a18fdabdc048bba238132047cb4b0 to your computer and use it in GitHub Desktop.

Select an option

Save mrousavy/517a18fdabdc048bba238132047cb4b0 to your computer and use it in GitHub Desktop.
A patch for lottie-react-native so it successfully builds with React Native 0.64
diff --git a/node_modules/lottie-react-native/lottie-react-native.podspec b/node_modules/lottie-react-native/lottie-react-native.podspec
index 006d118..63caf4a 100644
--- a/node_modules/lottie-react-native/lottie-react-native.podspec
+++ b/node_modules/lottie-react-native/lottie-react-native.podspec
@@ -14,7 +14,11 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/react-community/lottie-react-native.git", :tag => "v#{s.version}" }
s.source_files = "src/ios/**/*.{h,m,swift}"
- s.swift_version = "5.0"
- s.dependency 'React'
+
+ s.requires_arc = true
+
+ s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
+
+ s.dependency 'React-Core'
s.dependency 'lottie-ios', '~> 3.1.8'
end
diff --git a/node_modules/lottie-react-native/src/ios/LottieReactNative/AnimationViewManagerModule.swift b/node_modules/lottie-react-native/src/ios/LottieReactNative/AnimationViewManagerModule.swift
index 77dbfe2..696f220 100644
--- a/node_modules/lottie-react-native/src/ios/LottieReactNative/AnimationViewManagerModule.swift
+++ b/node_modules/lottie-react-native/src/ios/LottieReactNative/AnimationViewManagerModule.swift
@@ -1,7 +1,3 @@
-#if canImport(React)
-import React
-#endif
-
import Lottie
@objc(LottieAnimationView)
diff --git a/node_modules/lottie-react-native/src/ios/LottieReactNative/ContainerView.swift b/node_modules/lottie-react-native/src/ios/LottieReactNative/ContainerView.swift
index 6d7537b..db15cc5 100644
--- a/node_modules/lottie-react-native/src/ios/LottieReactNative/ContainerView.swift
+++ b/node_modules/lottie-react-native/src/ios/LottieReactNative/ContainerView.swift
@@ -1,7 +1,3 @@
-#if canImport(React)
-import React
-#endif
-
import Lottie
class ContainerView: RCTView {
@HishamMubarak
Copy link
Copy Markdown

Hi, thank you for this! I have been stuck with this issue for hours, and stumbled upon this just now from the react-native-lottie issues page. Patched and it worked just like that!

@rjuevesano
Copy link
Copy Markdown

I got an issue after upgrading to iOS 14.5. Thank you for this. It's really working! 👍

@yosepov
Copy link
Copy Markdown

yosepov commented Jun 14, 2021

someone can explain how do I patch ?

@rjuevesano
Copy link
Copy Markdown

someone can explain how do I patch ?

Try this version 4.0.2. It’s already fixed and no need to add that patch.

@vinipickrodt
Copy link
Copy Markdown

vinipickrodt commented Jul 8, 2021

someone can explain how do I patch ?

I think you will have to create a folder called "patches" in the project root, save this file as "lottie-react-native+3.5.0.patch" and run npx patch-package

It worked here.

@hasnainbaloch
Copy link
Copy Markdown

Just update both lottie packages, it works for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment