Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions PRODUCT_CAPABILITIES.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 微信流(WeChatBridge)产品能力文档

> 基于 main 分支当前代码整理
> 平台:macOS 14 及以上
> 平台:macOS 13 及以上
> 文档日期:2026-09-20

## 1. 产品定义
Expand Down Expand Up @@ -206,7 +206,7 @@

## 10. 已知限制

1. 仅支持 macOS 14 及以上。
1. 仅支持 macOS 13(Ventura)及以上。
2. 微信分享菜单入口数量在构建时固定,不能为每个已安装应用动态生成。
3. 任意应用扩展通过“发送到自定义”解决。
4. 自动粘贴依赖辅助功能权限、目标 App 可激活性和窗口焦点。
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@

| 平台 | 下载地址 | 提取密码 |
| --- | --- | --- |
| macOS 14+(Apple Silicon 与 Intel) | [wwbsr.lanzout.com/b0umjur8h](https://wwbsr.lanzout.com/b0umjur8h) | `向明` |
| macOS 13+(Apple Silicon 与 Intel) | [wwbsr.lanzout.com/b0umjur8h](https://wwbsr.lanzout.com/b0umjur8h) | `向明` |
| Windows | [wwbsr.lanzout.com/b0umjur4d](https://wwbsr.lanzout.com/b0umjur4d) | `向明` |

macOS 版打开 DMG,把「微信流」拖入「应用程序」即可;Windows 版解压后按目录内说明运行。iOS 版正在开发中,进群可以第一时间知道进展。
macOS 版打开 DMG,把「微信流」拖入「应用程序」即可(图标带 🚫 或提示「无法验证」见[常见问题](USAGE.zh-CN.md#常见问题));Windows 版解压后按目录内说明运行。iOS 版正在开发中,进群可以第一时间知道进展。

## 加入交流群

Expand Down
4 changes: 2 additions & 2 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ Free to download. All installers are distributed through Lanzou Cloud, and the e

| Platform | Download | Password |
| --- | --- | --- |
| macOS 14+ (Apple Silicon and Intel) | [wwbsr.lanzout.com/b0umjur8h](https://wwbsr.lanzout.com/b0umjur8h) | `向明` |
| macOS 13+ (Apple Silicon and Intel) | [wwbsr.lanzout.com/b0umjur8h](https://wwbsr.lanzout.com/b0umjur8h) | `向明` |
| Windows | [wwbsr.lanzout.com/b0umjur4d](https://wwbsr.lanzout.com/b0umjur4d) | `向明` |

On macOS, open the DMG and drag WeChatBridge into Applications. On Windows, unzip the archive and follow the instructions inside. An iOS version is in development—join the group to hear about it first.
On macOS, open the DMG and drag WeChatBridge into Applications (if the icon shows a 🚫 or macOS says it cannot verify the app, see the [FAQ](USAGE_EN.md#faq)). On Windows, unzip the archive and follow the instructions inside. An iOS version is in development—join the group to hear about it first.

## Join the community

Expand Down
14 changes: 14 additions & 0 deletions USAGE.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,20 @@

## 常见问题

**图标上有个 🚫,拖不进「应用程序」?**
这是 0.1.15 及更早的安装包只支持 macOS 14 的标志。新版本已支持 macOS 13(Ventura)及以上,重新下载最新版即可。macOS 12 及更早版本暂不支持。

**提示「Apple 无法验证“微信流”是否包含恶意软件」或「已损坏」?**
早期安装包没有经过 Apple 公证,新版本会修复。已经下载的旧包可以这样打开(只对从本项目蓝奏云链接下载的安装包这样做):

1. 先把「微信流」拖进「应用程序」,双击打开一次,在弹窗里点「完成」。
2. 打开「系统设置 → 隐私与安全性」,滚到底部,在「已阻止使用“微信流”」旁点「仍要打开」,输入开机密码确认。
3. 如果没有出现「仍要打开」,在「终端」里执行下面这行后再双击打开:

```bash
xattr -dr com.apple.quarantine /Applications/微信流.app
```

**入口没有出现在微信菜单里?**
先确认对应开关已打开,再到「系统设置 → 通用 → 登录项与扩展 → 共享」里检查扩展是否启用。系统有时需要重启微信才会刷新菜单。

Expand Down
14 changes: 14 additions & 0 deletions USAGE_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,20 @@ Conversation content only comes from files WeChat exports on your request. WeCha

## FAQ

**The icon shows a 🚫 and will not drag into Applications.**
Builds up to 0.1.15 required macOS 14. Newer builds run on macOS 13 (Ventura) and later; download the latest one. macOS 12 and earlier are not supported.

**macOS says “Apple could not verify WeChatBridge is free of malware” or that it “is damaged”.**
Early builds were not notarized by Apple; newer builds are. To open an older build you already downloaded (only one that came from this project's Lanzou link):

1. Drag WeChatBridge into Applications, double-click it once, and click “Done” in the alert.
2. Open “System Settings → Privacy & Security”, scroll to the bottom, click “Open Anyway” next to the WeChatBridge notice, and confirm with your login password.
3. If “Open Anyway” does not appear, run this in Terminal and double-click the app again:

```bash
xattr -dr com.apple.quarantine /Applications/微信流.app
```

**The entries are missing from the WeChat menu.**
Confirm the switch is on, then check the extension under “System Settings → General → Login Items & Extensions → Sharing”. WeChat sometimes needs a restart before the menu refreshes.

Expand Down
2 changes: 1 addition & 1 deletion macos/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import PackageDescription
// `Scripts/make-app.sh` assembles and signs the bundle around them.
let package = Package(
name: "WeChatBridge",
platforms: [.macOS(.v14), .iOS(.v17)],
platforms: [.macOS(.v13), .iOS(.v17)],
products: [
.executable(name: "WeChatBridge", targets: ["WeChatBridgeApp"]),
.executable(name: "WeChatBridgeShare", targets: ["WeChatBridgeShare"]),
Expand Down
6 changes: 3 additions & 3 deletions macos/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>zh-Hans</string>
<key>CFBundleDisplayName</key>
<string>微信流</string>
<key>CFBundleExecutable</key>
<string>WeChatBridge</string>
<key>CFBundleIconFile</key>
<string>AppIcon</string>
<key>CFBundleIdentifier</key>
<string>com.xiangming.wechatbridge</string>
<key>CFBundleDisplayName</key>
<string>微信流</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand All @@ -38,7 +38,7 @@
<key>DKStorageMode</key>
<string>shared</string>
<key>LSMinimumSystemVersion</key>
<string>14.0</string>
<string>13.0</string>
<key>LSUIElement</key>
<true/>
<key>NSHumanReadableCopyright</key>
Expand Down
6 changes: 3 additions & 3 deletions macos/Resources/Share-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<string>18</string>
<key>DKAppGroupIdentifier</key>
<string>DLKMC3ZRZQ.com.xiangming.wechatbridge.shared</string>
<key>DKStorageMode</key>
<string>shared</string>
<key>DKShareAction</key>
<string>clipboard</string>
<key>DKStorageMode</key>
<string>shared</string>
<key>LSMinimumSystemVersion</key>
<string>14.0</string>
<string>13.0</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
Expand Down
5 changes: 4 additions & 1 deletion macos/Scripts/make-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ CONFIG="${CONFIG:-release}"
# rebuild. A stable Developer ID or Apple Development identity is picked
# automatically when the keychain has one; ad-hoc stays the fallback so a clone
# without any certificate still builds.
# TEAM_ID narrows the search to one team's certificates, so a keychain holding
# several teams' identities never signs with the wrong one by accident.
select_identity() {
local found
for PREFIX in "Developer ID Application:" "Apple Development:"; do
found="$(security find-identity -v -p codesigning 2>/dev/null \
| awk -v prefix="$PREFIX" 'index($0, prefix) { print $2; exit }')"
| awk -v prefix="$PREFIX" -v team="${TEAM_ID:+($TEAM_ID)\"}" \
'index($0, prefix) && (team == "" || index($0, team)) { print $2; exit }')"
if [ -n "$found" ]; then
printf '%s' "$found"
return
Expand Down
19 changes: 17 additions & 2 deletions macos/Scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,22 @@ if [ "$REQUIRE_TAG" = "1" ]; then
fi
fi

IDENTITY="${IDENTITY:-$(security find-identity -v -p codesigning 2>/dev/null | awk '/Developer ID Application:/ {print $2; exit}')}"
# Pin the identity to one team. Picking "the first Developer ID in the
# keychain" signs with whichever certificate happens to be installed, which is
# how a release ends up under somebody else's name or not notarizable at all.
TEAM_ID="${TEAM_ID:-}"
if [ -z "${IDENTITY:-}" ]; then
if [ -z "$TEAM_ID" ]; then
echo "set TEAM_ID to the Apple Developer team that owns the Developer ID certificate" >&2
security find-identity -v -p codesigning | grep 'Developer ID Application:' >&2 || true
exit 1
fi
IDENTITY="$(security find-identity -v -p codesigning 2>/dev/null \
| awk -v team="($TEAM_ID)\"" '/Developer ID Application:/ && index($0, team) {print $2; exit}')"
fi
if [ -z "$IDENTITY" ]; then
echo "no valid Developer ID Application identity was found" >&2
echo "no valid Developer ID Application identity for team $TEAM_ID was found" >&2
echo "create one at developer.apple.com → Certificates → Developer ID Application" >&2
exit 1
fi

Expand Down Expand Up @@ -99,6 +112,8 @@ if [ "$NOTARIZE" = "1" ]; then
notarize_artifact "$DMG" dmg
xcrun stapler staple "$DMG"
xcrun stapler validate "$DMG"
# The same check a downloaded copy will face on a user's Mac.
"$ROOT/Scripts/verify-gatekeeper.sh" "$DMG"
else
echo "warning: NOTARIZE=0; this DMG is not publishable" >&2
fi
Expand Down
84 changes: 84 additions & 0 deletions macos/Scripts/verify-gatekeeper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env bash
# Check a DMG the way a user's Mac will see it after downloading, before it is
# uploaded anywhere. A DMG that fails here shows users "Apple could not verify
# 微信流 is free of malware" (or "is damaged") and will not open.
#
# Scripts/verify-gatekeeper.sh dist/WeChatBridge-0.1.16.dmg
#
# It also reports the lowest macOS the app accepts, so a build that would show
# the 🚫 badge on an older Mac is caught too.
set -euo pipefail

DMG="${1:?usage: verify-gatekeeper.sh path/to/app.dmg}"
EXPECTED_MIN_OS="${EXPECTED_MIN_OS:-13.0}"
FAILED=0
fail() { echo "✗ $*" >&2; FAILED=1; }
pass() { echo "✓ $*"; }

if [ ! -f "$DMG" ]; then
echo "missing DMG: $DMG" >&2
exit 1
fi

# The disk image itself: Developer ID signature plus a stapled ticket.
if spctl -a -t open --context context:primary-signature -vv "$DMG" 2>&1 | grep -q 'source=Notarized Developer ID'; then
pass "DMG is notarized"
else
fail "DMG is not notarized (spctl: $(spctl -a -t open --context context:primary-signature "$DMG" 2>&1 | tr '\n' ' '))"
fi
if xcrun stapler validate "$DMG" >/dev/null 2>&1; then
pass "DMG has a stapled ticket"
else
fail "DMG has no stapled ticket; offline Macs cannot verify it"
fi

MOUNT_POINT="$(mktemp -d "${TMPDIR:-/tmp}/wcb-gatekeeper.XXXXXX")"
cleanup() { hdiutil detach "$MOUNT_POINT" -quiet 2>/dev/null || true; rmdir "$MOUNT_POINT" 2>/dev/null || true; }
trap cleanup EXIT
hdiutil attach "$DMG" -nobrowse -readonly -noautoopen -mountpoint "$MOUNT_POINT" >/dev/null

APP="$(find "$MOUNT_POINT" -maxdepth 1 -name '*.app' -print -quit)"
if [ -z "$APP" ]; then
echo "no .app inside $DMG" >&2
exit 1
fi

# The app: what Finder checks once it has been dragged to Applications.
ASSESSMENT="$(spctl -a -t exec -vv "$APP" 2>&1 || true)"
if printf '%s' "$ASSESSMENT" | grep -q 'source=Notarized Developer ID'; then
pass "app is notarized ($(printf '%s' "$ASSESSMENT" | sed -n 's/^origin=//p'))"
else
fail "app would be blocked by Gatekeeper: $(printf '%s' "$ASSESSMENT" | tr '\n' ' ')"
fi
if xcrun stapler validate "$APP" >/dev/null 2>&1; then
pass "app has a stapled ticket"
else
fail "app has no stapled ticket"
fi
if codesign --verify --deep --strict "$APP" 2>/dev/null; then
pass "app signature is intact"
else
fail "app signature does not verify"
fi

MIN_OS="$(/usr/libexec/PlistBuddy -c 'Print :LSMinimumSystemVersion' "$APP/Contents/Info.plist")"
if [ "$MIN_OS" = "$EXPECTED_MIN_OS" ]; then
pass "runs on macOS $MIN_OS and later"
else
fail "LSMinimumSystemVersion is $MIN_OS, expected $EXPECTED_MIN_OS"
fi
ARCHS="$(lipo -archs "$APP/Contents/MacOS/WeChatBridge")"
case " $ARCHS " in
*" arm64 "*) ;;
*) fail "app has no arm64 slice ($ARCHS)" ;;
esac
case " $ARCHS " in
*" x86_64 "*) pass "universal binary ($ARCHS)" ;;
*) fail "app has no x86_64 slice ($ARCHS); Intel Macs cannot run it" ;;
esac

if [ "$FAILED" = "1" ]; then
echo "this DMG is not ready to publish" >&2
exit 1
fi
echo "ready to publish: $DMG"
112 changes: 112 additions & 0 deletions macos/Sources/WeChatBridgeApp/Design/Compat.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import SwiftUI

// The app ships to macOS 13 (Ventura) as well, because plenty of Intel Macs
// stop there. These wrappers use the macOS 14 SwiftUI API when it exists and the
// closest macOS 13 equivalent otherwise, so call sites stay one line.
extension View {
/// `onChange(of:initial:_:)` on macOS 14; the single-value form on 13, with
/// the previous value tracked here so the closure shape stays the same.
@ViewBuilder
func compatOnChange<V: Equatable>(of value: V, perform action: @escaping (V, V) -> Void) -> some View {
if #available(macOS 14, *) {
onChange(of: value) { old, new in action(old, new) }
} else {
modifier(LegacyOnChange(value: value, action: action))
}
}

/// The bounce is cosmetic, so macOS 13.0–13.2 simply keeps the default.
@ViewBuilder
func compatScrollBounceBasedOnSize() -> some View {
if #available(macOS 13.3, *) {
scrollBounceBehavior(.basedOnSize)
} else {
self
}
}

/// A scroll view already starts at the top on macOS 13.
@ViewBuilder
func compatDefaultScrollAnchorTop() -> some View {
if #available(macOS 14, *) {
defaultScrollAnchor(.top)
} else {
self
}
}

/// macOS 13 draws its focus ring on these custom controls; nothing breaks.
@ViewBuilder
func compatFocusEffectDisabled() -> some View {
if #available(macOS 14, *) {
focusEffectDisabled()
} else {
self
}
}

/// Keyboard navigation for a focused custom control. macOS 14 uses
/// `onKeyPress`; macOS 13 has no key-press modifier, so arrows go through
/// `onMoveCommand` and Return/Space are left to the mouse.
@ViewBuilder
func compatKeyCommands(
up: (() -> Void)? = nil,
down: (() -> Void)? = nil,
left: (() -> Void)? = nil,
right: (() -> Void)? = nil,
commit: (() -> Void)? = nil
) -> some View {
if #available(macOS 14, *) {
let handlers = Self.keyHandlers(up: up, down: down, left: left, right: right, commit: commit)
onKeyPress(keys: Set(handlers.keys)) { press in
guard let handler = handlers[press.key] else { return .ignored }
handler()
return .handled
}
} else {
onMoveCommand { direction in
switch direction {
case .up: up?()
case .down: down?()
case .left: left?()
case .right: right?()
@unknown default: break
}
}
}
}

private static func keyHandlers(
up: (() -> Void)?,
down: (() -> Void)?,
left: (() -> Void)?,
right: (() -> Void)?,
commit: (() -> Void)?
) -> [KeyEquivalent: () -> Void] {
var handlers: [KeyEquivalent: () -> Void] = [:]
if let up { handlers[.upArrow] = up }
if let down { handlers[.downArrow] = down }
if let left { handlers[.leftArrow] = left }
if let right { handlers[.rightArrow] = right }
if let commit {
handlers[.return] = commit
handlers[.space] = commit
}
return handlers
}
}

private struct LegacyOnChange<V: Equatable>: ViewModifier {
let value: V
let action: (V, V) -> Void
@State private var previous: V?

func body(content: Content) -> some View {
content
.onAppear { previous = value }
.onChange(of: value) { new in
action(previous ?? new, new)
previous = new
}
}
}
Loading
Loading