Skip to main content

Adding the React Native Embrace SDK

Add the JavaScript library

Use Yarn or NPM to install the NPM module.

yarn add @embrace-io/react-native
npm install @embrace-io/react-native --save
info

If you are using a yarn workspace, you must run the command at the react-native application folder level or modify package.json manually. Do not run this on your yarn workspace root.

Adding the SDK

Setup Script

The JavaScript Embrace SDK ships with a setup script to modify the files in your project to add the native dependencies. The setup scripts can be found in your node_modules folder at node_modules/@embrace-io/dist/scripts/setup

Run the setup script

node node_modules/@embrace-io/react-native/lib/scripts/setup/installAndroid.js
node node_modules/@embrace-io/react-native/lib/scripts/setup/installIos.js
Clean Up Embrace implementation

If you need to clean up an Embrace implementation added manually or by our scripts you can use our uninstall script

node node_modules/@embrace-io/react-native/lib/scripts/setup/uninstall.js

You can use git to see the changes that the script made.

git diff

Compare the changes to the Manual Setup step to verify the changes were made correctly.

Manually

You'll need to add an Embrace-Info.plist file at the root of the iOS project.

  1. Create a file called Embrace-Info.plist with the following content.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>API_KEY</key>
<string>{API_KEY}</string>
<key>CRASH_REPORT_ENABLED</key>
<true/>
</dict>
</plist>
Note for iOS

If you'd like to use Embrace's internal crash reporter, set the CRASH_REPORT_ENABLED field to true in the Embrace-Info.plist file that you created earlier (as described in the Adding the Embrace SDK page). If you're using Crashlytics, set this value to false.

  1. Identify your root iOS Project.
  1. Right click on that project and select Add Files to YOUR_PROJECT.
  1. Select Embrace-Info.plist and click on Add. Do not forget to select which Targets you are using.
  1. Check if the file appears inside YOUR_PROJECT.

React Native Version < 0.60

If you're on React Native version 0.60 and above, you can use Autolinking to set up the native modules.

Configure your PodFile to add Embrace. (RN Versions < 0.6)

target 'MyApp' do
# ...

pod 'EmbraceIO'
pod 'RNEmbrace', :path => '../node_modules/@embrace-io/react-native'
end

Then, install the pod.

cd ios && pod install --repo-update

There's a little more configuration we have to do to set up the uploading of symbol files. You'll be learning about that next.