Skip to content

[Bug]: iOS crash: -[RNDatePicker setMaximumDate:] unrecognized selector on RN 0.81.4 with v5.0.12 #945

@Richard-HeadCoach

Description

@Richard-HeadCoach

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

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
  • 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)
  • New Architecture (Fabric)

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions