How Do I Enable Hermes React Native iOS?

Are you trying to enable Hermes in your React Native iOS project? Hermes is a JavaScript engine that can improve the performance of your app by reducing the time it takes for JavaScript code to execute. In this tutorial, we will guide you through the steps required to enable Hermes in your React Native iOS project.

Step 1: Install React Native

Before enabling Hermes, ensure that you have installed React Native on your system. You can do so by following the official installation instructions provided on the React Native website.

Step 2: Install CocoaPods

Next, you need to install CocoaPods, which is a dependency manager for iOS projects. You can install it by running the following command in your terminal:

$ sudo gem install cocoapods

Step 3: Create a New Project

Create a new React Native project using the following command:

$ npx react-native init myProject

This command will create a new project named “myProject” in your current directory.

Step 4: Enable Hermes

To enable Hermes in your project, you need to add it as a dependency and configure Xcode to use it.

  • Add Hermes as a Dependency

Open the “package.json” file in your project directory and add “hermes-engine” as a dependency:

“dependencies”: {
   ..
   “react-native”: “^0.64.2”,
   “hermes-engine”: “^0.8.3”,
   .
}

Save the file and run the following command in your terminal to install the dependency:

$ npm install

  • Configure Xcode

Open your project in Xcode by running the following command:

$ open myProject.xcworkspace

In Xcode, go to the “Build Settings” tab of your Target and find the “Other C Flags” setting. Add the following flag to enable Hermes:

-DENABLE_HERMES=1

Save the changes and close Xcode.

Step 5: Run Your Project

Finally, run your React Native iOS project using the following command:

$ npx react-native run-ios

This command will start a new instance of the iOS simulator and run your app with Hermes enabled.

Congratulations! You have successfully enabled Hermes in your React Native iOS project.

You should notice an improvement in performance when running your app. If you encounter any issues during this process, refer to the official React Native documentation for troubleshooting guidance.