From aa39cb6d9f0cb059d8be96721bb636d8cf9a9d26 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Mon, 4 Feb 2019 11:32:31 -0800 Subject: [PATCH] Remove assertion on TurboModule existence Summary: It's okay for TurboModules to not exist. Therefore, `__turboModuleProvider(moduleName)` should return null if `moduleName` doesn't refer to an actual TurboModule. The current implementation assumes that the TurboModule must exist, and therefore, it crashes the app when it doesn't (assertion error). This change is important because it helps us land D13887962. When we switch `I18nResources` to `TurboModuleRegistry` in D13887962, on Wilde, it won't be found in `NativeModules`. Therefore, we'll try to lookup this module in `__turboModuleProvider`, and this will crash the app. It seems like `I18nResources` is a Java-only module? Reviewed By: fkgozali Differential Revision: D13924589 fbshipit-source-id: 7ac7b1873e06852e5aafcaaef5c24cbc548ee444 --- .../turbomodule/core/platform/ios/RCTTurboModuleManager.mm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm b/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm index fbf24e0b749..67adefc44ab 100644 --- a/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm +++ b/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm @@ -114,8 +114,9 @@ static Class getFallbackClassFromName(const char *name) { // If we request that a TurboModule be created, its respective ObjC class must exist // If the class doesn't exist, then provideRCTTurboModule returns nil - // Therefore, module cannot be nil. - assert(module); + if (!module) { + return nullptr; + } Class moduleClass = [module class];