From 2d46dbe6ce962bbdcae5d91afe557b46b6b7cfe4 Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Tue, 7 May 2024 03:06:54 -0700 Subject: [PATCH] Fix HermesExecutorFactory build error (#44423) Summary: https://github.com/facebook/react-native/commit/7af288e5 introduced a breaking change for whoever importing HermesExecutorFactory.h, because the `hermes/inspector-modern/chrome/HermesRuntimeTargetDelegate.h` is not a public header. Also the nested import is not ideal for CocoaPods or use_frameworks. I think HermesRuntimeTargetDelegate could be an implementation detail that hide from header. This PR tries to turn the ownership declaration from std::optional to std::unique_ptr, so that we could hide the concrete type. ## Changelog: [IOS] [FIXED] - Fixed `HermesExecutorFactory.h` build error when importing its private header Pull Request resolved: https://github.com/facebook/react-native/pull/44423 Test Plan: should introduce no breaking change and ci passed Reviewed By: cipolleschi Differential Revision: D57041498 Pulled By: huntie fbshipit-source-id: bfa10c7307458813d99c52313682dd62bea80f19 --- .../ReactCommon/hermes/executor/HermesExecutorFactory.cpp | 5 ++++- .../ReactCommon/hermes/executor/HermesExecutorFactory.h | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/react-native/ReactCommon/hermes/executor/HermesExecutorFactory.cpp b/packages/react-native/ReactCommon/hermes/executor/HermesExecutorFactory.cpp index 8ee40df6785..e7c8886fa07 100644 --- a/packages/react-native/ReactCommon/hermes/executor/HermesExecutorFactory.cpp +++ b/packages/react-native/ReactCommon/hermes/executor/HermesExecutorFactory.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -258,7 +259,9 @@ HermesExecutor::HermesExecutor( jsinspector_modern::RuntimeTargetDelegate& HermesExecutor::getRuntimeTargetDelegate() { if (!targetDelegate_) { - targetDelegate_.emplace(hermesRuntime_); + targetDelegate_ = + std::make_unique( + hermesRuntime_); } return *targetDelegate_; } diff --git a/packages/react-native/ReactCommon/hermes/executor/HermesExecutorFactory.h b/packages/react-native/ReactCommon/hermes/executor/HermesExecutorFactory.h index ea370876d7a..89fce4d04c4 100644 --- a/packages/react-native/ReactCommon/hermes/executor/HermesExecutorFactory.h +++ b/packages/react-native/ReactCommon/hermes/executor/HermesExecutorFactory.h @@ -8,7 +8,6 @@ #pragma once #include -#include #include #include @@ -62,8 +61,7 @@ class HermesExecutor : public JSIExecutor { JSIScopedTimeoutInvoker timeoutInvoker_; std::shared_ptr runtime_; std::shared_ptr hermesRuntime_; - std::optional - targetDelegate_; + std::unique_ptr targetDelegate_; }; } // namespace facebook::react