Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Unexpectedly found nil while unwrapping an Optional value #83

Open
smhemel opened this issue Sep 9, 2023 · 5 comments
Open

Comments

@smhemel
Copy link

smhemel commented Sep 9, 2023

Describe the bug
Date Picker is not showing up.
Getting Fatal error when I call atePicker.present() with valid options on Xcode.

My code:

DatePicker.present({
        mode: 'date',
        date: new Date().toISOString(),
        max: this.getMaxDate(from),
        theme: 'light',
      })
      .then((dateData) => {
         console.log(dateData);
      })

Error in Xcode:
CapacitorCommunityDatePicker/Parse.swift:20: Fatal error: Unexpectedly found nil while unwrapping an Optional value

Screenshot 2023-09-10 at 12 34 37 AM
@DanielDarrenJones
Copy link

I'm getting this same issue, did you manage to find a solution @smhemel ? :)

@smhemel
Copy link
Author

smhemel commented Sep 22, 2023

@DanielDarrenJones No, I didn't find any solution. But, I implemented a custom date-picker component using component instead of this plugin. Below, I have provided a screenshot. You can try it.

Screenshot 2024-05-14 234254

@goodwin64
Copy link

We've faced the same error in our project recently. In our case we were passing the following data to the DatePicker:

let { value: newValue } = await DatePicker.present({
  mode, // "time"
  date: value || dateSuggestion || undefined, // 24-hour formatted time string
  timezone,
  format: dateFormat, // "HH:mm"
  is24h: true,
  ios: {
    timezone,
    format: dateFormat,
    style: 'wheels',
    mode,
  },
  android: {
    timezone,
    format: dateFormat,
    mode,
  },
});

Despite the fact we explicitly passed the is24h and format params the plugin used the device's platform built-in Date formatter (DateFormatter from the Foundation code) - so devices with the 12 hour locale tried to parse the 24-hour formatted time, which returned nil. The things became worse because there's a "must-have-a-value" operator used:

// client/node_modules/@capacitor-community/date-picker/ios/Plugin/Parse.swift
return formatter.date(from: date)!;
//                               ^--- here

@Kamsou
Copy link

Kamsou commented May 14, 2024

Same error. @smhemel any idea ?

@smhemel
Copy link
Author

smhemel commented May 14, 2024

Same error. @smhemel any idea ?

@Kamsou I didn't find any solution. Also, I did R&D to find an alternative date-picker plugin for the capacitor, but I didn't.
After that, I implemented a custom date-picker component using component instead of this plugin. Below, I have provided a screenshot. You can try the component.

Screenshot 2024-05-14 234254

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants