mycode/myApp/Keging/IOS/Haptics.swift
songyc macbook 3cee5f08af polish(keging): 전면 자가 점검 — 클린룸 빌드 검증·유령 DI 정리·진동 체인 취소·경고 0
- 'cannot find in scope' 판정: 새 DerivedData 클린룸 빌드 3종(Debug/Release/워치) 전부 그린
  → SourceKit 편집기 오탐 확정 (실제 컴파일 에러 0)
- 강제 종료 유령 Live Activity 정리: 운동 중 kill 시 DI가 몇 시간 잔존(시뮬 재현) →
  앱 시작 시 cleanupStaleActivities()로 즉시 소멸(실측 확인)
- 진동 체인 세대 토큰: 짧은 수축·이완에서 이전 패턴 체인이 다음 국면 첫 진동을 삼키는
  엣지 방지, Haptics를 Task 기반으로 재작성해 Swift 6 경고 3건 전부 제거
- 워치에도 -noHealth QA 인자 추가
- 시뮬 실측: DI 백그라운드 갱신(수축 그린→이완 앰버)·포그라운드 복귀 벽시계 재동기화
  (5/20 정확 착지)·유령 DI 정리·주간 통계 검산(11세트/220회)·완주 경로·워치 실행·
  18.5 빌드 그린·전 카탈로그 missing/stale/ASCII~ 0

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UPmp29DQHY6Ahfss5SRopT
2026-08-29 23:30:14 +09:00

45 lines
2.0 KiB
Swift
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// Haptics.swift
// Keging
//
// (iOS) (1 0.5) .
// ( ·
// ) .
// AudioServices , .
//
import AudioToolbox
import Foundation
@MainActor
enum Haptics {
///
/// (· )
private static var generation = 0
static func play(_ pattern: HapticPattern) {
// ()
let gaps: [TimeInterval]
switch pattern {
case .short: gaps = [0] // : 1
case .doubleTap: gaps = [0, 0.25] // : 0.25 1
case .rattle: gaps = [0, 0.15, 0.15] // : 3
case .long: gaps = [0, 0, 0] // :
}
generation += 1
playChain(gaps, generation: generation)
}
private static func playChain(_ gaps: [TimeInterval], generation: Int) {
guard generation == Self.generation, let gap = gaps.first else { return }
let rest = Array(gaps.dropFirst())
Task { @MainActor in
if gap > 0 { try? await Task.sleep(for: .seconds(gap)) }
guard generation == Self.generation else { return }
AudioServicesPlaySystemSoundWithCompletion(kSystemSoundID_Vibrate) { @MainActor @Sendable in
playChain(rest, generation: generation)
}
}
}
}