You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

删除Google日历事件后iPhone端消失但MacBook端未同步求助

Google日历事件删除后MacBook端未同步的问题排查与解决

问题描述

使用EventKit获取并删除Google日历事件:
获取事件代码:

let store = EKEventStore()
let predicate = store.predicateForEvents(withStart: startDate, end: endDate, calendars: nil)
let events = store.events(matching: predicate)

删除事件代码:

try store.remove(event, span: .thisEvent, commit: true)

操作后iPhone端日历中事件已移除,但MacBook端Google日历内该事件仍存在;操作iCloud日历事件时,两端同步正常。

排查与解决方案

  • 确认操作的日历实例
    删除前必须验证目标事件所属的日历是否为Google日历,避免操作本地缓存副本:

    print("所属日历:\(event.calendar.title),数据源类型:\(event.calendar.source.type.rawValue)")
    

    同时检查MacBook端Google日历同步设置:打开日历App → 偏好设置 → 账户 → 选中Google账户,确认“日历”已勾选且同步频率为“自动”。

  • 强制触发同步提交
    第三方日历的同步可能需要额外触发刷新,修改删除代码如下:

    try store.remove(event, span: .thisEvent, commit: false)
    try store.commit()
    store.refreshSourcesIfNeeded()
    

    先取消自动提交,手动提交后强制刷新数据源,确保变更同步到服务器。

  • 排查Google日历同步延迟与缓存问题

    1. 等待10-15分钟后检查MacBook端,若未同步,右键点击侧边栏Google日历选择“刷新”;
    2. 查看Google网页版日历,确认事件是否已被删除。若网页版已删除但Mac端未更新,重置Mac日历缓存:
      • 退出日历App;
      • 删除缓存文件:~/Library/Calendars/Calendar Cache;
      • 重新打开日历App等待同步。
  • 验证本地删除状态
    删除后立即重新查询事件,确认本地已移除:

    let recheckEvents = store.events(matching: predicate)
    let isEventLocalRemoved = !recheckEvents.contains { $0.eventIdentifier == event.eventIdentifier }
    print("本地已删除:\(isEventLocalRemoved)")
    

    若本地已删除但Mac端未同步,在iPhone端下拉日历列表手动刷新Google日历。

  • 重置Google账户同步

    • iPhone端:设置→密码与账户→选中Google账户→关闭“日历”后重新开启;
    • MacBook端:系统设置→互联网账户→移除Google账户后重新添加,触发全量同步。

内容的提问来源于stack exchange,提问作者Maxim

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 11:57:31