mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
3afef3c167
Summary: when integrates with swift, the compiler will build clang module based on the *React-Core-umbrella.h*. however, the include chain reaches some c++ headers that are not available from swift. it will cause build error.  this pr adds `#ifdef __cplusplus` guard for it. ## Changelog [iOS] [Fixed] - Fix React module build error with swift integration on new architecture mode Pull Request resolved: https://github.com/facebook/react-native/pull/34527 Test Plan: one thing we didn't figure out is that we require reanimated to repro the build error. 1. `npx react-native init RN070 --version 0.70.0-rc.4`. # can also repro this issue on 0.69 2. `cd RN070` 3. `yarn add react-native-reanimated@next` 4. `cd ios && rm -rf Pods build && RCT_NEW_ARCH_ENABLED=1 pod install` 5. add `import React;` in `main.m` for clang module generation ```diff --- a/ios/RN070/main.m +++ b/ios/RN070/main.m @@ -1,5 +1,6 @@ #import <UIKit/UIKit.h> +@import React; #import "AppDelegate.h" int main(int argc, char *argv[]) ``` 6. `yarn ios` Reviewed By: cipolleschi Differential Revision: D39128716 Pulled By: jacdebug fbshipit-source-id: d9e9130f99e3b9e5f7807c475a24cdd84880e720
49 lines
1.1 KiB
Objective-C
49 lines
1.1 KiB
Objective-C
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import <Foundation/Foundation.h>
|
|
#import <React/RCTBridge.h>
|
|
#import <React/RCTRootView.h>
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#if RCT_NEW_ARCH_ENABLED
|
|
|
|
#ifndef RCT_USE_HERMES
|
|
#if __has_include(<reacthermes/HermesExecutorFactory.h>)
|
|
#define RCT_USE_HERMES 1
|
|
#else
|
|
#define RCT_USE_HERMES 0
|
|
#endif
|
|
#endif
|
|
|
|
#if RCT_USE_HERMES
|
|
#import <reacthermes/HermesExecutorFactory.h>
|
|
#else
|
|
#import <React/JSCExecutorFactory.h>
|
|
#endif
|
|
|
|
#import <ReactCommon/RCTTurboModuleManager.h>
|
|
#endif
|
|
|
|
#if RCT_NEW_ARCH_ENABLED
|
|
RCT_EXTERN id<RCTTurboModule> RCTAppSetupDefaultModuleFromClass(Class moduleClass);
|
|
|
|
std::unique_ptr<facebook::react::JSExecutorFactory> RCTAppSetupDefaultJsExecutorFactory(
|
|
RCTBridge *bridge,
|
|
RCTTurboModuleManager *turboModuleManager);
|
|
#endif
|
|
|
|
#endif // __cplusplus
|
|
|
|
RCT_EXTERN_C_BEGIN
|
|
|
|
void RCTAppSetupPrepareApp(UIApplication *application);
|
|
UIView *RCTAppSetupDefaultRootView(RCTBridge *bridge, NSString *moduleName, NSDictionary *initialProperties);
|
|
|
|
RCT_EXTERN_C_END
|