facebookarchive / react-native-fbsdk

A React Native wrapper around the Facebook SDKs for Android and iOS. Provides access to Facebook login, sharing, graph requests, app events etc.
https://developers.facebook.com/docs/react-native
Other
2.99k stars 908 forks source link

Could we get an updated/working/reproducable setup guide for IOS? #549

Open ElixirMike opened 5 years ago

ElixirMike commented 5 years ago

I have spent the entire day trying to implement sign-in with Facebook on Android and IOS. After about 1 hour, I was able to work through all the issues on android, many of which are not documented in the installation guide, but got it working. I then started working on IOS.

7 hours later, I still can't get this to work. I, of course, have followed the provided installation instructions to no avail. After searching /reading /hacking, trying different SDK verions in the Pod files, I at least have it to a point where it builds and when I click on the "Login" button, it doesn't throw the "null LoginManager" error.

I am now stuck at the point where it just throws an error when I click to login of "Login failed". There are multiple threads on this issue, ranging from changing the pod SDK versions back to 4.38, or some say 4.40. Others say to remove the pod reference to "react-native-fbsdK" and include "FacebookSDK" . And there is things about enabling key-chain sharing, etc.

But after trying all of these...I still cannot get this simple Login button to work. Would it be possible to have a defined, reproducible guide, listing which specific versions of the SDK's, react-native-FBSDK and anything else required to actually get a working version? A detailed step-by-step that covers everything, including hacks required, etc.

If we can start at something that can be reproduced and working, it will make it much easier to troubleshoot our existing projects and hopefully find a solution. Thx.

ElixirMike commented 5 years ago

Just to close the loop on this...after several more efforts, I got this working. I'd be happy to write up the detailed instructions if anyone wants them, but here is the gist.

I went back and did a clean react-native init fbtest to have a clean slate and then followed the instructions from here: https://developers.facebook.com/docs/react-native/getting-started

Luckily, with a clean install, everything just worked, I had it up/running in 30 minutes. I then reviewed the app and compared it to mine. Here are the discrepancies that through me off and lead me down many rabbit holes.

  1. In the clean install, there was no pod file created. The ios_Setup.js file they have does the copying of the SDK files. However, in my real project, I had a pod file that I was using for other projects like Firebase, etc. When you run the the react-native link react-native-fbsdk, it adds a pod line into your pod file. This was the first flag, because it doesn't work with this in the file. If you google the issue, it sends you down the path of adding the library's to the pod file, trying different versions, etc. Bad move.

So, first step was to remove the reference in the pod file...it should have no references to any of the SDK files.

  1. Next (ensure the facebook SDK's are downloaded into the ~/Documents/FacebookSDK folder. Extract the contents of the zip into the folder.

  2. After this, I tried a build and got some random compile error. My project is much bigger than the default init project created. After digging into this for an hour or so, I found it had to do with hitting some file size open limit. I found this article that shows how to change your limits on a MAC http://blog.mact.me/2014/10/22/yosemite-upgrade-changes-open-file-limit

  3. I tried to build again, and this time it built, but I was back to the error when clicking on the Login button of "null not valid " in referen to the loginManager . I had seen this error before.

  4. Finally, to resolve this, I followed the instructions someone posted about add the the RCTFBSDK.xcodeproj to the project's libary and adding the lib.a file into "link bindings" .

After the above, and following the original instructions, It worked. Wasted a good day on that...but it seems to be the norm when doing react-native development with 3rd party libs

Happy to share more if anyone needs more details.

redcancode commented 5 years ago

I'm sorry you had so much frustration with this library. There are some issues right now. If you look at the latest pull requests that have been merged or opened you will see that a new release has been forming which will solve many of the issues. I believe that release will bring an updated documentation as well.

rogerkerse commented 5 years ago

the current master branch doesnt work on ios at all. Gives an error

error: Build input file cannot be found: '/../app/node_modules/react-native-fbsdk/iOS/RCTFBSDK/core/RCTFBSDKInitializer.m'

And if I look at the code, there is no such file indeed commited to master. Should it be there?

superandrew213 commented 5 years ago

RCTFBSDKInitializer.m was removed here https://github.com/facebook/react-native-fbsdk/commit/7af350e4354438f67b5d4aaa6e7a27c8a4f84b3a.

You can just add it back and it will work.

rogerkerse commented 5 years ago

@superandrew213 thanks, but it is not a sustainable solution :), everyone is gonna have this problem

superandrew213 commented 5 years ago

I am only giving you a temp workaround. You can have a look at the repo to find out why it was removed to investigate it further and make a PR.

