[Bug]: iOS crash: -[RNDatePicker setMaximumDate:] unrecognized selector on RN 0.81.4 with v5.0.12
Describe the bug
Description: After upgrading to React Native 0.81.4, I had to pin react-native-date-picker to 5.0.12 (see #940) to get iOS to build.
However, when opening the date picker modal with maximumDate set, the app immediately crashes on iOS.
Error log:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RNDatePicker setMaximumDate:]: unrecognized selector sent to instance'
Cause: In ios/RNDatePickerManager.m, the native code still calls:
[view setMaximumDate:date];
…but UIDatePicker no longer exposes setMaximumDate:. The correct way is to assign the property directly:
view.maximumDate = date;
The same applies for minimumDate.
Reproduction:
React Native 0.81.4
react-native-date-picker 5.0.12
iOS 17 simulator
Open a <DatePicker maximumDate={someDate} />
Expected behavior: Date picker should open and respect the maximumDate.
Actual behavior: App crashes with unrecognized selector exception.
Proposed fix: Update RNDatePickerManager.m to use property assignment instead of non-existent setter methods. Example:
RCT_CUSTOM_VIEW_PROPERTY(maximumDate, id, DatePicker) { NSDate *date = [self convertToNSDate:json]; if (date) { view.maximumDate = date; } }
Expected behavior
The app doesn't crash!
To Reproduce
<DatePicker
mode="date"
date={tempDate}
maximumDate={latestValidDate}
onDateChange={setTempDate}
theme='light'
style={{ height: WINDOW_HEIGHT * 0.25, width: WINDOW_WIDTH * 0.8 }}
/>
Operating System
- [ ] Android
- [x] iOS
React Native Version
0.81.4
Expo Version (if applicable)
No response
react-native-date-picker version
5.0.12
React Native Architecture
- [ ] Old Architecture (Paper)
- [x] New Architecture (Fabric)
Relevant log output
It looks like the problem may go deeper than just swapping setMaximumDate: for maximumDate =. The native view here is an RNDatePicker wrapper, not the system UIDatePicker. From what I can tell, RNDatePicker itself doesn’t currently expose maximumDate/minimumDate as passthrough properties to its underlying UIDatePicker. That could explain why even with property assignment the selector isn’t recognized. I haven’t proved this out or tested a fix end-to-end, but it seems likely that RNDatePicker.h/.m would need to declare and implement these properties so the manager can assign them safely.
I'm having a similar problem. I don't know how to solve it. I'm getting the same error even though I set the minimumDate. How can we solve it?
I couldn't find a work around thst didn't require rewriting of the package. There were other issues after I stopped using min and max. In the end I removed the package and went with community date picker.
Issue was fixed by @burakharun -> comment
I created a patch based on PR #939.
Tested with:
"react-native": "0.81.4" "react-native-date-picker": "5.0.13"
Works as expected
+1
I couldn't find a work around thst didn't require rewriting of the package. There were other issues after I stopped using min and max. In the end I removed the package and went with community date picker.
sr which one will replace this lib? im using expo 54 and got crashed too
I was experiencing the same error when updating our app to "react-native": "0.82.1",, but upgrading "react-native-date-picker": "5.0.12" => "5.0.13" helped.
Final combo I ended up with is:
"react-native": "0.82.1,
"react-native-date-picker": "5.0.13"
Update: on every app start in dev build I do see this error, but the app seems to work and spinner with time works fine.
+1
@Richard-HeadCoach
Fixed using this patch.
Tested on: ✅ react-native: 0.82.1 react-native-date-picker: 5.0.13 (with patch)
I ran into an iOS build issue with react-native-date-picker that seems to be caused by the modulesProvider entry in package.json.
Fix: removing the modulesProvider block resolves the issue on my end.
Specifically, changing this:
"ios": {
"componentProvider": {
"RNDatePicker": "RNDatePicker"
},
"modulesProvider": {
"RNDatePicker": "RNDatePickerManager"
}
}
to this:
"ios": {
"componentProvider": {
"RNDatePicker": "RNDatePicker"
}
}
After applying this change, the iOS build works correctly.
I’ve temporarily fixed it locally using patch-package.
Sharing this in case it helps others or can be included in a future release. Thanks!
@aqee1ahmed Are you using modal variant DatePicker in your RN 0.82.1? I'm getting some iOS native crash even I'm not using max or min date props in the modal variant of DatePicker 5.0.13. Inline variant working fine without any error. Can you please confirm if you're using same modal variant? and new arch enabled in your RN? And config for hermes and flipper?