- ✅ 所有新功能使用 Swift/SwiftUI 实现
- ❌ 绝对禁止添加新的 Objective-C 文件
- 🔄 修改现有 Objective-C 代码前,必须先迁移到 Swift
- ⚡ 重写 Objective-C 代码必须使用 Swift
- 🚫 任何形式的 Objective-C 代码扩展都被禁止
- Swift/SwiftUI 是项目未来的唯一技术栈
- Objective-C 代码仅允许 bug 修复
- 所有贡献者必须遵守此政策
- 违反此政策的 PR 将被拒绝
Easydict 是一个 macOS 翻译和词典应用,正在进行从 Objective-C 到 Swift + SwiftUI 的逐步迁移。
| 服务名称 | 原文件名 | 新文件名 | 完成时间 | 提交记录 |
|---|---|---|---|---|
| Google 翻译 | EZGoogleTranslate | GoogleService | 2024-12 | refactor(objc-to-swift): migrate EZGoogleTranslate to Swift |
| Bing 翻译 | EZBingService | BingService | 2024-12 | refactor(objc-to-swift): migrate EZBingService to Swift |
| 有道翻译 | EZYoudaoTranslate | YoudaoService | 2024-12 | refactor(objc-to-swift): migrate EZYoudaoTranslate to Swift |
| NiuTrans 翻译 | EZNiuTransTranslate | NiuTransService | 2024-12 | refactor(objc-to-swift): migrate EZNiuTransTranslate to Swift |
| DeepL 翻译 | EZDeepLTranslate | DeepLService | 2024-12 | refactor(objc-to-swift): migrate EZDeepLTranslate to Swift |
| 苹果词典 | EZAppleDictionary | AppleDictionary | 2025-01 | refactor(objc-to-swift): migrate EZAppleDictionary to Swift |
| 百度翻译 | EZBaiduTranslate | BaiduService | 2025-03 | refactor(objc-to-swift): migrate EZBaiduTranslate to Swift |
| 名称 | 原文件名 | 新文件名 | 完成时间 | 提交记录 |
|---|---|---|---|---|
| 查询服务基类 | EZQueryService | QueryService | 2025-03 | refactor(objc-to-swift): migrate EZQueryService to Swift |
| 组件名称 | 原文件名 | 新文件名 | 完成时间 | 备注 |
|---|---|---|---|---|
| 文本分割 | NSString+EZSplit | String+Split | 2025-01-29 | 分割驼峰和下划线文本 |
| 输入文本处理 | NSString+EZHandleInputText | String+HandleInputText | 2025-01-29 | 完整的输入文本处理功能 |
| 字符串便利 | NSString+EZConvenience | String+Convenience | 2025-02-17 | URL 编码、剪贴板、XML 转义、MD5 等 |
| 服务名称 | 状态 | 备注 |
|---|---|---|
| OpenAI | ✅ | GPT-4 集成 |
| DeepSeek | ✅ | DeepSeek API |
| Gemini | ✅ | Google Gemini |
| Ollama | ✅ | 本地模型支持 |
| Volcano | ✅ | 火山翻译 |
| 月之暗面 | ✅ | Kimi API |
| 零一万物 | ✅ | Yi API |
| 智谱清言 | ✅ | ChatGLM |
| 通义千问 | ✅ | 阿里云大模型 |
| 腾讯混元 | ✅ | 腾讯大模型 |
| 百度文心 | ✅ | 百度大模型 |
| Coze | ✅ | 字节跳动 AI |
| 阿里通义 | ✅ | 已完成 |
| MiniMax | ✅ | 海螺 AI |
| 组件名称 | 原文件名 | 新文件名 | 状态 |
|---|---|---|---|
| 有序字典 | MMOrderedDictionary | MMOrderedDictionary | ✅ |
| AppleScript | - | AppleScriptIntegration | ✅ |
| 文本选择 | AXUI | TextSelection | ✅ |
| 离线翻译 | - | OfflineTranslation | ✅ |
| SwiftPM | - | Package.swift | ✅ |
| 暗色模式 | DarkModeManager/NSObject+DarkMode/Singleton | DarkModeManager.swift + Extensions | ✅ |
| 服务信息 | EZServiceInfo | EZServiceInfo.swift | ✅ |
| 本地存储 | EZLocalStorage | EZLocalStorage.swift | ✅ |
| 应用模型 | EZAppModel | EZAppModel.swift | ✅ |
| 服务类型 | EZServiceTypes | ServiceTypes.swift | ✅ |
| 扩展名称 | 原文件名 | 新文件名 | 状态 |
|---|---|---|---|
| 字符串布局 | - | String+Layout | ✅ |
| 颜色扩展 | NSColor+... | NSColor+... | ✅ |
| Logging | EZLog | EZLog.swift | ✅ |
| Device Info | EZDeviceSystemInfo | EZDeviceSystemInfo.swift | ✅ |
- 翻译服务: 6/13 已完成 (46%)
- AI 服务: 14/14 已完成 (100%)
- 基础设施: 10/10 已完成 (100%)
- 工具扩展: 5/15 已完成 (33%)
- 目标: 成功创建
String+HandleInputText.swift - 状态: ✅ 完成
- 实际时间: 1 天
- 成果:
- 创建了
String+Split.swift依赖文件 - 创建了
String+HandleInputText.swift主要实现 - 创建了
String+HandleInputTextTests.swift完整测试 - 更新了 bridging header 移除旧 import
- 修复了 AppleDictionary.swift 中的调用
- 修复了所有 SwiftLint 违规和编译错误
- 通过了所有 SwiftLint 检查 (0 violations)
- 创建了
- 目标: 使用 Swift 完全重写 DarkMode 模块
- 状态: ✅ 完成
- 实际时间: 1 天
- 成果:
- 创建了
DarkModeManager.swift统一的暗色模式管理器 - 创建了
DarkModeProtocol.swift提供响应式暗色模式协议 - 创建了
NSObject+DarkMode.swift和NSView+DarkMode.swift扩展 - 使用 Combine 替代 ReactiveObjC,移除额外依赖
- 更新了
AppDelegate.m和Configuration.swift的调用 - 移除了 4 个 Objective-C 文件和整个 DarkMode 目录
- 更新了
PrefixHeader.pch移除旧导入 - 更新了
MIGRATION_PROGRESS.md记录迁移进度
- 创建了
- 目标: 使用 Swift 重写
NSString+EZConvenience - 状态: ✅ 完成
- 成果:
- 新增
String+Convenience.swift,覆盖 URL 编码/解码、剪贴板操作、XML 转义、MD5、段落拆分等方法 - 删除旧的 Objective-C 分类,更新 PCH、Bridging Header 和 Xcode 工程引用
- 新增
- 目标: 迁移存储相关类到 Swift
- 状态: ✅ 完成
- 成果:
- 迁移
EZServiceInfo到 Swift,添加 Codable 支持 - 迁移
EZLocalStorage到 Swift,使用现代属性访问器 - 保持 @objcMembers 注解以兼容 Objective-C 代码
- 更新 bridging header 移除不再需要的导入
- 迁移
- 目标: 迁移 EZAppModel 到 Swift
- 状态: ✅ 完成
- 成果:
- 从 objc/Legacy/ 迁移到 Swift/Model/
- 添加全面的文档注释
- 实现 NSSecureCoding 协议
- 添加便捷的字典转换方法
- 移除 MJExtension/KVC 依赖
- 目标: 迁移 EZServiceTypes 到 Swift
- 状态: ✅ 完成
- 成果:
- 使用
ServiceTypes.swift替换 EZServiceTypes.h/.m - 保持 API 兼容性,使用 @objc 属性
- 保留单例模式和所有公共方法
- 更新代码库中的所有导入语句
- 使用
- 目标: 重命名类以符合更清晰的命名约定
- 状态: ✅ 完成
- 成果:
- 统一命名规范,提高代码可读性
- 更新相关引用和文档
- 目标: 移除未使用的 DeepL API 枚举和相关代码
- 状态: ✅ 完成
- 成果:
- 删除 EZDeepLTranslationAPI 枚举
- 清理冗余代码,简化架构
- Goal: Migrate EZQueryResult and related word result models to Swift.
- Status: ✅ Completed
- Outcome:
- Added Swift implementation in
Swift/Service/Model/EZQueryResult.swift. - Removed Objective-C
EZQueryResult.h/.mand updated ObjC headers to forward declarations. - Updated project references to use the Swift implementation.
- Added Swift implementation in
- Goal: Migrate EZLog and EZDeviceSystemInfo to Swift utilities.
- Status: ✅ Completed
- Outcome:
- Added
Swift/Utility/Logging/EZLog.swiftandSwift/Utility/DeviceInfo/EZDeviceSystemInfo.swift. - Updated ObjC call sites to import
Easydict-Swift.h. - Removed legacy ObjC sources from the build phase.
- Added
- Goal: Migrate EZDetectManager to Swift for text detection and OCR functionality.
- Status: ✅ Completed
- Outcome:
- Added
Swift/Service/Model/DetectManager.swiftwith complete implementation. - Used
@objc(EZDetectManager)and@objcMembersfor Objective-C compatibility. - Added async/await versions of methods for Swift code.
- Updated
EZBaseQueryViewController.mto importEasydict-Swift.h. - Updated
Easydict-Bridging-Header.hto comment out old Objective-C import.
- Added
- EZDetectManager ✅ - 文本检测管理器
- 位置:
Swift/Service/Model/DetectManager.swift - 影响: 语言检测和 OCR 功能
- 优先级: 高
- ✅ 已完成迁移到 Swift
- 状态: ✅ 完成
- 实际时间: 2026-01-06
- 成果:
- 创建了
Swift/Service/Model/DetectManager.swift完整的 Swift 实现 - 使用
@objc(EZDetectManager)和@objcMembers保持 Objective-C 兼容性 - 添加了 async/await 版本的方法支持 Swift 代码调用
- 更新了
EZBaseQueryViewController.m导入Easydict-Swift.h - 更新了
Easydict-Bridging-Header.h注释掉旧的 Objective-C 导入
- 创建了
- 位置:
-
AppDelegate - 应用代理
- 位置:
objc/AppDelegate.h/.m - 影响: 应用生命周期管理
- 优先级: 中高
⚠️ 重写时必须使用 Swift
- 位置:
-
EZWindowManager - 窗口管理器
- 位置:
objc/ViewController/Window/EZWindowManager.h/.m - 影响: 所有窗口功能
- 优先级: 中高
⚠️ 禁止修改,必须迁移到 Swift
- 位置:
-
EZLocalStorage - 本地存储 ✅
- 已于 2025-12-17 迁移到 Swift
- 新位置:
objc/ViewController/Storage/EZLocalStorage.swift
- EZBaseQueryViewController - 基础查询控制器
- 位置:
objc/ViewController/Window/BaseQueryWindow/EZBaseQueryViewController.m - 行数: ~1700 行
- 影响: 核心用户界面
- 优先级: 中
⚠️ 禁止修改,必须迁移到 Swift
- 位置:
- NSString+EZChineseText - 中文文本处理
⚠️ 禁止修改,必须迁移到 Swift
- NSString+EZUtils - 字符串工具
⚠️ 禁止修改,必须迁移到 Swift
- NSString+EZSplit - 文本分割
⚠️ 禁止修改,必须迁移到 Swift
- NSColor+MyColors - 颜色扩展
⚠️ 重写时必须使用 Swift
- EZLanguageManager - 语言管理
⚠️ 重写时必须使用 Swift
- EZEventMonitor - 事件监控
⚠️ 重写时必须使用 Swift
- EZLog - 日志工具
⚠️ 重写时必须使用 Swift
- DarkModeManager - 深色模式
⚠️ 重写时必须使用 Swift
- MMLog - 日志框架
⚠️ 重写时必须使用 Swift
- MMCrash - 崩溃处理
⚠️ 重写时必须使用 Swift
🚨 重要约束:禁止添加新的 Objective-C 代码,所有重写必须使用 Swift
- Apple Dictionary
- EZQueryService (基类) - 已迁移至 Swift
- EZBaiduTranslate - 已迁移至 Swift
- EZDetectManager - 必须使用 Swift
- EZLocalStorage - ✅ 已完成 (2025-12-17)
- AppDelegate - 必须使用 Swift
- EZWindowManager - 禁止修改,必须迁移到 Swift
- EZLanguageManager - 必须使用 Swift
- EZBaseQueryViewController - 禁止修改,必须迁移到 Swift
- 其他 ViewController - 必须使用 Swift
- 所有 NSString 扩展 - 禁止修改,必须迁移到 Swift
- 日志和监控 - 必须使用 Swift
- 性能优化 - 必须使用 Swift
- 完全移除 Objective-C
- ✅ SwiftLint 检查通过
- ✅ 单元测试覆盖
- ✅ 代码审查
- ✅ 性能测试
- ✅ 所有原有功能保持不变
- ✅ 新增功能符合设计
- ✅ 兼容性测试
- ✅ 用户反馈收集
- ❌ 绝对禁止添加新的 Objective-C 文件
- 🔍 代码审查:拒绝任何新的 Objective-C 代码
- 🚫 Objective-C 代码仅允许 bug 修复
- 📈 Swift/SwiftUI 作为未来的唯一技术栈
- 🛡️ CI 检查:防止新的 .m/.h 文件提交
- 2024年12月: 完成主要翻译服务迁移
- 2025年1月: 完成 Apple Dictionary 和 AI 服务
- 2025年3月: 完成核心服务层
- 2025年6月: 完成应用架构层
- 2025年9月: 完成 UI 层
- 2025年12月: 完全 Swift 化
最后更新: 2025-12-22