Log in Users With Facebook in React Native

Recently there’s been a lot of reports from users saying that the overall installation process of installing fbsdk is rather complicated, especially given the fact it does not yet work with rnpm.

There are two main reasons that make fbsdk incompatible at this point:

  • It ships with multiple native packages inside a single npm package. That issue has been raised by the community quite a few weeks ago, but since it was only fbsdk that shipped that way, we have marked it as a community responsibility as it sounded like a very specific use-case,
  • It has been set up with CocoaPods in mind, meaning that it does not work when linked the standard way, as featured in React Native docs. The reason for that is the lack of relative header search paths specified in the xcodeproj.

Today, I have spent more than 30 minutes with Mateusz Zatorski setting it up in one of our projects and as a result — I have decided to write a step-by-step guide that, hopefully, will enable you to get it installed without too much trouble. So, let’s get started!

In order to follow the next steps, you will need to have CocoaPodsinstalled. If you haven’t done so yet, you can follow the official installation instructions.

If you encounter any problems during this step, contact us and we‘ll see what we can do to help.

Step 1: Installing fbsdk

First thing we will have to do is install the fbsdk from npm registry. You can do this by running the following command from within your project folder:

$ npm install react-native-fbsdk --save
view raw fbsdk hosted with ❤ by GitHub

Step 2: Setting up our podfile

Once this installation has completed, we’ll need to integrate CocoaPods into our project. This gives us the ability to add fbsdk and any other native libraries that we may need in the future.

You can do so with the following command:

$ cd ./ios && pod init
view raw cocoa_pods hosted with ❤ by GitHub

As a result, we should now have an empty Podfile in the ios folder.

Step 3: Adding pods

Open up the Podfile with your editor of choice, and you should see the following:

adding pods

There should be two targets, one is your main target (your app, similar to dependencies) and the second one is your tests (similar to devDependencies).

As you may be guessing, we are going to add fbsdk to the app dependencies as it’s the core functionality of our app.

After adding fbsdk, your Podfile should look like this:

podfile

Don’t save and leave your editor just yet — we will have to do one more thing in the next step.

Step 4: Adding more pods

Personally, this is the most confusing step in this entire guide. We have to add React Native to Podfile itself. You may be wondering why that’s needed as you already have it inside Libraries group (React.xcodeprojand friends).

The answer is simpler than you may think.

CocoaPods, simply said, is similar to npm 2 — fbsdk defines peerDependency on React Native. Since React Native itself has only been added to our xcodeproj, Cocoapods has no knowledge that it exist. As a result, it will implicitly install React from its own registry — that is stuck on 0.11 since the core team has stopped publishing it since then.

Thankfully, the version we download from the npm registry contains a local podspec (think package.json) we can use to tell CocoaPods that we have React Native installed there.

After adding React Native, your Podfile should look similar to the this:

after adding React Native

Note: Some packages like react-native-vector-icons also have their podspec files. If you decide to include these packages that way, don’t forget to also clean them up from `Libraries` as described in next step.

Step 5: Cleaning up libraries

In the previous step we have added almost all the packages from React Native, including Push Notifications (RCTPushNotifications) and Linking (RCTLinkingIOS).

We now have them defined again in the Libraries group as well:

libraries group

In this step, you will have to do two things:

  • go to Libraries group and remove all xcodeproj references that you have in your Podfile (select file, click backspace and select “remove references” option)
removing reference
  • go to Podfile and remove anything extraneous (for example, if you’ve never used push notifications, you can safely get rid of it).
removing

Once that’s done, close Xcode and you should finally be able to install all the things with:

cd ./ios && pod install

Give it a minute or two to fetch all the things.

When it completes, you should get two warnings about linker flags (don’t worry, we will fix them in the next step) and a new file: xcworkspace.

xcworkspace

From now on, every time you open up your project with Xcode, you will need to choose the xcworkspace file instead of the xcodeproj file.

Tip: Consider adding the following to your package.json.

package json
Every time you run `npm install`, CocoaPods will fetch its dependencies as well

Step 6: Fixing linker warnings

The project created by default with react-native init does not have an $(inherited) flag in your Linker Flags. That will result in tons of errors when compiling your project. If the error message you get says that no symbols were found for the current architecture, chances are you need to redo this step.

To fix this, simply go to Build of your project, find Other Linker Flags and add $(inherited) so that the final list looks like on this picture below:

Linker flags
As you can see, the value has a list of flags inferred from the Pods project instead of $(inherited) value

Note: Every time you run react-native upgrade, you may need to repeat this step. Pay attention to the `git diff` after doing the upgrade.

Step 7: Clean up the project

Before we finally hit run — we have to go to Product -> Clean. This will clean the cache and any artifacts left from previous builds.

clean up the project
If you want, you can also use the CMD + SHIFT + K shortcut

Step 8: Follow FBSDK instructions

The fbsdk React Native package installs the iOS FacebookSDKautomatically. However, there are still two things you have to do that are nicely described in the official docs (skip step 1 and 2 as we’ve already done them) and the guide for developers.

After you’ve followed the above instructions, you should have the following settings in your Info.plist:

info plist 1

and

info plist 2

and a bunch of methods added to your AppDelegate.m

