iosreact-nativecocoapodsreact-native-video

Cannot find type 'RCTEventDispatcher' in scope | react-native-video


Can`t build project on IOS.

Error:

Cannot find type 'RCTEventDispatcher' in scope  
React-native v0.73.6 + react-native-video ^6.5.0
import AVFoundation
import AVKit
import Foundation
#if USE_GOOGLE_IMA
    import GoogleInteractiveMediaAds
#endif
import React

// MARK: - RCTVideo

class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverHandler {
    private var _player: AVPlayer?
    private var _playerItem: AVPlayerItem?
    private var _source: VideoSource?
    private var _playerLayer: AVPlayerLayer?
    private var _chapters: [Chapter]?

    private var _playerViewController: RCTVideoPlayerViewController?
    private var _videoURL: NSURL?
    private var _localSourceEncryptionKeyScheme: String?

    /* Required to publish events */
    private var _eventDispatcher: RCTEventDispatcher?
    private var _videoLoadStarted = false
init(eventDispatcher: RCTEventDispatcher!) {
        super.init(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
        ReactNativeVideoManager.shared.registerView(newInstance: self)
        #if USE_GOOGLE_IMA
            _imaAdsManager = RCTIMAAdsManager(video: self, pipEnabled: isPipEnabled)
        #endif

        _eventDispatcher = eventDispatcher

        #if os(iOS)
            if _pictureInPictureEnabled {
                initPictureinPicture()
                _playerViewController?.allowsPictureInPicturePlayback = true
            } else {
                _playerViewController?.allowsPictureInPicturePlayback = false
            }
        #endif

Error in Xcode

Error in Xcode

pods reinstall doesnt work I have googled and all methods described in next issues dont work: https://github.com/TheWidlarzGroup/react-native-video/issues/3004
https://github.com/TheWidlarzGroup/react-native-video/issues/3622
https://github.com/TheWidlarzGroup/react-native-video/issues/3152 error: expected a type - eventDispatcher:(nonnull RCTEventDispatcher *)eventDispatcher; AND 'Undefined symbol' errors during iOS build


Solution

  • This worked for me:

    First, update react-native from version 0.73.6 to 0.75.3.

    Then, run the command in the iOS folder:

    pod update hermes-engine --no-repo-update
    

    Related question: Invariant Violation: requireNativeComponent: "RCTVideo" was not found in the UIManager