React Native FBSDK file not found on CI

2.3k Views Asked by At

I have installed FBSDKCoreKit, FBSDKLoginKit and FBSDKShareKit by downloading the SDK to ~/Documents/FacebookSDK and then dragging the frameworks in to the frameworks folder in XCode. I checked the option to copy the files if needed so they appear in the project.

I then added the correct framework search path ~/Documents/FacebookSDK

Building locally works fine, however, building on Bitrise (CI) fails with the error:

/Users/vagrant/git/node_modules/react-native-fbsdk/ios/RCTFBSDK/share/RCTFBSDKShareDialog.h:21:9: 'FBSDKShareKit/FBSDKShareKit.h' file not found

The framework search path also contains $(PROJECT_DIR) which should find the frameworks located in appname/Frameworks/ but I cannot seem to fix this not found error.

3

There are 3 best solutions below

2
On BEST ANSWER

See: https://discuss.bitrise.io/t/build-failing-with-file-not-found-fbsdk-in-ios-build/399/11

It seems that you have the FacebookSDK on your Mac at ~/Documents/FacebookSDK, but you don't download it there on bitrise.io, so it's simply not available for your build.

2
On

I was using ZIP Unarchive step in Bitrise with the following path: ~/Documents/FacebookSDK and I was not able to make it work. When I changed the Framework Search Path to ${HOME}/Documents/FacebookSDK I was able to continue my build with success.

0
On

I ran into this problem using BuddyBuild (another CI system), and solved it via the instructions linked on their documentation page here http://docs.buddybuild.com/docs/common-react-native-errors#section-error-fbsdksharekit-fbsdksharekit-h-file-not-found, in particular this section:

error: 'FBSDKShareKit/FBSDKShareKit.h' file not found

This is generally a result of an incorrectly configured repository with regards to the location of FBSDK dependencies. If you take a look at: https://github.com/facebook/react-native-fbsdk/blob/master/ios/RCTFBSDK.xcodeproj/project.pbxproj

You will notice that RCTFBSDK will look for dependencies in one of two locations:

  • ~/Documents/FacebookSDK
  • $(PROJECT_DIR)/../../../ios/Frameworks

The second option is the correct option for continuous integration systems like Buddybuild. In other words, you MUST place your FBSDK dependencies under the "ios/Frameworks" folder in order for it to work on a continuous integration system.

The problem is that as Viktor pointed out the CI system doesn't have a reference to your FacebookSDK folder containing the required Frameworks, so you need to actually copy the Frameworks themselves into your project itself so that everything is contained in your repository. This is necessary because the RCTFBSDK library expects to find the Frameworks that it requires in precisely the folder $PROJECT_ROOT/ios/Frameworks within your project (see the BuddyBuild documentation), and if they're anywhere else it will freak out.

For clarity the steps that I took to get my build working were:

  • Create the folder $PROJECT_ROOT/ios/Frameworks in my project (Frameworks may not already exist)
  • Copy the Facebook framework files from ~/Documents/FacebookSDK into this new folder
  • Reference the Frameworks in Xcode per the installation instructions on the fbsdk Github page.

Hope that this helps any future readers.