diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..b9cccd7 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,62 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Build & Lint + +```bash +# Validate podspec +pod spec lint GADManager.podspec + +# Build via SPM +swift build + +# CocoaPods install (in consumer projects) +pod install +``` + +## Release Process + +1. Bump version in `GADManager.podspec` (`s.version`) +2. Commit: `bump: release a.b.c` +3. Tag: `git tag a.b.c && git push origin a.b.c` +4. Push podspec: `pod trunk push GADManager.podspec` + +## Architecture + +GADManager is a generic Swift library (`GADManager`) that wraps Google Mobile Ads SDK with time-based throttling and lifecycle management. + +**Core design:** +- `E` is a user-defined `RawRepresentable` enum where `RawValue == String` — each case maps to an ad unit name +- Ad unit IDs are read from `Info.plist` key `GADUnitIdentifiers` (a `[String: String]` dictionary keyed by enum raw values) +- The manager tracks per-unit state via dictionaries: `adObjects`, `intervals`, `isLoading`, `isTesting`, `completions`, etc. + +**Ad lifecycle:** +1. `prepare(...)` — loads the ad and caches it in `adObjects[unit]` +2. `show(unit:force:needToWait:...)` — checks `canShow()` (time interval) and `isPrepared()` (ad validity/expiry), then calls `__show()` +3. After dismissal (`adDidDismissFullScreenContent`), `reprepare()` is called automatically to reload + +**Supported ad types:** Interstitial, AppOpen (opening), Banner, Rewarded, Native + +**Key timing constants:** +- `defaultInterval`: 1 hour between interstitial/reward shows +- `opeingExpireInterval`: 4 hours (5 min in DEBUG) — AppOpen ad validity window after loading +- `loadingExpirationInterval`: 1 minute + +**Delegate (`GADManagerDelegate`):** +- Host app must persist and provide last-shown / last-prepared timestamps per unit +- Optional callbacks: `willPresentAD`, `didDismissAD` + +**Extensions in `GADManager/extensions/`:** +- `GADRequest+`: `hideTestLabel()`, `enableCollapsible(direction:)` +- `UIViewController+`, `UIApplication+`, `UIAlertAction+`, `String+`: utilities for presenting alerts and opening settings/App Store + +## Distribution + +- **CocoaPods**: `pod 'GADManager'` — depends on `Google-Mobile-Ads-SDK` (static framework) +- **SPM**: `Package.swift` — depends on `swift-package-manager-google-mobile-ads` ≥ 12.6.0 + +## CI + +- **Gemini code review** (`gemini-dispatch.yml`): triggers on PR open or `@gemini` comment from OWNER/MEMBER/COLLABORATOR +- **Claude** (`claude.yml`): separate workflow for Claude-based automation