diff --git a/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm b/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm index 67adefc44abe4f..a44146ab4e0fdd 100644 --- a/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm +++ b/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm @@ -124,6 +124,7 @@ - (instancetype)initWithRuntime:(jsi::Runtime *)runtime // allow it to do so. if ([module respondsToSelector:@selector(getTurboModuleWithJsInvoker:)]) { auto turboModule = [module getTurboModuleWithJsInvoker:_jsInvoker]; + assert(turboModule != nullptr); _turboModuleCache.insert({moduleName, turboModule}); return turboModule; } @@ -144,7 +145,9 @@ - (instancetype)initWithRuntime:(jsi::Runtime *)runtime * Step 2d: Return an exact sub-class of ObjC TurboModule */ auto turboModule = [_delegate getTurboModule:moduleName instance:module jsInvoker:_jsInvoker]; - _turboModuleCache.insert({moduleName, turboModule}); + if (turboModule != nullptr) { + _turboModuleCache.insert({moduleName, turboModule}); + } return turboModule; }