feat(macos): VoiceCatMac AppKit client + fix xcodebuild

The previous "shipped" claim was false — xcodebuild had never been run and
the macOS app source was never committed. This commit adds the 17 Swift
source files + xcodeproj and fixes three real defect classes so Debug and
Release both build clean:

1. MainWindowController.swift compile errors:
   - NSAccessibility.post arg order (element:notification:userInfo:)
   - NSAccessibilityPriorityMedium -> NSAccessibilityPriorityLevel.medium
   - StreamSummary.streamId -> .id (Identifiable conformance)
   - drop redundant VoiceCatResult.description extension
2. Linker: add -lc++ to OTHER_LDFLAGS (libvoicecat-fat.a is C++20; pure-Swift
   app target has no .cpp sources so libc++ wasn't pulled in — swift test
   passed because Package.swift testTarget has linkerSettings: c++).
3. Release config: add ONLY_ACTIVE_ARCH=YES (XCFramework only has arm64).

Verified: clean Debug + Release builds, otool -L shows libc++.1.dylib,
nm shows _vc_client_create/_vc_version_string, app launches and runs.
This commit is contained in:
2026-06-18 15:26:47 +02:00
parent b4766d2f24
commit 33169b01fa
23 changed files with 3616 additions and 4 deletions

View File

@@ -0,0 +1,93 @@
import AppKit
final class BanUserSheet: NSViewController {
var onComplete: ((String?, UInt64) -> Void)?
private let targetNickname: String
private let reasonField = NSTextField()
private let durationPicker = NSSegmentedControl(
labels: ["1 hour", "24 hours", "7 days", "Permanent"],
trackingMode: .selectOne,
target: nil, action: nil
)
init(nickname: String) {
self.targetNickname = nickname
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) { fatalError() }
override func loadView() {
view = NSView(frame: NSRect(x: 0, y: 0, width: 360, height: 160))
}
override func viewDidLoad() {
super.viewDidLoad()
buildUI()
}
private func buildUI() {
let titleLabel = NSTextField(labelWithString: "Ban \(targetNickname)")
titleLabel.font = .boldSystemFont(ofSize: 13)
let reasonLabel = NSTextField(labelWithString: "Reason:")
reasonField.placeholderString = "Ban reason (optional)"
reasonField.setAccessibilityLabel("Ban reason")
let durationLabel = NSTextField(labelWithString: "Duration:")
durationPicker.selectedSegment = 3
durationPicker.setAccessibilityLabel("Ban duration")
let cancelButton = NSButton(title: "Cancel", target: self, action: #selector(cancelClicked))
cancelButton.bezelStyle = .rounded
let banButton = NSButton(title: "Ban", target: self, action: #selector(banClicked))
banButton.bezelStyle = .rounded; banButton.keyEquivalent = "\r"
banButton.setAccessibilityLabel("Confirm ban")
let buttonRow = NSStackView(views: [NSView(), cancelButton, banButton])
buttonRow.orientation = .horizontal; buttonRow.spacing = 8
let grid = NSGridView(views: [
[reasonLabel, reasonField],
[durationLabel, durationPicker],
])
grid.rowSpacing = 8; grid.columnSpacing = 8
grid.column(at: 0).xPlacement = .trailing
let stack = NSStackView(views: [titleLabel, grid, buttonRow])
stack.orientation = .vertical; stack.spacing = 12
stack.edgeInsets = NSEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
stack.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(stack)
NSLayoutConstraint.activate([
stack.topAnchor.constraint(equalTo: view.topAnchor),
stack.leadingAnchor.constraint(equalTo: view.leadingAnchor),
stack.trailingAnchor.constraint(equalTo: view.trailingAnchor),
stack.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
}
@objc private func banClicked() {
let reason = reasonField.stringValue.trimmingCharacters(in: .whitespaces)
let expiresUnixMs = expiryFromSelection()
dismiss(nil)
onComplete?(reason.isEmpty ? nil : reason, expiresUnixMs)
}
@objc private func cancelClicked() {
dismiss(nil)
}
private func expiryFromSelection() -> UInt64 {
let nowMs = UInt64(Date().timeIntervalSince1970 * 1000)
switch durationPicker.selectedSegment {
case 0: return nowMs + 3_600_000 // 1 hour
case 1: return nowMs + 86_400_000 // 24 hours
case 2: return nowMs + 604_800_000 // 7 days
default: return 0 // permanent (0 = no expiry)
}
}
}