Skip to content

Commit 41c50fd

Browse files
cipolleschimeta-codesync[bot]
authored andcommitted
Fix build issues when RCT_REMOVE_LEGACY_ARCH is turned on internally (#54821)
Summary: Pull Request resolved: #54821 This diff addresses build issues that arise when the `RCT_REMOVE_LEGACY_ARCH` flag is enabled internally. The changes ensure that the build process is compatible with the updated architecture. ## Changelog: [Internal] - Make sure that we can build using BUCK when the RCT_NEW_ARCH_ENABLED flag is turned on. Reviewed By: GijsWeterings Differential Revision: D88651074 fbshipit-source-id: 41d9d033c1160b5b8b4a7ad3db240e9cf7b50e38
1 parent c31a5a8 commit 41c50fd

1 file changed

Lines changed: 21 additions & 31 deletions

File tree

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

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -288,62 +288,51 @@ - (RCTRootViewFactory *)createRCTRootViewFactory
288288
};
289289
}
290290

291+
#ifndef RCT_REMOVE_LEGACY_ARCH
292+
// When the Legacy Arch is removed, the Delegate does not have a extraLazyModuleClassesForBridge method
291293
if ([self.delegate respondsToSelector:@selector(extraLazyModuleClassesForBridge:)]) {
292294
configuration.extraLazyModuleClassesForBridge =
293295
^NSDictionary<NSString *, Class> *_Nonnull(RCTBridge *_Nonnull bridge)
294296
{
295-
#ifndef RCT_REMOVE_LEGACY_ARCH
296297
return [weakSelf.delegate extraLazyModuleClassesForBridge:bridge];
297-
#else
298-
// When the Legacy Arch is removed, the Delegate does not have a extraLazyModuleClassesForBridge method
299-
return @{};
300-
#endif
301298
};
302299
}
300+
#endif
303301

302+
#ifndef RCT_REMOVE_LEGACY_ARCH
303+
// When the Legacy Arch is removed, the Delegate does not have a bridge:didNotFindModule method
304+
// We return NO, because if we have invoked this method is unlikely that the module will be actually registered
304305
if ([self.delegate respondsToSelector:@selector(bridge:didNotFindModule:)]) {
305306
configuration.bridgeDidNotFindModule = ^BOOL(RCTBridge *_Nonnull bridge, NSString *_Nonnull moduleName) {
306-
#ifndef RCT_REMOVE_LEGACY_ARCH
307307
return [weakSelf.delegate bridge:bridge didNotFindModule:moduleName];
308-
#else
309-
// When the Legacy Arch is removed, the Delegate does not have a bridge:didNotFindModule method
310-
// We return NO, because if we have invoked this method is unlikely that the module will be actually registered
311-
return NO;
312-
#endif
313308
};
314309
}
310+
#endif
315311

312+
#ifndef RCT_REMOVE_LEGACY_ARCH
313+
// When the Legacy Arch is removed, the Delegate does not have a
314+
// loadSourceForBridge:onProgress:onComplete: method
315+
// We then call the loadBundleAtURL:onProgress:onComplete: instead
316316
if ([self.delegate respondsToSelector:@selector(loadSourceForBridge:onProgress:onComplete:)]) {
317317
configuration.loadSourceForBridgeWithProgress =
318318
^(RCTBridge *_Nonnull bridge,
319319
RCTSourceLoadProgressBlock _Nonnull onProgress,
320320
RCTSourceLoadBlock _Nonnull loadCallback) {
321-
#ifndef RCT_REMOVE_LEGACY_ARCH
322321
[weakSelf.delegate loadSourceForBridge:bridge onProgress:onProgress onComplete:loadCallback];
323-
#else
324-
// When the Legacy Arch is removed, the Delegate does not have a
325-
// loadSourceForBridge:onProgress:onComplete: method
326-
// We then call the loadBundleAtURL:onProgress:onComplete: instead
327-
[weakSelf.delegate loadBundleAtURL:self.bundleURL onProgress:onProgress onComplete:loadCallback];
328-
#endif
329322
};
330323
}
324+
#endif
331325

326+
#ifndef RCT_REMOVE_LEGACY_ARCH
327+
// When the Legacy Arch is removed, the Delegate does not have a
328+
// loadSourceForBridge:withBlock: method
329+
// We then call the loadBundleAtURL:onProgress:onComplete: instead
332330
if ([self.delegate respondsToSelector:@selector(loadSourceForBridge:withBlock:)]) {
333331
configuration.loadSourceForBridge = ^(RCTBridge *_Nonnull bridge, RCTSourceLoadBlock _Nonnull loadCallback) {
334-
#ifndef RCT_REMOVE_LEGACY_ARCH
335332
[weakSelf.delegate loadSourceForBridge:bridge withBlock:loadCallback];
336-
#else
337-
// When the Legacy Arch is removed, the Delegate does not have a
338-
// loadSourceForBridge:withBlock: method
339-
// We then call the loadBundleAtURL:onProgress:onComplete: instead
340-
[weakSelf.delegate loadBundleAtURL:self.bundleURL
341-
onProgress:^(RCTLoadingProgress *progressData) {
342-
}
343-
onComplete:loadCallback];
344-
#endif
345333
};
346334
}
335+
#endif
347336

348337
configuration.jsRuntimeConfiguratorDelegate = self;
349338

@@ -371,15 +360,16 @@ - (void)_setUpFeatureFlags:(RCTReleaseLevel)releaseLevel
371360
static dispatch_once_t setupFeatureFlagsToken;
372361
dispatch_once(&setupFeatureFlagsToken, ^{
373362
switch (releaseLevel) {
374-
case Stable:
375-
ReactNativeFeatureFlags::override(std::make_unique<ReactNativeFeatureFlagsOverridesOSSStable>());
376-
break;
377363
case Canary:
378364
ReactNativeFeatureFlags::override(std::make_unique<ReactNativeFeatureFlagsOverridesOSSCanary>());
379365
break;
380366
case Experimental:
381367
ReactNativeFeatureFlags::override(std::make_unique<ReactNativeFeatureFlagsOverridesOSSExperimental>());
382368
break;
369+
case Stable:
370+
default:
371+
ReactNativeFeatureFlags::override(std::make_unique<ReactNativeFeatureFlagsOverridesOSSStable>());
372+
break;
383373
}
384374
});
385375
}

0 commit comments

Comments
 (0)