Skip to content

feat(monetization): real shared AdMob banner via GADBannerView (#441) - #443

Merged
wei18 merged 1 commit into
mainfrom
feat/441-real-shared-banner
Jun 9, 2026
Merged

wei18 merged 1 commit into
mainfrom
feat/441-real-shared-banner

Conversation

@wei18

@wei18 wei18 commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Closes #441.

What

Lands the real GADBannerView (now BannerView in AdMob 13.x) and unifies the
two placeholder banner slots into ONE shared MonetizationUI.BannerSlotView
consumed by both Sudoku and Minesweeper.

Before this PR both apps rendered an honest "Ad will load here" placeholder on
.loaded; the real SDK wrapping was deferred to "v2.3.5" and never landed.

How

Real GADBannerView

  • LiveAdMobBridge (the sole import GoogleMobileAds site) already created +
    loaded a real BannerView on iOS. This PR adds a BannerViewRepresentable
    (UIViewRepresentable, gated #if canImport(UIKit)) wrapping that retained
    view, and a new bannerView(for:) -> AnyView? bridge method that hands the
    hosted view back type-erased. macOS / SDK-absent builds return nil.

The seam (how the loaded handle crosses into MonetizationUI without leaking the SDK)

  • New BannerViewProviding protocol in MonetizationUI (which may import
    SwiftUI): @MainActor func bannerView(for: AdBannerHandle) -> AnyView?.
  • LiveAdMobAdProvider (AdsAdMob) conforms to it, forwarding to the bridge.
    AdsAdMob gains a dependency on MonetizationUI — no cycle (MonetizationUI →
    MonetizationCore only; it never imports AdsAdMob).
  • The crossing payload is an AnyView (a SwiftUI type, not a
    GoogleMobileAds type), so foundations.md §9.1 holds: BannerView never leaves
    AdsAdMob. MonetizationCore stays pure (no SwiftUI).
  • SudokuUI / MinesweeperUI get the host via adProvider as? any BannerViewProviding — neither imports AdsAdMob. Fakes / macOS NoopAdProvider
    don't conform → nil → honest fallback.

Shared slot

  • Extracted MonetizationUI.BannerSlotView (mirrors the feat(minesweeper): add board pause/resume parity with Sudoku (#434) #435 PauseOverlayView
    extraction). 50pt height contract, dismiss ✕ writing through to
    AdGate.recordBannerDismissed, honest status captions (loading / "Ad
    unavailable" / suppressed / disposed). .loaded renders the real banner from
    the host.
  • Theme decoupled via DI Color params with system-color defaults (mirrors
    ToastView) — MonetizationUI keeps zero Theme-protocol dependency. Sudoku +
    Minesweeper pass their theme tokens.
  • Sudoku's ATT priming hook is injected as a (@Sendable () async -> Void)?
    closure (onAdContext) so MonetizationUI stays free of SudokuUI's
    ATTPrimerCoordinator.
  • Deleted SudokuUI.BannerSlotView + MinesweeperUI.MinesweeperBannerSlotView;
    repointed all 4 call sites (Sudoku Home + Board×2, MS Home + Board).

Debug-test / Release-prod ID split (user decision)

  • In DEBUG, LiveAdMobBridge ignores the injected id and forces Google's
    universal TEST banner unit (ca-app-pub-3940256099942544/2934735716, a
    committed constant) — a dev / sim build can never request prod creatives.
  • In RELEASE, it uses the per-app production id read from Bundle.main
    GADBannerUnitID (injected from Tuist/AdMob.xcconfig) that AppComposition
    passes in. No prod ID is hardcoded or committed.

Verify (macOS, absolute --package-path)

  • swift build + swift test green: AppMonetizationKit 114, SudokuKit
    220
    , MinesweeperKit 127 (snapshot suites included).
  • mise run scan:l10n PASS — banner labels stay bare literals (no catalog keys
    dropped/added).
  • GoogleMobileAds import audit: 1 site (LiveAdMobBridge.swift) — SDK stays
    confined; no leak into MonetizationUI / SudokuUI / MinesweeperUI.

🤖 Generated with Claude Code

Land the real GADBannerView and unify the two placeholder banner slots into
one shared MonetizationUI.BannerSlotView consumed by both apps.

- AdsAdMob: LiveAdMobBridge now wraps its retained BannerView in a
  UIViewRepresentable (iOS-only, #if canImport(UIKit)) and exposes it as a
  type-erased AnyView via a new bridge method. GoogleMobileAds stays confined
  to LiveAdMobBridge (isolation audit: exactly 1 import site).
- New BannerViewProviding seam in MonetizationUI lets the loaded banner view
  cross AdsAdMob -> MonetizationUI as an AnyView WITHOUT leaking the SDK type
  (foundations.md §9.1: BannerView never crosses the target border). The live
  provider conforms; SudokuUI/MinesweeperUI cast `adProvider as? any
  BannerViewProviding` so neither UI imports AdsAdMob.
- Shared MonetizationUI.BannerSlotView (mirrors the #435 PauseOverlayView
  extraction): 50pt height contract, dismiss button, honest status captions.
  The .loaded branch renders the real banner from the host; nil host (fakes /
  macOS NoopAdProvider) falls back to nothing-in-rect. Theme decoupled via DI
  Color params (mirrors ToastView). Deleted SudokuUI.BannerSlotView and
  MinesweeperUI.MinesweeperBannerSlotView; repointed all 4 call sites.
- Debug/Release ad-unit-id split (user decision): DEBUG builds force Google's
  universal TEST banner unit id inside LiveAdMobBridge so a dev/sim build can
  never request prod ads; Release reads the per-app prod id from Info.plist
  (GADBannerUnitID, injected from Tuist/AdMob.xcconfig) as before.

Verify (macOS, swift build + test all green):
- AppMonetizationKit 114 tests, SudokuKit 220 tests, MinesweeperKit 127 tests.
- mise run scan:l10n PASS (banner labels stay bare literals — no catalog keys
  dropped or added).
- GoogleMobileAds import audit: 1 site (LiveAdMobBridge.swift).

Co-Authored-By: Wei18 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
@wei18
wei18 merged commit 7b7e514 into main Jun 9, 2026
4 checks passed
@wei18
wei18 deleted the feat/441-real-shared-banner branch June 9, 2026 08:32
wei18 added a commit that referenced this pull request Jun 9, 2026
…on banner-seam note (#445)

Reflect the post-#442 work: #330 audio CLOSED (P3 #444), real shared banner #441/#443. Meeting log decisions/open-questions updated; mise-task-operations index gains verify:audio; monetization-sdk-integration records the GADBannerView -> AnyView cross-target seam + the #if DEBUG/Release ID split (supersedes the old REPLACE_IN_v2.5.3 placeholder).

Co-authored-by: Claude Opus 4.8 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(monetization): real shared AdMob banner — both apps render a placeholder, not a real ad

1 participant