I've been trying to get react-native-fbsdk
to work with CocoaPods, since I much prefer fetching the Facebook SDK as part of the pod install
process, but I haven't had much luck. I'm aware that I can react-native link
the npm library and manually download and add the necessary frameworks, but this seems rather silly when I have a perfectly good package manager at my disposal.
Judging by the documentation it should be fairly straight forward - just add the necessary pods to the Podfile
, right? But no matter what I try the native FBSDK modules never seem to be included. I've tried a whole host of different Podfile
s, some with use_framework!
and pod 'Bolts'
, some with just pod 'FBSDKCoreKit'
. This is the one I'm currently on:
target 'FacebookPods' do
pod 'FBSDKCoreKit'
pod 'FBSDKShareKit'
pod 'FBSDKLoginKit'
target 'FacebookPodsTests' do
inherit! :search_paths
end
end
But when I run my test app and try to do anything with the react-native-fbsdk
module I get errors complaining about various native modules being undefined. Here's my index.ios.js
file, trying to access the LoginManager
:
import React, {Component} from "react"
import {AppRegistry, Text} from "react-native"
import {LoginManager} from "react-native-fbsdk"
export default class FacebookPods extends Component {
componentWillMount() {
LoginManager.logInWithReadPermissions(["email"])
.then(() => console.log("Success!"))
.catch((err) => console.log("Failure!", err))
}
render() {
return <Text>Hello World</Text>
}
}
AppRegistry.registerComponent("FacebookPods", () => FacebookPods)
But this throws the error undefined is not an object (evaluating 'LoginManager.logInWithReadPermissions'
in FBLoginManager.js
. Further inspection of NativeModules shows that no native FBSDK modules are included at all. I also get the following warnings at launch:
2017-07-13 19:50:19.006 [warn][tid:com.facebook.react.JavaScript] Warning: Native component for "RCTFBLikeView" does not exist
2017-07-13 19:50:19.007 [warn][tid:com.facebook.react.JavaScript] Warning: Native component for "RCTFBLoginButton" does not exist
2017-07-13 19:50:19.008 [warn][tid:com.facebook.react.JavaScript] Warning: Native component for "RCTFBSendButton" does not exist
2017-07-13 19:50:19.009 [warn][tid:com.facebook.react.JavaScript] Warning: Native component for "RCTFBShareButton" does not exist
So yea, I'm at a complete loss. In my mind, simply adding the pods ought to be enough to include the frameworks. I've scoured the interwebs for any additional steps that I might've missed, but there isn't much, save for a few issues on the react-native-fbsdk
project that have since then been removed.