Sample CodeiOS, iPadOS, Mac CatalystReviewed 2026-07-21View on Apple Developer

Integrating your calendar app with Apple Intelligence

At a glance

Item Summary
Purpose Adopt calendar schemas so people can create, find, and manage events with Siri.
App architecture A Swift sample with the source-visible chain CometCalAppCalendarListViewCalendarManagerAppIntents / AppIntentsTesting APIs.
Main patterns No named application pattern supported by the extracted structure
Project style 47 scanned source file(s) across Swift, organized around ranked entry, type, and file boundaries.
Execution model Source-visible boundaries: @MainActor, async declaration or closure, Task; none alone proves a background thread.
State/event model Source-visible mechanisms: @Observable, SwiftUI state property wrapper.
Key frameworks/packages AppIntents, SwiftData, SwiftUI, AppIntentsTesting, GeoToolbox; these are source dependencies, not architecture labels.

Project structure

Source bundle/
└── CometCal/
    ├── CometCalApp.swift
    ├── Model/
    │   ├── AttendeeModel.swift
    │   ├── EventModel.swift
    │   ├── CalendarModel.swift
    │   └── ContactModel.swift
    ├── Views/
    │   ├── CalendarManagerView.swift
    │   ├── CalendarListView.swift
    │   ├── ContactDetailView.swift
    │   └── ContactPickerView.swift
    ├── AppIntents/
    │   └── Entities/
    │       └── EventEntity.swift
    └── Managers/
        ├── CalendarManager.swift
        └── NavigationManager.swift

Structure observations

  • Architecturally prominent files are ranked from entry points and role-named declarations; resource-only paths are omitted.
  • Primary languages: Swift.
  • The verified tree contains 3 project/configuration file(s) and 59 source declaration(s).

Overall architecture

Reference code

CometCal/CometCalApp.swift:11 — architecture anchor

@main
struct CometCalApp: App {
    // ...
    init() {
        let manager = CalendarManager.shared
        AppDependencyManager.shared.add(dependency: manager)
    }
    // ...
}

Interpretation

The arrows summarize the source-visible entry, role-named types or folders, and framework direction; when nodes come from structural folders, the sequence is a high-level interpretation rather than proof that every adjacent node calls the next. Ownership is claimed only where the next section cites a stored property or assignment. The diagram is intentionally limited to the dominant path into App Intents.

Ownership and state

Ownership evidence

CometCal/AppIntents/Entities/EventEntity.swift:16 — stored dependency or nearest verified ownership anchor

@AppEntity(schema: .calendar.event)
struct EventEntity: IndexedEntity, OwnershipProvidingEntity {
    // ...
    static let defaultQuery = EventEntityQuery()
    // ...
}
Owner Object or state Relationship Mutation authority
EventEntity EventEntityQuery (defaultQuery) creates and retains Initialized by the owner; the binding is immutable
EventEntity UUID (id) owns value state App/module collaborators
EventEntity CalendarEntity (calendar) stores or receives App/module collaborators
EventEntity String (title) owns value state App/module collaborators

Composition arrows indicate a source-visible construction expression or locally owned value state; aggregation means the owner stores or receives a dependency without proving exclusive lifetime ownership.

Concurrency, scheduling, and thread safety

Evidence limit: actor isolation, async/await, or Task creation does not by itself prove background-thread execution; Sendable conformance alone does not prove thread-safe mutation.

Concern Source mechanism Verified placement or handoff Evidence
Main isolation @MainActor The cited annotation marks its attached declaration or closure as main-actor isolated. CometCal/AppIntents/Entities/CalendarEntity.swift:38
Suspension boundary async declaration or closure The source declares or crosses an asynchronous boundary; it does not by itself establish background execution. CometCal/AppIntents/Entities/CalendarEntity.swift:43
Task creation Task The source creates an unstructured task; surrounding context determines inherited actor isolation. CometCal/Managers/CalendarManager+EventUpdates.swift:79

@MainActor/MainActor.run, DispatchQueue.main, and RunLoop.main are reported as distinct isolation, queue, and event-loop mechanisms. A plain Task is kept separate from Task.detached; neither is labeled as a background thread.

Reference code

