Skip to content

Commit

Permalink
Allow importing RCTAppDelegate in Swift (#43339)
Browse files Browse the repository at this point in the history
Summary:
This PR fixes importing RCTAppDelegate, cleans up the imports, and properly sets the background color for bridgeless mode when using `RCTRootViewFactory`.

The issue with importing to Swift was that `RCTTurboModuleManager` has C++ in headers which caused Swift to error out.

bypass-github-export-checks

## Changelog:

[IOS] [FIXED] - Allow importing RCTAppDelegate in Swift
[INTERNAL] [REMOVED] - Remove unnecessary imports in AppDelegate
[INTERNAL] [FIXED] - Properly set background color for bridgeless

Pull Request resolved: #43339

Test Plan:
- CI Green
- Check if background color is correct

Reviewed By: dmytrorykun

Differential Revision: D54584489

Pulled By: cipolleschi

fbshipit-source-id: cb4b947ca9d0f375b1852dbf5a7d889e920562f7
  • Loading branch information
okwasniewski authored and facebook-github-bot committed Mar 6, 2024
1 parent 1c69100 commit 7c95369
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
* LICENSE file in the root directory of this source tree.
*/

#if defined(__cplusplus)

#import <ReactCommon/RCTTurboModuleManager.h>
#import "RCTAppDelegate.h"

@interface RCTAppDelegate () <RCTTurboModuleManagerDelegate>
@end

#endif
15 changes: 1 addition & 14 deletions packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@

#import "RCTAppDelegate.h"
#import <React/RCTColorSpaceUtils.h>
#import <React/RCTCxxBridgeDelegate.h>
#import <React/RCTLog.h>
#import <React/RCTRootView.h>
#import <React/RCTSurfacePresenterBridgeAdapter.h>
#import <React/RCTUtils.h>
#import <objc/runtime.h>
#import <react/renderer/graphics/ColorComponents.h>
#import <react/renderer/runtimescheduler/RuntimeScheduler.h>
#import "RCTAppDelegate+Protected.h"
#import "RCTAppSetupUtils.h"

Expand All @@ -22,26 +21,14 @@
#else
#import <React/CoreModulesPlugins.h>
#endif
#import <React/RCTBundleURLProvider.h>
#import <React/RCTComponentViewFactory.h>
#import <React/RCTComponentViewProtocol.h>
#import <React/RCTFabricSurface.h>
#import <React/RCTSurfaceHostingProxyRootView.h>
#import <React/RCTSurfacePresenter.h>
#import <ReactCommon/RCTContextContainerHandling.h>
#if USE_HERMES
#import <ReactCommon/RCTHermesInstance.h>
#else
#import <ReactCommon/RCTJscInstance.h>
#endif
#import <ReactCommon/RCTHost+Internal.h>
#import <ReactCommon/RCTHost.h>
#import <ReactCommon/RCTTurboModuleManager.h>
#import <react/config/ReactNativeConfig.h>
#import <react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h>
#import <react/renderer/runtimescheduler/RuntimeScheduler.h>
#import <react/renderer/runtimescheduler/RuntimeSchedulerCallInvoker.h>
#import <react/runtime/JSRuntimeFactory.h>

@interface RCTAppDelegate () <RCTComponentViewFactoryComponentProvider>
@end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ - (UIView *)viewWithModuleName:(NSString *)moduleName
initWithSurface:surface
sizeMeasureMode:RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact];

surfaceHostingProxyRootView.backgroundColor = [UIColor systemBackgroundColor];
return surfaceHostingProxyRootView;
}

Expand Down

0 comments on commit 7c95369

Please sign in to comment.