@janicduplessis is RCTFBSDKInitializer still required somewhere for iOS.

tuledev commented 5 years ago

After hours, I can make it work with logInWithReadPermissions:

  1. yarn add react-native-fbsdk
  2. cd to node_modules/react-native-fksdk/ios. Drop drag RCTFBSDK.xcodeproj to iOS xcworkspace.
  3. Add libRCTFBSDK.a to Link Binary With Libraries in Build Phases.
  4. Download fa sdk .framework from https://developers.facebook.com/docs/ios/downloads/
  5. Drop drag FBSDKCoreKit.framework, FBSDKLoginKit.framework, FBSDKShareKit.framework to Frameworks folder. Check if they are in Link Binary With Libraries
  6. Drop drag FBSDKCoreKit.framework, FBSDKLoginKit.framework, FBSDKShareKit.framework to Frameworks folder of RCTFBSDK.xcodeproj (remove the old ones)
  7. Build and it works
superandrew213 commented 5 years ago

@tuledev logInWithReadPermissions and logInWithWritePermissions have been replaced with logInWithPermissions in the last release.

tuledev commented 5 years ago

@superandrew213 thank I noted.

joshyg commented 5 years ago

I am also having troubles with react-native-fbsdk. I have gone through all of the steps outlined by @ElixirMike , but now I see the following when building RCTFBSDK.xcodeproj:

Showing Recent Issues

RCTFBSDK/core/RCTConvert+FBSDKAccessToken.m:28:13: No visible @interface for 'FBSDKAccessToken' declares the selector 'initWithTokenString:permissions:declinedPermissions:expiredPermissions:appID:userID:expirationDate:refreshDate:dataAccessExpirationDate:'

It almost seems as if the project has the wrong header search paths. Is this a known issue as well?

joshyg commented 5 years ago

Ok, as a follow up to my last comment, it seems like I was using an old versiuon of ios_setup.js, as the url given here returns 404:

https://developers.facebook.com/docs/react-native/configure-ios

So this explains why my frameworks and RCTFBSDK were out of sync, however it is not clear how to download the latest FacebookSDK without cocoapods. This page:

https://developers.facebook.com/docs/ios/downloads

leads me here:

https://github.com/facebook/facebook-objc-sdk?fbclid=IwAR0NPvjjD6qUYnl8iiy1gNxem9aT2dzxpXJaReY0CEL7Fw1dpnkNpb76Gsc

which directs me here:

https://developers.facebook.com/docs/ios

which leads here:

https://developers.facebook.com/docs/ios/componentsdks

whidch leads right back to the github page.

How can I download the lates sdk without cocoapods?

afestein commented 5 years ago

https://github.com/facebook/facebook-objc-sdk/releases

CodeGains commented 5 years ago

Also stuck at the step trying to download ios_setup.js

soleh23 commented 5 years ago

Also stuck at the step trying to download ios_setup.js

same

CodeGains commented 5 years ago

Figured it out, don't follow these instructions. See: https://github.com/facebook/react-native-fbsdk/pull/551#issuecomment-50654828

Basically, just follow the instructions on the github page, except ignore the part where it says to skip step 2. You need to use CocoaPods for the install.

wbw20 commented 5 years ago

Thanks to the maintainers for their hard work on this project.

Seems like we are all seeing these issues:

https://developers.facebook.com/docs/ios Screen Shot 2019-07-09 at 5 14 25 PM

https://developers.facebook.com/docs/ios/componentsdks Screen Shot 2019-07-09 at 5 13 01 PM

https://github.com/facebook/facebook-objc-sdk Screen Shot 2019-07-09 at 5 12 41 PM

When I used ios_setup.js last year to set this up at my previous job it only took a few minutes. Can we please bring back this convenience script?

bernhardt1 commented 5 years ago

Has anyone gotten this API working on the latest version without cocoapods?

The Facebook documentation says to switch to cocoapods if you installed manually before but I would prefer not to: https://developers.facebook.com/docs/app-events/upgrade-guide/

I followed this (https://github.com/facebook/react-native-fbsdk/issues/574) and other issues to get the ios app to build without using cocoapods.

Now there is issues with the API functionality - as described here: https://github.com/facebook/react-native-fbsdk/issues/583

ajkhatibi commented 4 years ago

has any every had an error on IOS about RCTFBSDKZGraphRequestConnectionContainer.m? I'm getting errors like these when I link the react-native-sdk library to my project. I'm using version 0.10.3 and my react native version is 0.57.8

Screen Shot 2019-12-02 at 10 07 29 AM