React Native Troubleshooting

Important

Visual Studio App Center is scheduled for retirement on March 31, 2025. While you can continue to use Visual Studio App Center until it is fully retired, there are several recommended alternatives that you may consider migrating to.

Learn more about support timelines and alternatives.

My React Native build fails with: 'FBSDKCoreKit/FBSDKCoreKit.h' file not found

This error is usually because the Facebook SDK expects that it's installed in the user's home directory, which can be problematic for hosted builds. To work around this requirement, follow these steps:

  1. Check in the FacebookSDK to your repository. It can go anywhere, but the script below assumes it's added to <repo-root>/vendor/FacebookSDK.

  2. Add an npm preinstall script to your package.json:

"scripts": {
    ...
    "preinstall": "./npmpreinstall.sh"
}
  1. npmpreinstall.sh symlinks ~/Documents/FacebookSDK to your repo with the following code:
#!/bin/sh
if [ ! -L ~/Documents/FacebookSDK ]; then
    echo 'Symlinking ~/Documents/FacebookSDK to Facebook SDK in repo'
    ln -s $(cd ./vendor/FacebookSDK; pwd) ~/Documents/FacebookSDK
fi
  1. Make npmpreinstall.sh executable:
chmod u+x npmpreinstall.sh

My React Native build fails with "FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory"

The issue can be resolved by allocating more memory with the --max-old-space-size flag.

On Android, add the following to the project's build.gradle file:

project.ext.react = [
    nodeExecutableAndArgs: ["node", "--max_old_space_size=8192"]
]

On iOS, in Xcode, select your target and go to the Build Phases tab, in the section Bundle React Native code and images, add the flag to the shell script:

export NODE_BINARY="'node --max_old_space_size=8192'
../node_modules/react-native/packager/react-native-xcode.sh"