Skip to content

Commit

Permalink
Fix HermesExecutorFactory build error (#44423)
Browse files Browse the repository at this point in the history
Summary:
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: #44423

Test Plan: should introduce no breaking change and ci passed

Reviewed By: cipolleschi

Differential Revision: D57041498

Pulled By: huntie

fbshipit-source-id: bfa10c7307458813d99c52313682dd62bea80f19
  • Loading branch information
Kudo authored and facebook-github-bot committed May 7, 2024
1 parent 362abb9 commit 2d46dbe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <jsi/decorator.h>
#include <jsinspector-modern/InspectorFlags.h>

#include <hermes/inspector-modern/chrome/HermesRuntimeTargetDelegate.h>
#include <hermes/inspector-modern/chrome/Registration.h>
#include <hermes/inspector/RuntimeAdapter.h>

Expand Down Expand Up @@ -258,7 +259,9 @@ HermesExecutor::HermesExecutor(
jsinspector_modern::RuntimeTargetDelegate&
HermesExecutor::getRuntimeTargetDelegate() {
if (!targetDelegate_) {
targetDelegate_.emplace(hermesRuntime_);
targetDelegate_ =
std::make_unique<jsinspector_modern::HermesRuntimeTargetDelegate>(
hermesRuntime_);
}
return *targetDelegate_;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#pragma once

#include <hermes/hermes.h>
#include <hermes/inspector-modern/chrome/HermesRuntimeTargetDelegate.h>
#include <jsireact/JSIExecutor.h>
#include <utility>

Expand Down Expand Up @@ -62,8 +61,7 @@ class HermesExecutor : public JSIExecutor {
JSIScopedTimeoutInvoker timeoutInvoker_;
std::shared_ptr<jsi::Runtime> runtime_;
std::shared_ptr<hermes::HermesRuntime> hermesRuntime_;
std::optional<jsinspector_modern::HermesRuntimeTargetDelegate>
targetDelegate_;
std::unique_ptr<jsinspector_modern::RuntimeTargetDelegate> targetDelegate_;
};

} // namespace facebook::react

0 comments on commit 2d46dbe

Please sign in to comment.