Skip to content

Commit 6c907ee

Browse files
Kudofabriziocucci
authored andcommitted
fix React-jsitooling build error for use_frameworks build (#50252)
Summary: to resolve use_frameworks build error. this is an edge case happening only when there's objective-c files import to `React_RCTAppDelegate`. Xcode will have `include of non-modular header inside framework module` error originally. this is the generated umbrella header for jsitooling is incorrect. even the header path are correct, they are not modular headers. ~this pr adds a workaround to import header from outside the module.~ updates: this pr uses a forward declaration to prevent exposing the dependency in umbrella header. [IOS] [FIXED] - `JSRuntimeFactoryCAPI.h` build error for `use_frameworks` build Pull Request resolved: #50252 Test Plan: to reproduce the build error, we can build `USE_FRAMEWORKS=static bundle exec pod install` from rn-tester. we also need to import `React_RCTAppDelegate` from objective-c files. in this case, we can add `import React_RCTAppDelegate;` in rn-tester's main.m ```diff --- a/packages/rn-tester/RNTester/main.m +++ b/packages/rn-tester/RNTester/main.m @@ -8,6 +8,9 @@ #import <UIKit/UIKit.h> #import "AppDelegate.h" +@import React_RCTAppDelegate; +// This also triggers the error +//#import <React_RCTAppDelegate/React-RCTAppDelegate-umbrella.h> int main(int argc, char *argv[]) { ``` Reviewed By: fabriziocucci Differential Revision: D71963188 Pulled By: cipolleschi fbshipit-source-id: 5d566ae5aadb9efc032aacfe32862ea289134f87
1 parent 0bd7b4e commit 6c907ee

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

packages/react-native/Libraries/AppDelegate/RCTJSRuntimeConfiguratorProtocol.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
#import <UIKit/UIKit.h>
9-
#import <react/runtime/JSRuntimeFactoryCAPI.h>
10-
118
#pragma once
129

1310
NS_ASSUME_NONNULL_BEGIN
1411

12+
// Forward declarations for umbrella headers.
13+
// In implementations, import `<react/runtime/JSRuntimeFactoryCAPI.h>` to obtain the actual type.
14+
typedef void *JSRuntimeFactoryRef;
15+
1516
@protocol RCTJSRuntimeConfiguratorProtocol
1617

1718
- (JSRuntimeFactoryRef)createJSRuntimeFactory;

packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#import <react/renderer/runtimescheduler/RuntimeScheduler.h>
3333
#import <react/renderer/runtimescheduler/RuntimeSchedulerCallInvoker.h>
3434
#import <react/runtime/JSRuntimeFactory.h>
35+
#import <react/runtime/JSRuntimeFactoryCAPI.h>
3536

3637
@implementation RCTRootViewFactoryConfiguration
3738

packages/react-native/ReactCommon/jsitooling/React-jsitooling.podspec

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ Pod::Spec.new do |s|
4848
s.header_mappings_dir = "./"
4949
end
5050

51-
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => header_search_paths.join(" "),
52-
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard() }
51+
s.pod_target_xcconfig = {
52+
"HEADER_SEARCH_PATHS" => header_search_paths.join(" "),
53+
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
54+
"DEFINES_MODULE" => "YES",
55+
}
5356

5457
s.dependency "React-cxxreact", version
5558
s.dependency "React-jsi", version

packages/react-native/ReactCommon/jsitooling/react/runtime/JSRuntimeFactory.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#pragma once
99

10+
#ifdef __cplusplus
11+
1012
#include <ReactCommon/RuntimeExecutor.h>
1113
#include <cxxreact/MessageQueueThread.h>
1214
#include <jsi/jsi.h>
@@ -72,3 +74,5 @@ class JSIRuntimeHolder : public JSRuntime {
7274
};
7375

7476
} // namespace facebook::react
77+
78+
#endif // __cplusplus

0 commit comments

Comments
 (0)