Repository navigation
RCTThirdPartyComponentsProvider crashes on multi-target iOS apps (ShareExtension, App Clip) #56469
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
Needs: Author FeedbackNeeds: ReproThis issue could be improved with a clear list of steps to reproduce the issue.This issue could be improved with a clear list of steps to reproduce the issue.StaleThere has been a lack of activity on this issue and it may be closed soon.There has been a lack of activity on this issue and it may be closed soon.
Description
Summary
When an iOS app has multiple targets (e.g., main app + ShareExtension), RCTThirdPartyComponentsProvider.mm crashes because it uses NSDictionary literal syntax that cannot handle nil values.
Environment
- React Native: 0.81.5
- Expo SDK: 54
- New Architecture: Enabled
- iOS targets: Main app + ShareExtension
Problem
Crash
NSInvalidArgumentException: attempt to insert nil object from objects[14]
+[RCTThirdPartyComponentsProvider thirdPartyFabricComponents]
Root Cause
- Codegen generates a single
RCTThirdPartyComponentsProvider.mmshared between all targets - It uses
NSDictionaryliteral syntax:thirdPartyComponents = @{ @"RNGoogleSignInButton": NSClassFromString(@"RNGoogleSignInButtonComponentView"), @"RNGoogleMobileAdsBannerView": NSClassFromString(@"RNGoogleMobileAdsBannerView"), // ... }; - ShareExtension/App Clip targets don't link all libraries (size constraints, API limitations)
NSClassFromString()returns nil for unlinked classesNSDictionaryliteral crashes on nil values
Why existing fix doesn't help
PR #51838 (backported to 0.79, included in 0.81) allows disabling libraries via react-native.config.js. But this doesn't help when:
- Library is enabled for main app
- Library is not linked to secondary target (ShareExtension)
- Both targets share the same codegen output
Proposed Solution
Generate nil-safe code by default:
static inline void SafeAddComponent(NSMutableDictionary *dict, NSString *name, NSString *className) {
Class cls = NSClassFromString(className);
if (cls != nil) {
dict[name] = cls;
}
}
// ...
NSMutableDictionary *components = [NSMutableDictionary dictionary];
SafeAddComponent(components, @"RNGoogleSignInButton", @"RNGoogleSignInButtonComponentView");
SafeAddComponent(components, @"RNGoogleMobileAdsBannerView", @"RNGoogleMobileAdsBannerView");
thirdPartyComponents = [components copy];This is backward compatible and handles all multi-target scenarios.
Alternative Solutions
- Generate target-specific
RCTThirdPartyComponentsProviderfiles - Add a codegen option to enable nil-safe generation
Related Issues
- ShareExtension crashes with RCTThirdPartyComponentsProvider on New Architecture MaxAst/expo-share-extension#117 (expo-share-extension users hitting this)
- Disabling autolinking on iOS selectively in react-native.config.js crashes the app during runtime #51077 (similar issue, different trigger)
- Exclude selectively disabled libraries from codegen generation #51078, fix: exclusion of selectively disabled libraries from codegen generation #51838 (partial fix for disabled libraries)
Workaround
Currently using a post-install script to patch the generated file:
MaxAst/expo-share-extension#117 (comment)
Metadata
Metadata
Assignees
Labels
Needs: Author FeedbackNeeds: ReproThis issue could be improved with a clear list of steps to reproduce the issue.This issue could be improved with a clear list of steps to reproduce the issue.StaleThere has been a lack of activity on this issue and it may be closed soon.There has been a lack of activity on this issue and it may be closed soon.
Activity
react-native-bot commentedon Apr 16, 2026
Warning
Missing reproducer: We could not detect a reproducible example in your issue report. Reproducers are mandatory and we can accept only one of those as a valid reproducer:
You can read more about about it on our website: How to report a bug.
react-native-bot commentedon May 11, 2026
This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.
react-native-bot commentedon May 18, 2026
This issue was closed because it has been stalled for 7 days with no activity.
Skip third-party components whose class is not linked instead of cras…