CometCal/AppIntents/Entities/CalendarEntity.swift:38 — representative execution boundary

    @MainActor
    struct CalendarEntityQuery: EnumerableEntityQuery, EntityStringQuery {
        // ...
        var calendarManager: CalendarManager
        // ...
    }

State propagation, frameworks, and dependencies

Evidence limit: an import proves a source-level compilation dependency at the cited line; it does not prove runtime use, architectural adoption, or whether a Swift package is a direct application dependency.

Category Mechanism or module Verified role Evidence
State propagation @Observable Observation macro publishes source-visible changes. CometCal/Managers/CalendarManager.swift:13
State propagation SwiftUI state property wrapper A SwiftUI property wrapper supplies or observes UI state. CometCal/Views/CalendarListView.swift:16
Source import AppIntents The cited file imports this module; runtime use and architectural role are not inferred. CometCal/AppIntents/Entities/AttendeeEntity.swift:7
Source import SwiftData The cited file imports this module; runtime use and architectural role are not inferred. CometCal/AppIntents/TestSupport/TestDataHelper.swift:8
Source import SwiftUI The cited file imports this module; runtime use and architectural role are not inferred. CometCal/AppIntents/Intents/UpdateEventIntent.swift:9
Source import AppIntentsTesting The cited file imports this module; runtime use and architectural role are not inferred. CometCalUITests/DataSeedingTests.swift:7
Source import GeoToolbox The cited file imports this module; runtime use and architectural role are not inferred. CometCal/AppIntents/Entities/EventEntity.swift:9
Source import XCTest The cited file imports this module; runtime use and architectural role are not inferred. CometCalUITests/DataSeedingTests.swift:8

receive(on:) describes downstream delivery scheduling, while subscribe(on:) describes upstream subscription/request/cancel scheduling. An import Combine alone establishes neither behavior nor a Store, reducer, Redux, or other application architecture.

Class and protocol design

CometCal/CometCalApp.swift:12 — representative type boundary

@main
struct CometCalApp: App {
    // ...
        let manager = CalendarManager.shared
    // ...
}
Type Responsibility Depends on or conforms to
CometCalApp Application entry and top-level composition App
AttendeeModel Feature data or observable state Concrete collaborators/imported frameworks
EventModel Feature data or observable state Concrete collaborators/imported frameworks
CalendarManagerView User-interface presentation and input forwarding View
CalendarFormView User-interface presentation and input forwarding View
CalendarModel Feature data or observable state Concrete collaborators/imported frameworks
CalendarListView User-interface presentation and input forwarding View
CalendarManager Long-lived feature or framework coordination Concrete collaborators/imported frameworks
NavigationManager Long-lived feature or framework coordination Concrete collaborators/imported frameworks
ContactModel Feature data or observable state Concrete collaborators/imported frameworks

No local protocol conformance is claimed as protocol-oriented design; external framework conformances are listed only as dependencies.

Access control

Symbol Access Verified effect Likely rationale
resolveCalendar (CometCal/AppIntents/Intents/UpdateEventIntent.swift:70) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: hide an implementation step that is not part of the collaboration surface.
resolveLocation (CometCal/AppIntents/Intents/UpdateEventIntent.swift:75) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: hide an implementation step that is not part of the collaboration surface.
resolveAttendees (CometCal/AppIntents/Intents/UpdateEventIntent.swift:100) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: hide an implementation step that is not part of the collaboration surface.
resolveRecurrence (CometCal/AppIntents/Intents/UpdateEventIntent.swift:114) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: hide an implementation step that is not part of the collaboration surface.

Reference code

CometCal/AppIntents/Intents/UpdateEventIntent.swift:70 — representative boundary

    @MainActor
    private func resolveCalendar() throws -> CalendarModel? {
        guard let calendar else { return nil }
        return try calendarManager.fetchCalendars().first(where: { $0.id == calendar.id })
    }

Swift declarations without a modifier are internal; explicit private, fileprivate, private(set), public, or open entries above are interpreted by language semantics. Objective-C/C samples instead rely on header and implementation boundaries, which are not equivalent to Swift lexical privacy.

Logic ownership and placement

