blackuy / react-native-twilio-video-webrtc

Twilio Video (WebRTC) for React Native
MIT License
605 stars 402 forks source link

Native module cannot be null error on Ios #55

Closed paul-apacio closed 6 years ago

paul-apacio commented 6 years ago

Steps to reproduce

Intergrate package as usual

Expected behaviour

Expect to not see error

Actual behaviour

Get error, Native module cannot be null, pointing to Native Event Emitter via TwilioVideo.ios.js

Environment

RN: 48 IOS 9

react-native-twilio-video-webrtc

1.0.2

bilby91 commented 6 years ago

Will try to upgrade the example app to the latest version of RN this weekend and see how it goes.

naytun commented 6 years ago

@bilby91 , @paul-apacio Did you find a solution? I have the same problem:

Actual behavior

Invariant Violation: Native module cannot be null. This error is located at: in TwilioVideo in RCTView

react-native-twilio-video-webrtc

1.0.1

Environment

iOS 11.2.5 RN: 0.52.0

frankTurtle commented 6 years ago

Just testing on iOS - Same problem.

Setup is same as @naytun

alfonsosn commented 6 years ago

I'm having the same problem than @naytun. Were you all able to solve the problem? This is what I'm doing on my component, and this is how I'm importing the TwilioVideo, TwilioVideoLocalView, TwilioVideoParticipantView. I copied and pasted from the Example index.ios.js and that didn't work either... All I'm trying to do is test the component.

The error is:

ExceptionsManager.js:71 Unhandled JS Exception: Invariant Violation: Native module cannot be null.

This error is located at:
    in _class (at WebRTCScreen.js)
    in RCTView (at View.js:60)
import {
  TwilioVideoLocalView,
  TwilioVideoParticipantView,
  TwilioVideo
} from 'react-native-twilio-video-webrtc'

export default class WebRTCScreen extends Component {
  constructor(props) {
    super(props);

    this.state = {    }
  }

  render() {
    return (
      <View style={styles.container}>
        <TwilioVideo
          ref="twilioVideo"
          onRoomDidConnect={ () => {} }
          onRoomDidDisconnect={ () => {} }
          onRoomDidFailToConnect={ () => {} }
          onParticipantAddedVideoTrack={ () => {} }
          onParticipantRemovedVideoTrack={ () => {} }
        />
      </View>
    );
  }
}
alfonsosn commented 6 years ago

Okay actually, I think I solved my problem. I was reading that usually this problem stems from not adding the header file to your Xcode project. So for this case, I used step 2 from the installation guide of oney/react-native-webrtc. I'll add the step in case this works for anyone else.

Step: Add Library Search Path in Xcode

2-1.) select Build Settings, find Search Paths
2-2.) edit BOTH Framework Search Paths and Library Search Paths
2-3.) add path on BOTH sections with: $(SRCROOT)/../node_modules/react-native-twilio-video-webrtc/ios with recursive.

You can use the image below to guide you in this step. Just make sure you import the search pat for react-native-twilio-video-webrtc

doc_install_xcode_search_path

slycoder commented 6 years ago

Yep, I'll take a pass at updating the docs.

cristiandley commented 6 years ago

Im having this issue, but no luck at all with your solution @alfonsosn

slycoder commented 6 years ago

Can you verify that this package's library is being linked in the Build Phases section of your project?

cristiandley commented 6 years ago

Yes, for some reason Build Phases cleaned... but... again same error as in #116


** BUILD FAILED **

The following build commands failed:
        CompileC /Users/cristianleyes/proyectos/_app-rn/ios/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/React.build/Objects-normal/x86_64/RCTUIManagerUtils.o Modules/RCTUIManagerUtils.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
slycoder commented 6 years ago

Do you have the actual failure? That's just the command that failed but not what the actual error was.

slycoder commented 6 years ago

Also what do you mean by Build Phases cleaned?

cristiandley commented 6 years ago

Also what do you mean by Build Phases cleaned?

Nvm... i mixed ideas.


Yes i have the actual failure:

