Skip to content

Adds iOS Calendar Demo using ffigen#125

Merged
jwill merged 8 commits into
mainfrom
ios_interop_demo
Jun 13, 2026
Merged

Adds iOS Calendar Demo using ffigen#125
jwill merged 8 commits into
mainfrom
ios_interop_demo

Conversation

@jwill

@jwill jwill commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Pre-launch Checklist

  • I signed the CLA.

jwill added 8 commits June 12, 2026 20:00
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.
@jwill jwill merged commit abb55f1 into main Jun 13, 2026
5 checks passed
@jwill jwill deleted the ios_interop_demo branch June 13, 2026 05:51
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

Successfully merging this pull request may close these issues.

1 participant