Skip to content
Merged
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
62 changes: 62 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -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<E>`) 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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Typo: `opeingExpireInterval` should be `openingExpireInterval`.

Note that this typo currently exists in the implementation in GADManager.swift. You may want to consider refactoring the code to the correct spelling to ensure consistency and readability in the future.

Suggested change
- `opeingExpireInterval`: 4 hours (5 min in DEBUG) — AppOpen ad validity window after loading
- `openingExpireInterval`: 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
Loading