Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/react-native/React/Base/RCTBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,11 @@ - (instancetype)initWithDelegate:(id<RCTBridgeDelegate>)delegate
moduleProvider:(RCTBridgeModuleListProvider)block
launchOptions:(NSDictionary *)launchOptions
{
// Only enabld this assertion in OSS
#if COCOAPODS
[RCTBridge throwIfOnLegacyArch];
#endif

if (self = [super init]) {
RCTEnforceNewArchitectureValidation(RCTNotAllowedInBridgeless, self, nil);
_delegate = delegate;
Expand All @@ -393,6 +398,17 @@ - (instancetype)initWithDelegate:(id<RCTBridgeDelegate>)delegate
return self;
}

// Wrap the exception throwing in a static method to avoid the warning: "The code following the exception will never be
// executed". This might create build failures internally where we treat warnings as errors.
+ (void)throwIfOnLegacyArch
{
@throw [NSException
exceptionWithName:NSInternalInconsistencyException
reason:
@"You are trying to initialize the legacy architecture. This is not supported anymore and will be removed in the next version of React Native. Please use the New Architecture instead."
userInfo:nil];
}

RCT_NOT_IMPLEMENTED(-(instancetype)init)

- (void)dealloc
Expand Down
Loading