Mac 控制中心控件 + 小组件扩展 target(Phase 5)
- 新增 WidgetsMac(macOS app-extension):与 iOS CommilitiaDropWidgets 同源(Widgets/ + Shared + Resources/i18n),macOS 26 原生支持 ControlWidget——控制中心两控件(上传 / 拉取云剪贴板)+ 交互式小组件(通知中心 / 桌面,按钮直跑 AppIntent)。嵌入 CommilitiaDropMac(Contents/PlugIns) - ClipboardIntents 跨平台:UIPasteboard 读 / 写加 #if os(macOS) NSPasteboard 分支(上传 / 拉取剪贴板 AppIntent,控制中心与小组件按钮共用)。其余控件源(ClipboardControls ControlWidget / CloudClipboardWidget 交互小组件 / ClipboardClient REST + App Group / WidgetFeedback 本地通知)本就 WidgetKit/AppIntents/Foundation 跨平台,无改 - App Group(读主 app 代铸的 widget_session)仅 Release 挂 Support/macOS/WidgetsMac.entitlements(macOS App Group 属受限能力须 provisioning profile,Phase 6 Developer ID 签名再挂);Debug/ad-hoc 无 App Group——控件 / 小组件编过 + 嵌入 + ad-hoc 签过,但读不到共享会话、呈占位。运行期功能待 Phase 6(App Group Release 挂 app + 扩展 + 签名) - 控件 / 小组件 kind 已在 Phase 1 去缩写为 net.commilitia.Commilitia-Drop.control.*/.widget.clipboard - 验证:just mac-build(CommilitiaDropMac.app + WidgetsMac.appex 嵌入、ad-hoc 签过)+ iOS 模拟器(CommilitiaDrop.app)均 BUILD SUCCEEDED
This commit is contained in:
@@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||||
|
<key>CFBundleDisplayName</key>
|
||||||
|
<string>Commilitia Drop</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>$(EXECUTABLE_NAME)</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>$(PRODUCT_NAME)</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>XPC!</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1</string>
|
||||||
|
<key>NSExtension</key>
|
||||||
|
<dict>
|
||||||
|
<key>NSExtensionPointIdentifier</key>
|
||||||
|
<string>com.apple.widgetkit-extension</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<!-- 与主 app 共享的 App Group:控件 / 小组件读 widget_session.json(主 app 代铸的控件会话)。macOS
|
||||||
|
下 App Group 属受限能力须 provisioning profile,故仅 Release(Developer ID 签名,Phase 6)引用;
|
||||||
|
Debug/ad-hoc 不挂——控件编过但读不到共享会话,呈占位。 -->
|
||||||
|
<key>com.apple.security.application-groups</key>
|
||||||
|
<array>
|
||||||
|
<string>group.net.commilitia.Commilitia-Drop</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
import AppIntents
|
import AppIntents
|
||||||
|
#if canImport(UIKit)
|
||||||
import UIKit
|
import UIKit
|
||||||
|
#elseif canImport(AppKit)
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
// 「上传剪贴板」动作:读本机剪贴板文本,经控件专用会话推到云剪贴板。控制中心控件与主屏小组件按钮
|
// 「上传剪贴板」动作:读本机剪贴板文本,经控件专用会话推到云剪贴板。控制中心控件与主屏小组件按钮
|
||||||
// 共用此 intent。App 外触发时经 WidgetFeedback 弹本地通知反馈成功 / 失败(#6)。
|
// 共用此 intent。App 外触发时经 WidgetFeedback 弹本地通知反馈成功 / 失败(#6)。
|
||||||
@@ -10,7 +14,11 @@ struct UploadClipboardIntent: AppIntent
|
|||||||
|
|
||||||
func perform() async throws -> some IntentResult
|
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 ?? "" }
|
let text = await MainActor.run { UIPasteboard.general.string ?? "" }
|
||||||
|
#endif
|
||||||
guard !text.isEmpty else
|
guard !text.isEmpty else
|
||||||
{
|
{
|
||||||
await WidgetFeedback.post(t("ios.clipboard.empty"))
|
await WidgetFeedback.post(t("ios.clipboard.empty"))
|
||||||
@@ -50,7 +58,15 @@ struct PullClipboardIntent: AppIntent
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if os(macOS)
|
||||||
|
await MainActor.run
|
||||||
|
{
|
||||||
|
NSPasteboard.general.clearContents()
|
||||||
|
NSPasteboard.general.setString(text, forType: .string)
|
||||||
|
}
|
||||||
|
#else
|
||||||
await MainActor.run { UIPasteboard.general.string = text }
|
await MainActor.run { UIPasteboard.general.string = text }
|
||||||
|
#endif
|
||||||
await WidgetFeedback.post(t("ios.clipboard.pulled"))
|
await WidgetFeedback.post(t("ios.clipboard.pulled"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,6 +199,8 @@ targets:
|
|||||||
# 原生数据面 libwebrtc(LibWebRtcEngine)。macOS 切片缺子头,构建经 just mac-prep 补齐
|
# 原生数据面 libwebrtc(LibWebRtcEngine)。macOS 切片缺子头,构建经 just mac-prep 补齐
|
||||||
# (scripts/patch-macos-webrtc-headers.sh)。
|
# (scripts/patch-macos-webrtc-headers.sh)。
|
||||||
- package: WebRTC
|
- package: WebRTC
|
||||||
|
# 控制中心控件 + 小组件扩展(WidgetsMac appex,嵌入 Contents/PlugIns)。macOS 26 原生支持 ControlWidget。
|
||||||
|
- target: WidgetsMac
|
||||||
info:
|
info:
|
||||||
path: Support/macOS/App-Info.plist
|
path: Support/macOS/App-Info.plist
|
||||||
properties:
|
properties:
|
||||||
@@ -245,6 +247,35 @@ targets:
|
|||||||
PRODUCT_BUNDLE_IDENTIFIER: net.commilitia.Commilitia-Drop.mac.tests
|
PRODUCT_BUNDLE_IDENTIFIER: net.commilitia.Commilitia-Drop.mac.tests
|
||||||
ARCHS: arm64
|
ARCHS: arm64
|
||||||
GENERATE_INFOPLIST_FILE: "YES"
|
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:
|
schemes:
|
||||||
CommilitiaDrop:
|
CommilitiaDrop:
|
||||||
build:
|
build:
|
||||||
|
|||||||
Reference in New Issue
Block a user