TheWidlarzGroup / react-native-video

A <Video /> component for react-native
MIT License
7.08k stars 2.85k forks source link

[BUG]: Duplicate interface definition for class 'RCTEventDispatcher' #3774

Open simoes-agroleague opened 1 month ago

simoes-agroleague commented 1 month ago

Version

6.0.0

What platforms are you having the problem on?

iOS

Architecture

Old architecture

What happened?

I am experiencing the same issue than Or in other words, changing node_modules/react-native-video/ios/Video/RCTVideo-Bridging-Header.h to:

The issue started on version 6.0.0-rc0 and I use react-native 0.73.6 I cannot modify the framework linkage static in the Podfile as it conflict with other libraries (Firebase for ex).

The only working fix is patching react-native-video/ios/Video/RCTVideo-Bridging-Header.h by adding the following import : #import "RCTEventDispatcher.h"

Can you please integrate this import to the next version of react-native-video ?

Thanks !

Reproduction

repository link

Reproduction

Step to reproduce this bug are:

Install react-native-video v6.0.0 with react-native v0.73.6 and keep the same config has previously in the Podfile :

`pod 'react-native-video', :path => '../node_modules/react-native-video/react-native-video.podspec'`
freeboub commented 1 month ago

@simoes-agroleague but you need to remove: pod 'react-native-video', :path => '../node_modules/react-native-video/react-native-video.podspec' as explain here: https://thewidlarzgroup.github.io/react-native-video/updating Did you try to remove this line ?

mmorier commented 1 month ago

@simoes-agroleague but you need to remove: pod 'react-native-video', :path => '../node_modules/react-native-video/react-native-video.podspec' as explain here: https://thewidlarzgroup.github.io/react-native-video/updating Did you try to remove this line ?

Yes I tested on my side and it was the same for me.

freeboub commented 1 month ago

I am not really confident in adding include which is unused ... (moreover I don't really understand what it do with linking). BTW, I think I found a good fix for this.

I applied following patch in the sample which allows to use dynamic framework.

@@ -16,19 +16,30 @@ if linkage != nil
 end

 target 'videoplayer' do
   config = use_native_modules!

-  use_frameworks! :linkage => :static
+  use_frameworks! :linkage => :dynamic

   if ENV['RNV_SAMPLE_ENABLE_ADS']
     $RNVideoUseGoogleIMA = true
   end
   if ENV['RNV_SAMPLE_VIDEO_CACHING']
     $RNVideoUseVideoCaching = true
   end

+  pre_install do |installer|
+    installer.pod_targets.each do |pod|
+      if pod.name.eql?('react-native-video')
+        def pod.build_type
+          Pod::BuildType.static_library
+        end
+      end
+     end
+   end
+
   # Flags change depending on the env values.
   flags = get_default_flags()

   use_react_native!(
     :path => config[:reactNativePath],

I first update use_frameworks! :linkage => :dynamic -> I got a link issue, let say the issue is reproduced. (note that it was a missing symbol, not a a duplicate symbol). Then I added the other part to force linkage of react native video as static, And now it works.

Can you please try to add the pre_install section in your app to se if it fixes the issue. If correct, I will update documentation. Thank you

freeboub commented 1 month ago

@simoes-agroleague Did you test my proposal ?

simoes-agroleague commented 1 month ago

Thanks for the proposition @freeboub. I did not manage to set the use_frameworks! :linkage => :dynamic as another library I am using (RefinerSDK), doesn't resolve correctly. For what it worths, without the use_frameworks the pre_install alone doesn't do the tricks, I got the same error. I will keep the patch_package fix for now.

freeboub commented 1 month ago

@simoes-agroleague OK, thanks for the update. Just to be clear, your expectation is to have no use_frameworks at all ?!

simoes-agroleague commented 1 month ago

Exactly @freeboub

freeboub commented 1 month ago

@simoes-agroleague I just try to remove the use_frameworks in the sample app, It builds without issue 🙄 It is react 0.74 with xcode 15.3

Roshdy commented 1 month ago

@freeboub so how should the rest of us do it :) I'm using rn 0.72.5, i set the min_ios_override to 13.0

To make pod install run smoothly, i do the below:

# enable Video caching
  pod 'DVAssetLoaderDelegate', :modular_headers => true
  pod 'SPTPersistentCache', :modular_headers => true
  $RNVideoUseVideoCaching = true

my linkage is the standard react-native new app

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
  Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
  use_frameworks! :linkage => linkage.to_sym
end

and i override any modular headers like this

pod 'Firebase/Auth', :modular_headers => true
pod 'FirebaseAuth', :modular_headers => true
pod 'FirebaseCore', :modular_headers => true
pod 'Firebase', :modular_headers => true

I'm not sure if I should include the react-native-video to the modular_headers or not, but when i tried pods wouldn't install.

freeboub commented 1 month ago

@Roshdy you should try, but the issue described here is not a pod install issue, but a build issue ... Did you double check the installation documentation for ios ?

Roshdy commented 1 month ago

@freeboub yes i'm pod installing successfully now, but i'm getting Cannot find type 'RCTEventDispatcher' in scope in xcode @ react-antive-video/RCTVideo.swift