桌面版 ~/Desktop/lolama 的跨平台移植,目标:iOS / iPadOS / macOS native / watchOS,UI 全部使用原生 SwiftUI。
| 平台 | 状态 | 入口 |
|---|---|---|
| iOS / iPadOS | ✅ 编译通过 | ContentView (Compact + Regular) |
| macOS native | ✅ 编译通过 | ContentView (Regular only) |
| visionOS | ContentView (Regular) |
|
| watchOS | WatchRootView |
xcodebuild -destination 'platform=macOS' 与 xcodebuild -destination 'generic/platform=iOS Simulator' 均通过。
- LiteRT (Gemma 4 E2B) 端侧推理已用桩替代(
Platform/LiteRTStub.swift),始终notInstalled。原因:LiteRT C++ vendor 库无法跨 macOS / watchOS 编译。如需在 iOS 启用,把Vendor/LiteRTLM-Swift加回工程并删除LiteRTStub.swift。 - Notifications + 后台定位 全部
#if os(iOS),只在 iPhone/iPad 编译。SettingsView 的"智能通知"入口也只在 iOS 显示。 - HealthKit / CoreMotion 在 macOS 上自动跳过(返回空
EnvironmentSnapshot/ActivitySnapshot)。 - AVAudioSession / 状态栏 / fullScreenCover / EditMode /
.keyboardType/.textInputAutocapitalization/.toolbar(.hidden, for: .tabBar)等 iOS-only API 全部加了#if os(iOS) || os(visionOS)守卫。 - macOS 用
NavigationSplitViewStyle(.balanced),iOS regular 用.prominentDetail。
Platform/PlatformShims.swift—— 跨平台 Color / Pasteboard / 触觉反馈 / Toolbar placement / 数字密码键盘 shim。Platform/LiteRTStub.swift——LiteRTLLMService/LiteRTModelManager桩,与原 API 形状一致。Platform/PreviewSupport.swift——#Preview用的样本数据(原本散在ContentView里)。Platform/WatchRootView.swift—— watchOS 精简 UI。
watchOS 独立 app 需要单独的 bundle (WKApplication + watch 专用 Info.plist + entitlement),手工改 pbxproj 风险高,所以这一步留给 Xcode UI:
- 打开
lolama.xcodeproj - File → New → Target → watchOS → App
- Product Name:
lolama Watch,Bundle ID:com.qingyon.lolama.watchkitapp - 把 watchOS 需要的源文件加入新 target 的 Membership(Inspector 右侧):
Platform/WatchRootView.swiftPlatform/PlatformShims.swiftPlatform/LiteRTStub.swiftRecordStore.swift,SwiftDataStorage.swift,L10n.swift,AppLogger.swift,AppLanguage.swift,KeychainStore.swift,AppLockStore.swiftComponents/AppColors.swift,Components/HabitPresets.swift(只要HabitVisual)Localizable.xcstrings
- 在新 target 的入口文件里写:
@main struct LolamaWatchApp: App { @StateObject private var store = RecordStore() @StateObject private var appLock = AppLockStore() var body: some Scene { WindowGroup { WatchRootView() .environmentObject(store) .environmentObject(appLock) } } }
- watch 上不需要的(Notifications、Chat、Settings、Stats 等)不加进 watch target,自动跳过。
watch UI 已经精简到三件事:记录速记 / 习惯列表 / 今日总数,跟你"watchOS 只具备必要功能"的要求一致。
xcodebuild -project lolama.xcodeproj -scheme lolama -destination 'platform=macOS' build或在 Xcode 里把 destination 切到 "My Mac"。
- macOS 上
EnvironmentDataFetcher不会真实采集步数 / 心率 / 气压(这些 API 不存在),只采集天气。 - Mac Catalyst 没启用,目标是 macOS native binary。
- 字符串目录
Localizable.xcstrings直接复用桌面版,所有翻译保留。