Ld /Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Products/Debug-iphonesimulator/app-rn.app/app-rn normal x86_64
    cd /Users/cristianleyes/proyectos/app-rn-app-rn/ios
    export IPHONEOS_DEPLOYMENT_TARGET=8.0
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk -L/Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Products/Debug-iphonesimulator -L../node_modules/react-native-twilio-video-webrtc/ios -F/Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Products/Debug-iphonesimulator -F../node_modules/react-native-twilio-video-webrtc/ios -filelist /Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Intermediates.noindex/app-rn.build/Debug-iphonesimulator/app-rn.build/Objects-normal/x86_64/app-rn.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -mios-simulator-version-min=8.0 -Xlinker -object_path_lto -Xlinker /Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Intermediates.noindex/app-rn.build/Debug-iphonesimulator/app-rn.build/Objects-normal/x86_64/app-rn_lto.o -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -ObjC -ObjC -lc++ -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Intermediates.noindex/app-rn.build/Debug-iphonesimulator/app-rn.build/app-rn.app-Simulated.xcent /Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Products/Debug-iphonesimulator/libRNTwilioVideoWebRTC.a /Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Products/Debug-iphonesimulator/libRNCookieManagerIOS.a /Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Products/Debug-iphonesimulator/libRCTBlob.a /Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Products/Debug-iphonesimulator/libRCTAnimation.a /Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Products/Debug-iphonesimulator/libReact.a /Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Products/Debug-iphonesimulator/libRCTAnimation.a /Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Products/Debug-iphonesimulator/libRCTActionSheet.a /Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Products/Debug-iphonesimulator/libRCTGeolocation.a /Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Products/Debug-iphonesimulator/libRCTImage.a /Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Products/Debug-iphonesimulator/libRCTLinking.a /Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Products/Debug-iphonesimulator/libRCTNetwork.a /Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Products/Debug-iphonesimulator/libRCTSettings.a /Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Products/Debug-iphonesimulator/libRCTText.a /Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Products/Debug-iphonesimulator/libRCTVibration.a /Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Products/Debug-iphonesimulator/libRCTWebSocket.a -lPods-app-rn -Xlinker -dependency_info -Xlinker /Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Intermediates.noindex/app-rn.build/Debug-iphonesimulator/app-rn.build/Objects-normal/x86_64/app-rn_dependency_info.dat -o /Users/cristianleyes/Library/Developer/Xcode/DerivedData/app-rn-frrsxghobzchjqdstvejyhckxroh/Build/Products/Debug-iphonesimulator/app-rn.app/app-rn

ld: library not found for -lPods-app-rn
clang: error: linker command failed with exit code 1 (use -v to see invocation)

But in Build Phases -> Link Binary With Libraries, libPods-app-rn.a is present.

slycoder commented 6 years ago

Looks like it's trying to link a Pod project with the name Pods-app-rn. Did you change the name of your project at some point and omit changing some of the references?

(Check your xcodeproj file)

cristiandley commented 6 years ago

Never changed the name, Not sure where to look at, but this is the basic (noob here)

Display N: app-rn Build I: org.reactjs.native.app-rn

slycoder commented 6 years ago

And are the pods in your workspace? IIRC some people accidentally build the project instead of the workspace where only the latter contains the Pod build phases.

cristiandley commented 6 years ago

Works after setting the subspecs on Podfile

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!

# This will disable all the warnings for all pods.
inhibit_all_warnings!

def general_pods
    pod 'RNVectorIcons', path: '../node_modules/react-native-vector-icons'
    pod 'yoga', path: '../node_modules/react-native/ReactCommon/yoga/Yoga.podspec'
    pod 'React', path: '../node_modules/react-native', :subspecs => [
        'Core',
        'CxxBridge',
        'DevSupport',
        'RCTActionSheet',
        'RCTGeolocation',
        'RCTText',
        'RCTNetwork',
        'RCTWebSocket',
        'RCTNetwork',
        'RCTVibration',
        'RCTSettings',
        'RCTAnimation',
        'RCTLinkingIOS',
        'RCTImage',
    ]

  pod 'react-native-twilio-video-webrtc', path: '../node_modules/react-native-twilio-video-webrtc'

end #def general_pods

target 'app' do
    general_pods
end

target 'appTests' do
    general_pods
end

target 'app-tvOS' do
    general_pods
end

target 'app-tvOSTests' do
    general_pods
end
slycoder commented 6 years ago

Cool, glad to hear that it's working!