Things to check:
-
AppDelegate - Package Config - Dependencies
- Package Config - Codegen
- React Native Config
- Metro Config
- In the RN template, the
AppDelegateinherits fromRCTAppDelegate. - A newly added property called:
RCTAppDelegate.dependencyProvideris initialized with an instance ofRCTAppDependencyProvider- This property accepts an object that conforms to
RCTDependencyProvider - It essential acts as a registry for class names and their corresponding class types.
- The requirements for this protocol defines properties that hold dictionaries (i.e. mapping from string to class types), or arrays that hold class names that conform to some protocol (e.g.
(NSArray<NSString *> *)imageURLLoaderClassNames). - The registry/map for the "third party components" are in the
RCTComponentViewProtocol.thirdPartyFabricComponentsproperty, and is defined as a "string to class type" dictionary (i.e.NSDictionary<NSString *, Class<RCTComponentViewProtocol>>). - I.e. a mapping of the "component handle" (class name), to the class types that conform to
RCTComponentViewProtocol.
- This property accepts an object that conforms to
- Since
RCTAppDelegate.dependencyProvideris initialized with an instance ofRCTAppDependencyProvider, it conforms toRCTDependencyProvider. - The
RCTAppDependencyProvider.thirdPartyFabricComponentsis a computed lazy static property (lazily initialized once).- This is because it uses a
dispatch_once_ttoken, and uses adispatch_onceblock to cache_thirdPartyFabricComponentsivar. - As such every time
RCTAppDependencyProvider.thirdPartyFabricComponentsis invoked, it just returns the cache value from_thirdPartyFabricComponentsivar. - The value returned from this computed static property is from:
RCTThirdPartyComponentsProvider.thirdPartyFabricComponents(important).
- This is because it uses a
- The initialization of
RCTAppDependencyProvider.thirdPartyFabricComponentsis where the crash originates.- Error Message:
com.facebook.react.runtime.JavaScript (18): "-[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[17]. - Error Desc: "An abort signal terminated the process. Such crashes often happen because of an uncaught exception or unrecoverable error or calling the abort() function"
- For whatever reason, whenever
RCTAppDependencyProvider.thirdPartyFabricComponentsis "read" for the first time, it triggers a crash related to a dictionary being empty (or in this case, being malformed).
- Error Message:
- We know that
RCTThirdPartyComponentsProvider.thirdPartyFabricComponentscomes from codegen/turbo modules.- To recap, when codegen runs during
pod install, It generates stubs and implementations for all the fabric components (defined via the turbo module system). - Codegen searches for all the files that ends with:
NativeComponent.tsand reads thecodegenNativeComponentconfig/spec defined for the given fabric component. - Additionally, in
codegenConfigproperty in your librarypackage.jsondefines extra settings, most notably:codegenConfig.componentProvider(Record<string, string>). - So the crash originates from codegen, specifically the mapping between the handle. i.e. name of the fabric component to its associated class type (component registry).
- To recap, when codegen runs during
- If we check
RCTThirdPartyComponentsProvider.mm(in this particular project, it's located at:example/ios/build/generated/ios/RCTThirdPartyComponentsProvider.mm), we can see the mapping the codegen generates.- From screenshot, we can see the generated dict. is malformed.

