Adds iOS Calendar Demo using ffigen#125
Merged
Merged
Conversation
Also added "Privacy - Calendar Full Access Usage Description" (NSCalendarsFullAccessDescription) to both Info.plist files. This enables usage of the calendar on ios/macos.
This commit introduces the necessary configuration and script to generate Dart and Swift wrappers for Apple's EventKit framework. Details: - Updated pubspec.yaml with ffi, ffigen, objective_c, and swiftgen dependencies. - Created tool/generate_code.dart to generate wrappers for EKEventStore, EKEvent, and EKCalendar. - Configured the generator to target macOS to bypass iOS compilation limits on deprecated properties, and added a post-generation step to strip the iOS-unavailable 'birthdayPersonUniqueID' property from the generated Swift code. - Added generated EventKit wrapper and binding files to .gitignore to keep the repository clean.
- Replaced the swiftgen generator script with a pure FfiGenerator approach directly on Objective-C headers. This eliminates the need for intermediate Swift/Objective-C wrapper classes (like EKEventStoreWrapper), significantly reducing complexity and avoiding Xcode linking crashes (FailedToLoadClassException). - Updated generate_code.dart to specify exact entry points and headers for EventKit.framework, fetching native EKEventStore, EKEvent, EKCalendar, EKCalendarItem, and EKObject definitions directly. - Refactored _retrieveEvents in lib/main.dart to use the type-safe, generated Dart APIs (eventsMatchingPredicate, objectAtIndex, etc.) instead of error-prone, manual objc.msgSend invocations and raw pointer casting. - Fixed an issue where EKEvent.title (which returns an Objective-C NSString reference) incorrectly printed 'Instance of ObjCObject' by safely unwrapping it with package:objective_c's toDartString() method.
- Updated event fetching to parse startDate into a Dart DateTime. - Refactored UI table to have distinct columns for Title, Date, and Time. - Removed Sample Event boilerplate logic.
- Extracted CreateEventDialog into its own discrete file create_event_dialog.dart. - Integrated CreateEventDialog into main.dart to open on the "Create Event" button press. - Passed calendars explicitly to predicateForEventsWithStartDate to ensure fetching utilizes user's available calendars. - Cleaned up leftover debugPrint statements and updated AppBar title.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pre-launch Checklist