docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거

Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
This commit is contained in:
Antigravity Agent
2026-07-05 00:33:48 +09:00
parent 1cfd3bbb56
commit 9148c358d0
6455 changed files with 1 additions and 86875 deletions
@@ -0,0 +1,115 @@
---
id: ios-background-tasks
title: iOS Background Tasks — BGTaskScheduler / Refresh
category: Coding
status: draft
source_trust_level: B
verification_status: conceptual
created_at: 2026-05-09
updated_at: 2026-05-09
tags: [ios, background, bgtask, vibe-coding]
tech_stack: { language: "Swift / BackgroundTasks", applicable_to: ["iOS 13+"] }
applied_in: []
aliases: [BGAppRefreshTask, BGProcessingTask, background fetch]
---
# iOS Background Tasks
> iOS 는 앱이 백그라운드에서 자유롭게 안 돌게 한다. **BGTaskScheduler** 로 OS 가 적절한 시점에 깨워줌. 짧은 refresh (30s) vs 긴 processing (분 단위, charging 시점) 구분.
## 📖 핵심 개념
- BGAppRefreshTask: 짧은 작업 (~30s). 사용자 패턴 학습 후 OS 가 호출.
- BGProcessingTask: 긴 작업, 충전/네트워크 조건 가능. 주로 야간.
- 둘 다 OS 결정 — 정확한 시각 보장 X.
## 💻 코드 패턴
### Info.plist 등록
```xml
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>com.example.app.refresh</string>
<string>com.example.app.cleanup</string>
</array>
```
### App init 에서 register
```swift
@main
struct App: SwiftUI.App {
init() {
BGTaskScheduler.shared.register(forTaskWithIdentifier: "com.example.app.refresh", using: nil) { task in
handleRefresh(task as! BGAppRefreshTask)
}
BGTaskScheduler.shared.register(forTaskWithIdentifier: "com.example.app.cleanup", using: nil) { task in
handleCleanup(task as! BGProcessingTask)
}
}
}
```
### 다음 실행 예약
```swift
func scheduleRefresh() {
let req = BGAppRefreshTaskRequest(identifier: "com.example.app.refresh")
req.earliestBeginDate = Date(timeIntervalSinceNow: 15 * 60) // 15
do { try BGTaskScheduler.shared.submit(req) }
catch { print("schedule failed: \(error)") }
}
func scheduleCleanup() {
let req = BGProcessingTaskRequest(identifier: "com.example.app.cleanup")
req.requiresNetworkConnectivity = true
req.requiresExternalPower = true
req.earliestBeginDate = Date(timeIntervalSinceNow: 4 * 60 * 60)
try? BGTaskScheduler.shared.submit(req)
}
// app didEnterBackground reschedule
func sceneDidEnterBackground(_ scene: UIScene) {
scheduleRefresh()
}
```
### 작업 실행
```swift
func handleRefresh(_ task: BGAppRefreshTask) {
scheduleRefresh() //
let op = SyncOperation()
task.expirationHandler = { op.cancel() } // OS cancel
op.completionBlock = { task.setTaskCompleted(success: !op.isCancelled) }
OperationQueue().addOperation(op)
}
```
### 디버그 — Xcode breakpoint
```
e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"com.example.app.refresh"]
```
## 🤔 의사결정 기준
| 작업 | 도구 |
|---|---|
| 30초 이내 데이터 sync | BGAppRefreshTask |
| 큰 다운로드 / DB cleanup | BGProcessingTask |
| 위치 변화 trigger | Significant location changes |
| 정확한 시각 | UNNotificationRequest (local) — 단 OS 표시만, 코드 실행 X |
| 음악 / 통화 / 위치 추적 | Background mode capability + 별도 |
| Push 로 깨우기 | Silent push (content-available) |
## ❌ 안티패턴
- **시간 보장 가정**: OS 가 마음대로. 며칠 못 깨울 수도.
- **expirationHandler 안 처리**: 시간 초과 시 강제 종료 + suspend. 다음 등록 어려움.
- **register 와 submit 혼동**: register 는 한 번 (init), submit 은 매번.
- **백그라운드에서 UI 업데이트**: setNeedsDisplay 의미 없음.
- **무한 task**: OS 가 throttle. 다음 호출 거의 안 옴.
- **테스트 안 함**: simulator 에선 trigger 어려움. lldb 명령으로 강제 실행.
- **Info.plist 등록 안 함**: register 가 silently 실패.
## 🤖 LLM 활용 힌트
- "BGTaskScheduler 는 hint, not guarantee" 강조.
- 모든 task 가 schedule + register + execute 3단계 페어.
## 🔗 관련 문서
- [[iOS_Push_Notifications]]
- [[Android_WorkManager_Patterns]]