Logic Owning type or file Placement rationale
Application entry and top-level composition CometCalApp The source’s App suffix makes this role explicit.
Long-lived feature or framework coordination CalendarManager, NavigationManager The source’s Manager suffix makes this role explicit.
Feature data or observable state AttendeeModel, CalendarModel, ContactModel, EventModel The source’s Model suffix makes this role explicit.
User-interface presentation and input forwarding CalendarFormView, CalendarListView, CalendarManagerView, ContactDetailView The source’s View suffix makes this role explicit.

Design patterns

Pattern Source evidence Purpose or tradeoff
No named application pattern CometCal/CometCalApp.swift:11 The verified source directly composes concrete framework types; this document avoids forcing a pattern name.

Main application flow

Reference code

CometCal/Managers/CalendarManager.swift:267deleteEvent()

    func deleteEvent(_ event: EventModel, donateIntent: Bool = true) throws {
        modelContext.delete(event)
        try modelContext.save()

        // Remove the event from Spotlight.
        Task {
            try? await searchableIndex.deleteAppEntities(
                identifiedBy: [event.entity.id],
                ofType: EventEntity.self
            )
        }

        if donateIntent {
            let intent = DeleteEventIntent()
            intent.entity = event.entity
            Task {
                try? await IntentDonationManager.shared.donate(intent: intent)
            }
        }
    }

Naming conventions

  • Types: App: CometCalApp; Manager: CalendarManager, NavigationManager; Model: AttendeeModel, CalendarModel, ContactModel, EventModel; View: CalendarFormView, CalendarListView, CalendarManagerView, ContactDetailView, ContactPickerView.
  • Protocols: no local protocol declaration in the scanned source.
  • Methods: toRecurrenceRule, from, deleteCalendars, color, save, allEntities, entities, suggestedEntities.
  • Files: CometCal/CometCalApp.swift, CometCal/Model/AttendeeModel.swift, CometCal/Model/EventModel.swift, CometCal/Views/CalendarManagerView.swift, CometCal/Model/CalendarModel.swift, CometCal/AppIntents/Entities/EventEntity.swift.

Architecture takeaways

  • CometCalApp is the main source-visible entry or composition anchor for this sample.
  • Framework work reaches AppIntents, SwiftData, SwiftUI, AppIntentsTesting through a deliberately small high-level chain; the detailed API graph remains inside the cited implementation files.
  • Stored-property evidence identifies lifecycle collaboration; it does not by itself prove exclusive object ownership.
  • Access-control conclusions separate verified language visibility from the likely design rationale.
  • The source does not justify labeling the design protocol-oriented.

Source map

Source file Relevant symbols
CometCal/CometCalApp.swift Cited implementation, CometCalApp
CometCal/AppIntents/Entities/EventEntity.swift Cited implementation, GeoToolbox, EventEntity, EventEntityQuery, EventEntityStatus, EventSpan, EventLocation, EventAlarm
CometCal/AppIntents/Intents/UpdateEventIntent.swift Cited implementation, SwiftUI, UpdateEventIntent
CometCal/AppIntents/Entities/CalendarEntity.swift @MainActor, async declaration or closure, CalendarEntity, CalendarEntityQuery
CometCal/Managers/CalendarManager+EventUpdates.swift Task, Feature implementation
CometCal/Managers/CalendarManager.swift @Observable, CalendarManager
CometCal/Views/CalendarListView.swift SwiftUI state property wrapper, CalendarListView, EventSection
CometCal/AppIntents/Entities/AttendeeEntity.swift AppIntents, AttendeeEntity, ParticipantStatus, AttendeeType
CometCal/AppIntents/TestSupport/TestDataHelper.swift SwiftData, TestDataHelper
CometCalUITests/DataSeedingTests.swift AppIntentsTesting, XCTest, DataSeedingTests
CometCal/Model/AttendeeModel.swift AttendeeModel, AttendeeStatusValue
CometCal/Model/EventModel.swift EventModel, RecurrenceFrequency
CometCal/Views/CalendarManagerView.swift CalendarManagerView, CalendarFormView, Mode, CalendarColorOption
CometCal/Model/CalendarModel.swift CalendarModel
CometCal/Managers/NavigationManager.swift NavigationManager
CometCal/Model/ContactModel.swift ContactModel