Manual linking guide

This documentation is for the original BugSnag React Native SDK. We recommend upgrading to the React Native package that is now part of the Universal JavaScript SDK using our Upgrade guide. Documentation for the latest release can be found here.

While the default integration guide is suitable for apps using React Native as the primary development layer, it may not be suitable for all applications. This guide details the manual steps for linking BugSnag with native apps and adopting React Native incrementally.

If your project is ineligible for using react-native link, you can complete the following steps to create a fully linked React Native project.

Android configuration

  1. Add the library to android/app/build.gradle:
   dependencies {
     implementation project(':bugsnag-react-native')
   }
  1. Link the library in android/settings.gradle:
   include ':app'
   // must be after `include ':app'`

   include ':bugsnag-react-native'
   project(':bugsnag-react-native').projectDir = new File(rootProject.projectDir,
                                                          '../node_modules/bugsnag-react-native/android')
  1. Add the library package to native packages listed in android/{...}/MainApplication.java:
   import com.bugsnag.BugsnagReactNative;

   // ...

   protected List<ReactPackage> getPackages() {
       return Arrays.<ReactPackage>asList(
           new MainReactPackage(), BugsnagReactNative.getPackage()
       );
   }
  1. Specify Google’s maven repository in build.gradle:
   allprojects {
       repositories {
           maven { url 'https://maven.google.com' }
       }
   }

iOS configuration

  1. Open ios/[project].xcodeproj in Xcode and, using Finder, drag node_modules/bugsnag-react-native/cocoa/BugsnagReactNative.xcodeproj into the Libraries group, alongside React Native and other dependencies.
  2. In Xcode, select your project in the Project Navigator pane, select the Build Phases tab, and add libz.tbd and libBugsnagReactNative.a to Link Binary With Libraries.
  3. In Xcode, select the Build Settings tab, and append the following to the “Header Search Paths” field: $(inherited) $(SRCROOT)/../node_modules/bugsnag-react-native/cocoa/**

Next steps

  • Learn how to report handled errors, attach custom diagnostic data, and send user information with the integration guide
  • Further customize your integration using the configuration options.
  • Get support for your questions and feature requests