//
// SimpleAppSnapshotTests.m
// SimpleAppSnapshotTests
//
// Created by Michał Grabowski on 30/04/16.
// Copyright © 2016 Facebook. All rights reserved.
//
#import <XCTest/XCTest.h>
@interface SimpleAppSnapshotTests : XCTestCase
@end
@implementation SimpleAppSnapshotTests
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testExample {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
- (void)testPerformanceExample {
// This is an example of a performance test case.
[self measureBlock:^{
// Put the code you want to measure the time of here.
}];
}
@end

Things added by me following FBSDK docs were commented with `// Added by FBSDK`

Note: If the Facebook app doesn’t return back to your app after a successful authentication — you might need to make sure you’ve done all these steps.

Step 9: Run the app

Now — you can just hit Run from within Xcode and hopefully your React Native login works flawlessly!

run the app
Make sure your “TestApp” is selected in place of “UIExplorer”

Recap

Congratulations on getting to the end of this long arduous tutorial! We’re aware that there are simply too many steps to setup such a simple thing and are working on making it much nicer.

If you have some ideas to share, please leave a comment or visit rnpm/rnpm#144and let us know what you think. On a positive note — you now know how to use CocoaPods which effectively means you can install other SDKs without copying & pasting them to your repository.

Big thanks to Mateusz Zatorski for helping me with the list of steps required and to Dave Sibiski for proofreading it so quickly!

Insights

Learn more about React Native

cover

Aug 4Podcast

VisionCamera V5 With Marc Rousavy

Marc Rousavy joins Mike Grabowski to unpack VisionCamera v5, Nitro Modules, the constraints API, migration work, and what changed for React Native camera apps.

cover

Jul 1Podcast

Redraw for Effects Beyond Skia

William Candillon talks about where Redraw fits next to Skia, from physics-based rendering to camera effects, AR, and new UI patterns.

cover

Jun 29Article

Less Boilerplate, More Type Safety: React Navigation 8's Typed Hooks

React Navigation 8 improves typed hooks with screen-aware types, less boilerplate, and fewer unsafe casts in shared UI and nested navigators.

cover

Apr 30Live Stream

Build a React Native App With the TanStack Stack

Join Callstack’s live stream on building a React Native app from the ground up using the TanStack toolbelt.

cover

Apr 28Article

React Native production lessons from React Universe Meetup x Zalando

Lessons from React Universe Meetup x Zalando on React Native in production, covering brownfield performance, feed video, native API access, and on-device AI.

cover

Apr 23Talk

Shipping iOS Live Activities with React: The Voltra Story

How Voltra enables Live Activities and Dynamic Island views using React without writing Swift. A deep dive into iOS constraints and architecture.

cover

Apr 16Live Stream

React Native 0.85: Animation Backend and Key Updates

A recap of React Native 0.85, covering the new animation backend, DevTools improvements, and ecosystem takeaways.

cover

Mar 5Article

Keeping Screens Visible With <Activity mode="hidden">

A cross‑platform workaround to keep screens visible while <Activity mode="hidden"> unmounts effects on inactive screens by setting mode="hidden".

cover

Feb 25Article

React Native Monorepo With pnpm Workspaces

Set up a React Native monorepo with pnpm workspaces for mobile and Next.js web, including Metro fixes, hoisted node-linker, and shared packages.

cover

Feb 18Article

A Practical Guide to React Native Monorepo With Yarn Workspaces

Learn how to set up a React Native monorepo with Yarn workspaces for mobile and web, including Metro, Gradle, and shared packages.

cover

Feb 17Podcast

From Teddy Bears to Voice Agents: Kraen Hansen on Voice AI, Local-First & App Security

What happens when you combine voice agents and teddy bears? A hands-on look at local-first systems, voice AI, and security lessons from poking real apps.

cover

Jan 28Article

Bringing CSS Clipping to React Native

A deep look at how a single CSS feature moves through React Native’s New Architecture, from JavaScript styles to native rendering on iOS and Android.

cover

Mar 19Tutorial

The Hard Way vs. The React Native AI SDK Way: Stop Writing Custom Modules for Every Model

Learn how React Native AI uses a unified provider model to switch between cloud and on-device LLMs without rewriting application logic, enabling reliable AI experiences online and offline.

cover

Mar 12Tutorial

Build Smarter Apps: Tool Calling & AI Orchestration Explained

Learn how on-device models in React Native can call tools, interact with external APIs, and return structured outputs you can use directly in application logic.

cover

Mar 5Tutorial

MLC LLM + React Native: On-Device AI Without the Pain

Learn how to run third-party on-device LLMs in React Native using MLC LLM. Choose your models, run them efficiently across platforms, and keep a unified JavaScript API with React Native AI.

cover

Feb 24Tutorial

Intelligent Fallbacks with Apple Intelligence in React Native

Learn how to use Apple’s built-in Foundation Models in React Native apps, reduce memory usage, and enable fast, fully on-device AI with React Native AI Apple.

cover

Feb 10Tutorial

What Is the React Native AI SDK? A Complete Intro & Quickstart

Learn why on-device AI matters for React Native apps, how local LLMs behave offline, and what problems React Native AI is designed to solve from day one.

cover

Jan 29Tutorial

Implementing an Android TurboModule with Kotlin

Learn how to implement a React Native TurboModule on Android, from the TypeScript spec and Codegen to the Kotlin implementation and package registration.

cover

Jan 19Tutorial

Working with Different Threads in Swift TurboModules

Learn how JavaScript, native module, background, and main threads interact in React Native TurboModules, and how to use GCD queues to run async work safely in Swift.

cover

Jan 9Tutorial

How to Add Type-Safe Constants to Swift TurboModules

Learn how to expose typed, immutable constants from a Swift TurboModule using Codegen, and get full end-to-end type safety between native and JavaScript.

cover

Dec 30Tutorial

Adding Event Emitters to Your TurboModule in Swift

Learn how to emit native events from a Swift TurboModule and subscribe to them in JavaScript, including proper memory management and Codegen integration.

cover

Dec 22Tutorial

Writing Your First TurboModule in Swift

Learn how to build a fully working TurboModule in Swift, integrate it with Codegen, and bridge it through Objective‑C inside an Expo app.