From 2a21d5a28ea0ee0a1a332ce26b50b7fd61ac89a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Wed, 5 Oct 2022 09:19:05 -0700 Subject: [PATCH] Exclude Hermes debugger in release builds 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 --- ReactCommon/hermes/React-hermes.podspec | 11 +++++++---- sdks/hermes-engine/hermes-engine.podspec | 12 +++++------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/ReactCommon/hermes/React-hermes.podspec b/ReactCommon/hermes/React-hermes.podspec index d08e5b68a7cab7..83d64d3a81978f 100644 --- a/ReactCommon/hermes/React-hermes.podspec +++ b/ReactCommon/hermes/React-hermes.podspec @@ -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'] @@ -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 @@ -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 diff --git a/sdks/hermes-engine/hermes-engine.podspec b/sdks/hermes-engine/hermes-engine.podspec index 68014a97f88b2b..fd108231491024 100644 --- a/sdks/hermes-engine/hermes-engine.podspec +++ b/sdks/hermes-engine/hermes-engine.podspec @@ -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 @@ -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