Skip to content

Commit

Permalink
Exclude Hermes debugger in release builds
Browse files Browse the repository at this point in the history
Summary:
Fixes Xcode release builds when Hermes is enabled.

The Hermes debugger is loaded by the Hermes executor only if HERMES_ENABLE_DEBUGGER is defined. The hermes-engine Pod would set `HERMES_ENABLE_DEBUGGER=0` in release builds, but of course this would satisfy the HERMES_ENABLE_DEBUGGER ifdef check, leading to build time issues due to missing `hermes::debugger` symbols.

Now, both the `hermes-engine` and `React-hermes` pods only set `HERMES_ENABLE_DEBUGGER=1` in debug builds. No gcc preprocessor definition is added by these pods in release builds.

Changelog:
[iOS] [Changed] - Do not load Hermes inspector in release builds

Reviewed By: cipolleschi

Differential Revision: D40077503

fbshipit-source-id: dd9ce148e8521fc4e43e47e90f29ba8f7c9b7e4a
  • Loading branch information
hramos authored and facebook-github-bot committed Oct 5, 2022
1 parent aa5d43f commit 2a21d5a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
11 changes: 7 additions & 4 deletions ReactCommon/hermes/React-hermes.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

require "json"

# Whether Hermes is built for Release or Debug is determined by the PRODUCTION envvar.
build_type = ENV['PRODUCTION'] == "1" ? :release : :debug

# package.json
package = JSON.parse(File.read(File.join(__dir__, "..", "..", "package.json")))
version = package['version']

Expand All @@ -25,7 +29,7 @@ Pod::Spec.new do |s|
s.version = version
s.summary = "-" # TODO
s.homepage = "https://reactnative.dev/"
s.license = package["license"]
s.license = package['license']
s.author = "Facebook, Inc. and its affiliates"
s.platforms = { :osx => "10.14", :ios => "12.4" }
s.source = source
Expand All @@ -36,9 +40,8 @@ Pod::Spec.new do |s|
s.public_header_files = "executor/HermesExecutorFactory.h"
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
s.pod_target_xcconfig = {
"HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/..\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/libevent/include\"",
"GCC_PREPROCESSOR_DEFINITIONS" => "HERMES_ENABLE_DEBUGGER=1",
}
"HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/..\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/libevent/include\""
}.merge!(build_type == :debug ? { "GCC_PREPROCESSOR_DEFINITIONS" => "HERMES_ENABLE_DEBUGGER=1" } : {})
s.header_dir = "reacthermes"
s.dependency "React-cxxreact", version
s.dependency "React-jsi", version
Expand Down
12 changes: 5 additions & 7 deletions sdks/hermes-engine/hermes-engine.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ react_native_path = File.join(__dir__, "..", "..")
build_type = ENV['PRODUCTION'] == "1" ? :release : :debug

# package.json
package_file = File.join(react_native_path, "package.json")
package = JSON.parse(File.read(package_file))
package = JSON.parse(File.read(File.join(react_native_path, "package.json")))
version = package['version']

# sdks/.hermesversion
Expand Down Expand Up @@ -59,11 +58,10 @@ Pod::Spec.new do |spec|
spec.ios.vendored_frameworks = "destroot/Library/Frameworks/universal/hermes.xcframework"
spec.osx.vendored_frameworks = "destroot/Library/Frameworks/macosx/hermes.framework"

spec.xcconfig = {
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
"CLANG_CXX_LIBRARY" => "compiler-default",
"GCC_PREPROCESSOR_DEFINITIONS" => "HERMES_ENABLE_DEBUGGER=#{build_type == :debug ? "1" : "0"}"
}
spec.xcconfig = {
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
"CLANG_CXX_LIBRARY" => "compiler-default"
}.merge!(build_type == :debug ? { "GCC_PREPROCESSOR_DEFINITIONS" => "HERMES_ENABLE_DEBUGGER=1" } : {})

if source[:git] then
ENV['REACT_NATIVE_PATH'] = react_native_path
Expand Down

0 comments on commit 2a21d5a

Please sign in to comment.