Skip to content
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

Unrecognised selector sent to instance #69

Open
nikesh8 opened this issue Jul 15, 2020 · 1 comment
Open

Unrecognised selector sent to instance #69

nikesh8 opened this issue Jul 15, 2020 · 1 comment

Comments

@nikesh8
Copy link

nikesh8 commented Jul 15, 2020

Hello,
I am trying with the demo code and return a simple view with color. But when I have passed 'exampleprop' it will be throwing an error. My code Will looks like Below. Please refer attached screenshot for error.

RNVideoModule-Bridging-Header.h

//  Created by react-native-create-bridge
// RNVideoModule-Bridging-Header.h

// import RCTBridgeModule
#if __has_include(<React/RCTBridgeModule.h>)
#import <React/RCTBridgeModule.h>
#elif __has_include(“RCTBridgeModule.h”)
#import “RCTBridgeModule.h”
#else
#import “React/RCTBridgeModule.h” // Required when used as a Pod in a Swift project
#endif

// import RCTEventEmitter
#if __has_include(<React/RCTViewManager.h>)
#import <React/RCTViewManager.h>
#elif __has_include(“RCTViewManager.h”)
#import “RCTViewManager.h”
#else
#import “React/RCTViewManager.h” // Required when used as a Pod in a Swift project
#endif

RNVideoModule.m

//  Created by react-native-create-bridge

// import RCTViewManager
#if __has_include(<React/RCTViewManager.h>)
#import <React/RCTViewManager.h>
#elif __has_include(“RCTViewManager.h”)
#import “RCTViewManager.h”
#else
#import “React/RCTViewManager.h” // Required when used as a Pod in a Swift project
#endif

// import RCTEventDispatcher
#if __has_include(<React/RCTEventDispatcher.h>)
#import <React/RCTEventDispatcher.h>
#elif __has_include(“RCTEventDispatcher.h”)
#import “RCTEventDispatcher.h”
#else
#import “React/RCTEventDispatcher.h” // Required when used as a Pod in a Swift project
#endif

// Export a native module
// https://facebook.github.io/react-native/docs/native-modules-ios.html#exporting-swift
@interface RCT_EXTERN_MODULE(RNVideoModule, RCTViewManager)

// Map native properties to React Component props
// https://facebook.github.io/react-native/docs/native-components-ios.html#properties
RCT_EXPORT_VIEW_PROPERTY(exampleProp, NSString)

// Export methods to a native module
// https://facebook.github.io/react-native/docs/native-modules-ios.html#exporting-swift
RCT_EXTERN_METHOD(exampleMethod)

@end

RNVideoModuleManager.swift

//  Created by react-native-create-bridge

import Foundation

@objc(RNVideoModule)
class RNVideoModuleManager : RCTViewManager {
  // Export constants to use in your native module
//  override func constantsToExport() -> [String : Any]! {
//    return ["EXAMPLE_CONSTANT": "example"]
//  }

  // Return the native view that represents your React component
  override func view() -> UIView! {
    let player : UIView = UIView(frame: CGRect(origin: CGPoint(x: 0, y: 0), size: CGSize(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.width)))
    player.backgroundColor = UIColor.red
    return player
  }

  // Implement methods that you want to export to the native module
  @objc func exampleMethod() {
    // The bridge eventDispatcher is used to send events from native to JS env
    // No documentation yet on DeviceEventEmitter: https://github.com/facebook/react-native/issues/2819
    self.bridge.eventDispatcher().sendAppEvent(withName: "EXAMPLE_EVENT", body: nil)
  }
}
<View style={{ flex: 1 }}>
             <RNVideoModuleView style={{ height: 300, width: 300 }} exampleProp={'Nikesh'} />
</View>

Please help me out with this issue to how to overcome.

NOTE: I am using Swift Modules for this

Simulator Screen Shot - iPhone 11 - 2020-07-15 at 16 30 53

@nikesh8
Copy link
Author

nikesh8 commented Jul 29, 2020

Hello,
Any updates on this issue. Actually I am stuck at some point because of this issue. Please help me out with this to overcome this problem.

Hello,
I am trying with the demo code and return a simple view with color. But when I have passed 'exampleprop' it will be throwing an error. My code Will looks like Below. Please refer attached screenshot for error.

RNVideoModule-Bridging-Header.h

//  Created by react-native-create-bridge
// RNVideoModule-Bridging-Header.h

// import RCTBridgeModule
#if __has_include(<React/RCTBridgeModule.h>)
#import <React/RCTBridgeModule.h>
#elif __has_include(“RCTBridgeModule.h”)
#import “RCTBridgeModule.h”
#else
#import “React/RCTBridgeModule.h” // Required when used as a Pod in a Swift project
#endif

// import RCTEventEmitter
#if __has_include(<React/RCTViewManager.h>)
#import <React/RCTViewManager.h>
#elif __has_include(“RCTViewManager.h”)
#import “RCTViewManager.h”
#else
#import “React/RCTViewManager.h” // Required when used as a Pod in a Swift project
#endif

RNVideoModule.m

//  Created by react-native-create-bridge

// import RCTViewManager
#if __has_include(<React/RCTViewManager.h>)
#import <React/RCTViewManager.h>
#elif __has_include(“RCTViewManager.h”)
#import “RCTViewManager.h”
#else
#import “React/RCTViewManager.h” // Required when used as a Pod in a Swift project
#endif

// import RCTEventDispatcher
#if __has_include(<React/RCTEventDispatcher.h>)
#import <React/RCTEventDispatcher.h>
#elif __has_include(“RCTEventDispatcher.h”)
#import “RCTEventDispatcher.h”
#else
#import “React/RCTEventDispatcher.h” // Required when used as a Pod in a Swift project
#endif

// Export a native module
// https://facebook.github.io/react-native/docs/native-modules-ios.html#exporting-swift
@interface RCT_EXTERN_MODULE(RNVideoModule, RCTViewManager)

// Map native properties to React Component props
// https://facebook.github.io/react-native/docs/native-components-ios.html#properties
RCT_EXPORT_VIEW_PROPERTY(exampleProp, NSString)

// Export methods to a native module
// https://facebook.github.io/react-native/docs/native-modules-ios.html#exporting-swift
RCT_EXTERN_METHOD(exampleMethod)

@end

RNVideoModuleManager.swift

//  Created by react-native-create-bridge

import Foundation

@objc(RNVideoModule)
class RNVideoModuleManager : RCTViewManager {
  // Export constants to use in your native module
//  override func constantsToExport() -> [String : Any]! {
//    return ["EXAMPLE_CONSTANT": "example"]
//  }

  // Return the native view that represents your React component
  override func view() -> UIView! {
    let player : UIView = UIView(frame: CGRect(origin: CGPoint(x: 0, y: 0), size: CGSize(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.width)))
    player.backgroundColor = UIColor.red
    return player
  }

  // Implement methods that you want to export to the native module
  @objc func exampleMethod() {
    // The bridge eventDispatcher is used to send events from native to JS env
    // No documentation yet on DeviceEventEmitter: https://github.com/facebook/react-native/issues/2819
    self.bridge.eventDispatcher().sendAppEvent(withName: "EXAMPLE_EVENT", body: nil)
  }
}
<View style={{ flex: 1 }}>
             <RNVideoModuleView style={{ height: 300, width: 300 }} exampleProp={'Nikesh'} />
</View>

Please help me out with this issue to how to overcome.

NOTE: I am using Swift Modules for this

Simulator Screen Shot - iPhone 11 - 2020-07-15 at 16 30 53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant