I have a native iOS module that is suddenly not exposed anymore to Javascript. I'm using RN 0.59.4.
It seems that it happened after I renamed the iOS project.
What I can say is that I'm using dependency injection, not RCT_EXPORT_MODULE.
The module initialisation code is called, I've verified it by setting breakpoints in key areas such as requiresMainQueueSetup.
I guess my question is this: under which known conditions a module may not be exposed to JavaScript?
Any help appreciated.
EDIT 1: I've pinpointed the problem to RCTCxxUtils::createNativeModules() which at first receives 105 elements with my module, but is called a second time with only 104 elements.
EDIT 2: For what its worth, here are the back traces of each calls:
First Call => modules=105 elements in frame #0
* thread #9, name = 'com.facebook.react.JavaScript', stop reason = breakpoint 3.1
* frame #0: 0x0000000100c4e6d4 CardioSensys`facebook::react::createNativeModules(modules=105 elements, bridge=0x0000000102d14490, instance=std::__1::shared_ptr<facebook::react::Instance>::element_type @ 0x000000028100d7c0 strong=1 weak=1) at RCTCxxUtils.mm:39:3
frame #1: 0x0000000100bcd840 CardioSensys`::-[RCTCxxBridge _buildModuleRegistryUnlocked](self=0x0000000102d14490, _cmd="_buildModuleRegistryUnlocked") at RCTCxxBridge.mm:520:10
frame #2: 0x0000000100bceb84 CardioSensys`::-[RCTCxxBridge _initializeBridgeLocked:](self=0x0000000102d14490, _cmd="_initializeBridgeLocked:", executorFactory=std::__1::shared_ptr<facebook::react::JSExecutorFactory>::element_type @ 0x0000000283ae7058 strong=3 weak=1) at RCTCxxBridge.mm:573:36
frame #3: 0x0000000100bce39c CardioSensys`::-[RCTCxxBridge _initializeBridge:](self=0x0000000102d14490, _cmd="_initializeBridge:", executorFactory=std::__1::shared_ptr<facebook::react::JSExecutorFactory>::element_type @ 0x0000000283ae7058 strong=3 weak=1) at RCTCxxBridge.mm:550:5
frame #4: 0x0000000100bcb498 CardioSensys`::__21-[RCTCxxBridge start]_block_invoke.168(.block_descriptor=0x0000000283ae6dc0) at RCTCxxBridge.mm:344:5
frame #5: 0x0000000100bdefa0 CardioSensys`decltype(__f=0x000000016fa15c58) block_pointer __strong&>(fp)()) std::__1::__invoke<void () block_pointer __strong&>(&&, decltype(std::__1::forward<void () block_pointer __strong&>(fp)())&&...) at type_traits:4361:1
frame #6: 0x0000000100bdef3c CardioSensys`void std::__1::__invoke_void_return_wrapper<void>::__call<void (__args=0x000000016fa15c58) block_pointer __strong&>(void () block_pointer __strong&) at __functional_base:349:9
frame #7: 0x0000000100bdef14 CardioSensys`std::__1::__function::__alloc_func<void () block_pointer __strong, std::__1::allocator<std::__1::allocator>, void ()>::operator(this=0x000000016fa15c60)() at functional:1527:16
frame #8: 0x0000000100bdd6b8 CardioSensys`std::__1::__function::__func<void () block_pointer __strong, std::__1::allocator<std::__1::allocator>, void ()>::operator(this=0x000000016fa15c58)() at functional:1651:12
frame #9: 0x00000001008722c0 CardioSensys`std::__1::__function::__value_func<void ()>::operator(this=0x000000016fa15c58)() const at functional:1799:16
frame #10: 0x00000001008709dc CardioSensys`std::__1::function<void ()>::operator(this=0x000000016fa15c58)() const at functional:2347:12
frame #11: 0x0000000100c4ed98 CardioSensys`facebook::react::tryAndReturnError(func=0x000000016fa15c58)> const&) at RCTCxxUtils.mm:72:7
frame #12: 0x0000000100bc9e44 CardioSensys`::-[RCTCxxBridge _tryAndHandleError:](self=0x0000000102d14490, _cmd="_tryAndHandleError:", block=0x0000000100bcb434) at RCTCxxBridge.mm:257:20
frame #13: 0x000000018d465690 Foundation`__NSThreadPerformPerform + 336
frame #14: 0x000000018c96ff2c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
frame #15: 0x000000018c96feac CoreFoundation`__CFRunLoopDoSource0 + 88
frame #16: 0x000000018c96f794 CoreFoundation`__CFRunLoopDoSources0 + 176
frame #17: 0x000000018c96a6d0 CoreFoundation`__CFRunLoopRun + 1004
frame #18: 0x000000018c969fc4 CoreFoundation`CFRunLoopRunSpecific + 436
frame #19: 0x0000000100bc9c8c CardioSensys`::+[RCTCxxBridge runRunLoop](self=RCTCxxBridge, _cmd="runRunLoop") at RCTCxxBridge.mm:249:36
frame #20: 0x000000018d4654a0 Foundation`__NSThread__start__ + 984
frame #21: 0x000000018c5f92c0 libsystem_pthread.dylib`_pthread_body + 128
frame #22: 0x000000018c5f9220 libsystem_pthread.dylib`_pthread_start + 44
frame #23: 0x000000018c5fccdc libsystem_pthread.dylib`thread_start + 4
Second call => modules = 104 elements in frame #0
* thread #19, name = 'com.facebook.react.JavaScript', stop reason = breakpoint 3.1
* frame #0: 0x0000000100c4e6d4 CardioSensys`facebook::react::createNativeModules(modules=104 elements, bridge=0x0000000102d1b8c0, instance=std::__1::shared_ptr<facebook::react::Instance>::element_type @ 0x000000028100e4e0 strong=1 weak=1) at RCTCxxUtils.mm:39:3
frame #1: 0x0000000100bcd840 CardioSensys`::-[RCTCxxBridge _buildModuleRegistryUnlocked](self=0x0000000102d1b8c0, _cmd="_buildModuleRegistryUnlocked") at RCTCxxBridge.mm:520:10
frame #2: 0x0000000100bceb84 CardioSensys`::-[RCTCxxBridge _initializeBridgeLocked:](self=0x0000000102d1b8c0, _cmd="_initializeBridgeLocked:", executorFactory=std::__1::shared_ptr<facebook::react::JSExecutorFactory>::element_type @ 0x0000000283909318 strong=3 weak=1) at RCTCxxBridge.mm:573:36
frame #3: 0x0000000100bce39c CardioSensys`::-[RCTCxxBridge _initializeBridge:](self=0x0000000102d1b8c0, _cmd="_initializeBridge:", executorFactory=std::__1::shared_ptr<facebook::react::JSExecutorFactory>::element_type @ 0x0000000283909318 strong=3 weak=1) at RCTCxxBridge.mm:550:5
frame #4: 0x0000000100bcb498 CardioSensys`::__21-[RCTCxxBridge start]_block_invoke.168(.block_descriptor=0x00000002834686c0) at RCTCxxBridge.mm:344:5
frame #5: 0x0000000100bdefa0 CardioSensys`decltype(__f=0x000000016ff3dc58) block_pointer __strong&>(fp)()) std::__1::__invoke<void () block_pointer __strong&>(&&, decltype(std::__1::forward<void () block_pointer __strong&>(fp)())&&...) at type_traits:4361:1
frame #6: 0x0000000100bdef3c CardioSensys`void std::__1::__invoke_void_return_wrapper<void>::__call<void (__args=0x000000016ff3dc58) block_pointer __strong&>(void () block_pointer __strong&) at __functional_base:349:9
frame #7: 0x0000000100bdef14 CardioSensys`std::__1::__function::__alloc_func<void () block_pointer __strong, std::__1::allocator<std::__1::allocator>, void ()>::operator(this=0x000000016ff3dc60)() at functional:1527:16
frame #8: 0x0000000100bdd6b8 CardioSensys`std::__1::__function::__func<void () block_pointer __strong, std::__1::allocator<std::__1::allocator>, void ()>::operator(this=0x000000016ff3dc58)() at functional:1651:12
frame #9: 0x00000001008722c0 CardioSensys`std::__1::__function::__value_func<void ()>::operator(this=0x000000016ff3dc58)() const at functional:1799:16
frame #10: 0x00000001008709dc CardioSensys`std::__1::function<void ()>::operator(this=0x000000016ff3dc58)() const at functional:2347:12
frame #11: 0x0000000100c4ed98 CardioSensys`facebook::react::tryAndReturnError(func=0x000000016ff3dc58)> const&) at RCTCxxUtils.mm:72:7
frame #12: 0x0000000100bc9e44 CardioSensys`::-[RCTCxxBridge _tryAndHandleError:](self=0x0000000102d1b8c0, _cmd="_tryAndHandleError:", block=0x0000000100bcb434) at RCTCxxBridge.mm:257:20
frame #13: 0x000000018d465690 Foundation`__NSThreadPerformPerform + 336
frame #14: 0x000000018c96ff2c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
frame #15: 0x000000018c96feac CoreFoundation`__CFRunLoopDoSource0 + 88
frame #16: 0x000000018c96f794 CoreFoundation`__CFRunLoopDoSources0 + 176
frame #17: 0x000000018c96a6d0 CoreFoundation`__CFRunLoopRun + 1004
frame #18: 0x000000018c969fc4 CoreFoundation`CFRunLoopRunSpecific + 436
frame #19: 0x0000000100bc9c8c CardioSensys`::+[RCTCxxBridge runRunLoop](self=RCTCxxBridge, _cmd="runRunLoop") at RCTCxxBridge.mm:249:36
frame #20: 0x000000018d4654a0 Foundation`__NSThread__start__ + 984
frame #21: 0x000000018c5f92c0 libsystem_pthread.dylib`_pthread_body + 128
frame #22: 0x000000018c5f9220 libsystem_pthread.dylib`_pthread_start + 44
frame #23: 0x000000018c5fccdc libsystem_pthread.dylib`thread_start + 4
EDIT 3: The first time, I have a call to registerExtraModules and this is where my module is added. The second time, a if condition is not satisfied, thus the extra module not added.
if ([self.delegate respondsToSelector:@selector(extraModulesForBridge:)])
{
extraModules = [self.delegate extraModulesForBridge:_parentBridge];
} else if (self.moduleProvider) {
extraModules = self.moduleProvider();
}
EDIT 4: I had to went back to the project before renaming and do it again to solve my problem. Today the problem is back again, this time as soon as I added a new native module.