diff --git a/ios/CDrop/Support/macOS/Widgets-Info.plist b/ios/CDrop/Support/macOS/Widgets-Info.plist
new file mode 100644
index 0000000..29cf963
--- /dev/null
+++ b/ios/CDrop/Support/macOS/Widgets-Info.plist
@@ -0,0 +1,29 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ $(DEVELOPMENT_LANGUAGE)
+ CFBundleDisplayName
+ Commilitia Drop
+ CFBundleExecutable
+ $(EXECUTABLE_NAME)
+ CFBundleIdentifier
+ $(PRODUCT_BUNDLE_IDENTIFIER)
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ $(PRODUCT_NAME)
+ CFBundlePackageType
+ XPC!
+ CFBundleShortVersionString
+ 1.0
+ CFBundleVersion
+ 1
+ NSExtension
+
+ NSExtensionPointIdentifier
+ com.apple.widgetkit-extension
+
+
+
diff --git a/ios/CDrop/Support/macOS/WidgetsMac.entitlements b/ios/CDrop/Support/macOS/WidgetsMac.entitlements
new file mode 100644
index 0000000..c9b9d1f
--- /dev/null
+++ b/ios/CDrop/Support/macOS/WidgetsMac.entitlements
@@ -0,0 +1,13 @@
+
+
+
+
+
+ com.apple.security.application-groups
+
+ group.net.commilitia.Commilitia-Drop
+
+
+
diff --git a/ios/CDrop/Widgets/ClipboardIntents.swift b/ios/CDrop/Widgets/ClipboardIntents.swift
index 2e0015d..57e8e0d 100644
--- a/ios/CDrop/Widgets/ClipboardIntents.swift
+++ b/ios/CDrop/Widgets/ClipboardIntents.swift
@@ -1,5 +1,9 @@
import AppIntents
+#if canImport(UIKit)
import UIKit
+#elseif canImport(AppKit)
+import AppKit
+#endif
// 「上传剪贴板」动作:读本机剪贴板文本,经控件专用会话推到云剪贴板。控制中心控件与主屏小组件按钮
// 共用此 intent。App 外触发时经 WidgetFeedback 弹本地通知反馈成功 / 失败(#6)。
@@ -10,7 +14,11 @@ struct UploadClipboardIntent: AppIntent
func perform() async throws -> some IntentResult
{
+ #if os(macOS)
+ let text = await MainActor.run { NSPasteboard.general.string(forType: .string) ?? "" }
+ #else
let text = await MainActor.run { UIPasteboard.general.string ?? "" }
+ #endif
guard !text.isEmpty else
{
await WidgetFeedback.post(t("ios.clipboard.empty"))
@@ -50,7 +58,15 @@ struct PullClipboardIntent: AppIntent
}
else
{
+ #if os(macOS)
+ await MainActor.run
+ {
+ NSPasteboard.general.clearContents()
+ NSPasteboard.general.setString(text, forType: .string)
+ }
+ #else
await MainActor.run { UIPasteboard.general.string = text }
+ #endif
await WidgetFeedback.post(t("ios.clipboard.pulled"))
}
}
diff --git a/ios/CDrop/project.yml b/ios/CDrop/project.yml
index 8b3830d..d00d310 100644
--- a/ios/CDrop/project.yml
+++ b/ios/CDrop/project.yml
@@ -199,6 +199,8 @@ targets:
# 原生数据面 libwebrtc(LibWebRtcEngine)。macOS 切片缺子头,构建经 just mac-prep 补齐
# (scripts/patch-macos-webrtc-headers.sh)。
- package: WebRTC
+ # 控制中心控件 + 小组件扩展(WidgetsMac appex,嵌入 Contents/PlugIns)。macOS 26 原生支持 ControlWidget。
+ - target: WidgetsMac
info:
path: Support/macOS/App-Info.plist
properties:
@@ -245,6 +247,35 @@ targets:
PRODUCT_BUNDLE_IDENTIFIER: net.commilitia.Commilitia-Drop.mac.tests
ARCHS: arm64
GENERATE_INFOPLIST_FILE: "YES"
+ # 控制中心控件 + 小组件扩展(macOS)。与 iOS CommilitiaDropWidgets 同源(Widgets/),macOS 26 原生支持
+ # ControlWidget;WidgetKit 无多平台扩展故单列 target。排除 iOS 的 Info.plist / 旧 entitlements。App Group
+ # 仅 Release 挂(受限能力须 profile,Phase 6 签名);Debug/ad-hoc 无 App Group——控件编过但读不到主 app
+ # 代铸的 widget_session,呈占位。控件 / 小组件 kind 已在 Phase 1 去缩写为 net.commilitia.Commilitia-Drop.*。
+ WidgetsMac:
+ type: app-extension
+ platform: macOS
+ deploymentTarget: "26.0"
+ sources:
+ - path: Widgets
+ excludes:
+ - Info.plist
+ - CDropWidgets.entitlements
+ - path: Shared
+ - path: Sources/Resources/i18n
+ info:
+ path: Support/macOS/Widgets-Info.plist
+ properties:
+ CFBundleDisplayName: Commilitia Drop
+ NSExtension:
+ NSExtensionPointIdentifier: com.apple.widgetkit-extension
+ settings:
+ base:
+ PRODUCT_BUNDLE_IDENTIFIER: net.commilitia.Commilitia-Drop.widgets
+ PRODUCT_NAME: WidgetsMac
+ ARCHS: arm64
+ configs:
+ Release:
+ CODE_SIGN_ENTITLEMENTS: Support/macOS/WidgetsMac.entitlements
schemes:
CommilitiaDrop:
build: