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

iOS: Cannot build and run the app after installing RNFBSDK and frameworks #528

Open esbenvb opened 5 years ago

esbenvb commented 5 years ago

🐛 Bug Report

I tried following the guide and chose NOT to use cocoapods. I have downloaded the SDK files and copied them to the "Frameworks" group of the xcode project by dragging in the.framework file for Core, Login and Share. I also added the -ObjC linker flag.

The frameworks are present in "Linked frameworks and libraries" and I also added them to "Embedded binaries"

I both tried with the version 5.0 and 4.4.x if the frameworks. Same result.

On a brand new RN 0.59.8 project it won't even build, but fails at #import<FBSDKShareKit/FBSDKShareKit.h>

On an existing app project based on 0.59.5, it builds but crashes at launch, saying

dyld: Library not loaded: @rpath/Bolts.framework/Bolts
  Referenced from: /Users/esben/Library/Developer/CoreSimulator/Devices/EAC258B3-E4BC-4C3B-AD94-E675CB745A96/data/Containers/Bundle/Application/D4E8EB90-7EE8-4A76-9BDB-87E4507DC64A/XXXXXXX.app/Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit
  Reason: image not found

To Reproduce

react-native init TestProject && cd TestProject && yarn add react-native-fbsdk && react-native link react-native-fbsdk

image image image image

Expected Behavior

Expected the app to build and run

Environment


info 
  React Native Environment Info:
    System:
      OS: macOS 10.14.3
      CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
      Memory: 236.22 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 11.13.0 - /usr/local/bin/node
      Yarn: 1.15.2 - /usr/local/bin/yarn
      npm: 6.7.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
      Android SDK:
        API Levels: 28
        Build Tools: 28.0.3
        System Images: android-25 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 3.4 AI-183.5429.30.34.5452501
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.8 => 0.59.8 

``
gokulkulkarni1987 commented 5 years ago

I keep getting this,

ld: framework not found FBSDKShareKit

Its crazy, I have added in framework search paths, still this error shows.

Tired from two days.

esbenvb commented 5 years ago

I ended up enabling cocoapods for the project and installing the FB SDK using cocoapods. However, that was also kind of a nightmare.

Made a podfile like this:

https://facebook.github.io/react-native/docs/integration-with-existing-apps.html#configuring-cocoapods-dependencies

And then for every build error I added the dependencies from here https://github.com/facebook/react-native/blob/master/React.podspec (this file is not the same as the React.podspec in my node_modules/react-native folder).

But since the docs instruct the developer to skip the pod setup, and manually download and add the frameworks, I think that should be decscribed more detailed, since the current description obviously doesn't work :(

tuledev commented 5 years ago

You can try https://github.com/facebook/react-native-fbsdk/issues/549#issuecomment-503525279

Lloydza commented 5 years ago

@gokulkulkarni1987 did you try going into RCTFBSDK.xcodeproj in the Libraries folder and fixing the Search Path there?

gokulkulkarni1987 commented 5 years ago

@Lloydza I unlinked and relinked all worked..

zicrox commented 5 years ago

I solved my case of "file or lib not found" and without cocoapods, I think in XCode 10.x the typically Frameworks folder (~/Documents/FacebookSDK) was missing because this is out of the project so:

  1. Created a folder Frameworks in ios folder and copy this the FacebookSDK folder.

  2. In Build Phases of "main/react project" go to "Link Binary With Libraries" and add or fix the link of three FacebookSDK libs (FBSDKCoreKit.framework, FBSDKLoginKit.framework, FBSDKShareKit.framework). NOTE: In "Build Phases" there is "Embed Frameworks" a section but I think there is nothing to do here in this case, if there are some FacebookSDK libs links here remove it.

  3. More fixes can be needed:

    1. In Build Settings of "main/react project" go to "Framework Search Paths" and check if you have the FacebookSDK folder, in my case is something like this: "$(PROJECT_DIR)/Frameworks/FacebookSDK" if not add it.
    2. In "RCTFBSDK.xcodeproj" project (is usually in Libraries of "main/react project") in "Frameworks" folder check or fix the link of three FacebookSDK libs.

Environment

    IDE:
      Xcode: 10.1
    npmPackages:
      react: 16.8.6
      react-native: 0.59.9
      react-native-fbsdk: 0.10.1
    FacebookSDK: 5.1.1

Inspired in this solution posted by @SvetoslavSlavov check it, worked for me: https://github.com/facebook/react-native-fbsdk/issues/452#issuecomment-463283195

CodeGains commented 5 years ago

I finally got mine to work after using CocoaPods, see: https://github.com/facebook/react-native-fbsdk/pull/551#issuecomment-506548286