Repository navigation
feat(monetization): real shared AdMob banner via GADBannerView (#441) - #443
Merged
Merged
Conversation
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
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #441.
What
Lands the real
GADBannerView(nowBannerViewin AdMob 13.x) and unifies thetwo placeholder banner slots into ONE shared
MonetizationUI.BannerSlotViewconsumed 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
GADBannerViewLiveAdMobBridge(the soleimport GoogleMobileAdssite) already created +loaded a real
BannerViewon iOS. This PR adds aBannerViewRepresentable(
UIViewRepresentable, gated#if canImport(UIKit)) wrapping that retainedview, and a new
bannerView(for:) -> AnyView?bridge method that hands thehosted view back type-erased. macOS / SDK-absent builds return
nil.The seam (how the loaded handle crosses into MonetizationUI without leaking the SDK)
BannerViewProvidingprotocol in MonetizationUI (which may importSwiftUI):
@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).
AnyView(a SwiftUI type, not aGoogleMobileAds type), so foundations.md §9.1 holds:
BannerViewnever leavesAdsAdMob.
MonetizationCorestays pure (no SwiftUI).SudokuUI/MinesweeperUIget the host viaadProvider as? any BannerViewProviding— neither imports AdsAdMob. Fakes / macOSNoopAdProviderdon't conform →
nil→ honest fallback.Shared slot
MonetizationUI.BannerSlotView(mirrors the feat(minesweeper): add board pause/resume parity with Sudoku (#434) #435PauseOverlayViewextraction). 50pt height contract, dismiss ✕ writing through to
AdGate.recordBannerDismissed, honest status captions (loading / "Adunavailable" / suppressed / disposed).
.loadedrenders the real banner fromthe host.
Colorparams with system-color defaults (mirrorsToastView) — MonetizationUI keeps zero Theme-protocol dependency. Sudoku +Minesweeper pass their theme tokens.
(@Sendable () async -> Void)?closure (
onAdContext) so MonetizationUI stays free of SudokuUI'sATTPrimerCoordinator.SudokuUI.BannerSlotView+MinesweeperUI.MinesweeperBannerSlotView;repointed all 4 call sites (Sudoku Home + Board×2, MS Home + Board).
Debug-test / Release-prod ID split (user decision)
LiveAdMobBridgeignores the injected id and forces Google'suniversal TEST banner unit (
ca-app-pub-3940256099942544/2934735716, acommitted constant) — a dev / sim build can never request prod creatives.
Bundle.mainGADBannerUnitID(injected fromTuist/AdMob.xcconfig) thatAppCompositionpasses in. No prod ID is hardcoded or committed.
Verify (macOS, absolute --package-path)
swift build+swift testgreen: AppMonetizationKit 114, SudokuKit220, MinesweeperKit 127 (snapshot suites included).
mise run scan:l10nPASS — banner labels stay bare literals (no catalog keysdropped/added).
LiveAdMobBridge.swift) — SDK staysconfined; no leak into MonetizationUI / SudokuUI / MinesweeperUI.
🤖 Generated with Claude Code