facebook / hermes

A JavaScript engine optimized for running React Native.
https://hermesengine.dev/
MIT License
9.91k stars 641 forks source link

Building Hermes in Debug mode for RN apps on iOS #656

Closed ergawy closed 4 weeks ago

ergawy commented 2 years ago

Hello,

Thanks for the cool project.

I am trying to understand Hermes in a bit deeper detail. In particular, I would like to understand how the VM loads an interprets the bytecode at runtime.

For that, what I would like to do is to:

  1. Build Hermes in Debug mode.
  2. Package it in a sample iOS app.
  3. Step through the code.

I found this guide on how to use a custom build of Hermes in React Native app for Android. With your help I would be happy to write a document on how to build Hermes in Debug mode and package it in an iOS app. Can someone give me some pointers on how to do so properly?

neildhar commented 2 years ago

Hi @ergawy, it may be helpful to take a look at how our CI builds the cocoapod to build a debug version for local development:

  1. Calls build-ios-framework.sh here.
  2. Internally, that calls build-apple-framework.sh which performs the build itself here.
  3. Observe that the build takes a $BUILD_TYPE, which is set to debug when the DEBUG environment variable is present. (here).
  4. Everything gets placed in a folder called destroot, which you should be able to just copy over to replace the version of destroot currently in Pods/hermes-engine in your project.
tmikov commented 2 years ago

@ergawy if you want to understand how Hermes works, I recommend debugging a desktop version, specifically the hvm executable. It literally takes nothing more than opening the root CMakeLists.txt with CLion and running it. There is no need to complicate things with an iOS version.