Skip to content

feat(secrets): xcconfig + info.plist substitution for admob ids (pr1) - #265

Merged
wei18 merged 2 commits into
mainfrom
feat/admob-secret-injection-pr1
Jun 3, 2026
Merged

wei18 merged 2 commits into
mainfrom
feat/admob-secret-injection-pr1

Conversation

@wei18

@wei18 wei18 commented Jun 3, 2026

Copy link
Copy Markdown
Owner

Summary

Migrates Sudoku + Minesweeper AdMob configuration from "hardcoded with fatalError gate" to build-time xcconfig substitution. Mirrors existing `Tuist/Signing.xcconfig` precedent.

Mechanism

  • `Tuist/AdMob.xcconfig` gitignored / `AdMob.xcconfig.example` committed
  • `Tuist/Config-{Debug,Release}.xcconfig` wrappers `#include?` Signing + AdMob
  • Both Info.plist files use `$()` substitution for `GADApplicationIdentifier` + new `GADBannerUnitID`
  • Both Live.swift files read banner via `Bundle.main` through a guard catching missing/empty/unresolved tokens
  • `ci_post_clone.sh` writes AdMob.xcconfig from XCC env vars per workflow
  • `secrets/` scaffolding for ASCRegister CLI use

Safety net (3 layers)

  1. Smoke tests verify Info.plist keys exist (catches deletion)
  2. Runtime guard catches missing/empty/literal `$()` at app launch
  3. TBD next PR: build-phase substitution-resolution check

Test plan

  • SudokuKit: 211/211 (+2 new smoke)
  • MinesweeperKit: 33/33 (+2 new smoke)
  • AdMob isolation: still exactly 1 `import GoogleMobileAds`
  • swift build clean both packages
  • User post-merge: fill local xcconfig + set XCC env vars + first TestFlight build verification

Refs

  • meetings/2026-06-03_admob-secret-injection-architect-review.md (design doc)
  • meetings/2026-06-03_admob-secret-injection-pr1.impl-notes.md
  • New project skill: `.claude/skills/build-time-secret-injection/`

wei18 and others added 2 commits June 3, 2026 15:08
Migrates Sudoku + Minesweeper AdMob configuration from
hardcoded-with-fatalError-gate to build-time xcconfig substitution.

Mechanism (mirrors existing Tuist/Signing.xcconfig precedent):
- Tuist/AdMob.xcconfig (gitignored) — local real values
- Tuist/AdMob.xcconfig.example (committed) — Google sandbox + docstring
  explaining both XCC env var source + local fill flow
- Tuist/Config-{Debug,Release}.xcconfig wrappers — #include? both
  Signing + AdMob (optional include keeps fresh clone buildable)
- Project.swift per-target xcconfig wiring (Sudoku + Minesweeper)
- Both Info.plist files use $(ADMOB_APP_ID) + $(ADMOB_BANNER_UNIT_ID)
  substitution (latter is a custom key we invented for app-side reads)
- Live.swift both apps: removed #if DEBUG / #else fatalError gate;
  reads GADBannerUnitID via Bundle.main.object(forInfoDictionaryKey:)
  through a guard that catches missing/empty/unresolved tokens
- ci_post_clone.sh: appended AdMob.xcconfig generation step that
  selects per-workflow env vars from $CI_PRODUCT / $CI_XCODE_SCHEME
  (fail-loud if missing)

Safety net (3 layers):
1. Smoke tests (InfoPlistAdMobKeysTests.swift) verify both keys exist
   in each app's source Info.plist — catches accidental key deletion
2. Runtime guard in both Live.swift — preconditionFailure on missing,
   empty, or literal $() token. Catches unresolved substitution at
   app launch before AdMob SDK rejects.
3. Subsequent PRs will add a build-phase substitution-resolution check
   to catch earlier than runtime

Tooling secrets (ASCRegister CLI, scope: scaffolding only):
- secrets/.env.example (committed) — KEY=VALUE structure + docstring
- secrets/ gitignore deny-by-default: * + !*.example + !README.md
- secrets/ASCAPI_AuthKey_*.p8 — user moves cert here post-merge
- ASCRegister CLI unchanged; user pattern: source secrets/.env
  before invoking, then pass via existing flags

Sudoku byte-identicality:
- DEBUG: literal banner-unit value unchanged (sandbox both before + after)
- Release: behavior changed from fatalError crash → preconditionFailure
  crash + smoke test pre-archive. Equivalent fail-loud safety.

AdMob SDK isolation audit: still exactly 1 import GoogleMobileAds
(LiveAdMobBridge.swift).

Tests:
- SudokuKit: 211/211 (existing 209 + 2 new smoke)
- MinesweeperKit: 33/33 (existing 31 + 2 new smoke)

Out of scope (subsequent PRs):
- Build-phase substitution-resolution check (Open Q1)
- gitleaks rule for prod AdMob IDs
- ADR / foundations.md update
- Removing precondition guard after one full prod release cycle

User-side post-merge (one-time):
1. cp Tuist/AdMob.xcconfig.example Tuist/AdMob.xcconfig + fill real
   values from project memory admob-production-ids +
   minesweeper-admob-ids
2. mv ~/GitHub/ASCAPI_AuthKey_*.p8 secrets/
3. ASC → Xcode Cloud → Workflow → Environment Variables: add
   SUDOKU_ADMOB_APP_ID / _BANNER_UNIT_ID +
   MINESWEEPER_ADMOB_APP_ID / _BANNER_UNIT_ID (mark Secret)

Refs:
- meetings/2026-06-03_admob-secret-injection-architect-review.md
- meetings/2026-06-03_admob-secret-injection-pr1.impl-notes.md
- .claude/skills/build-time-secret-injection/ (new project skill)

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Round 2 inline fixes from PR #265 CR (verdict: ACCEPT with cosmetics):

1. `.gitignore` `secrets/*` → `secrets/**` — covers subdirectory contents
   (e.g. a future `secrets/p8/` or `secrets/keys/`); current `*` form
   only matches top-level files.

2. `secrets/README.md` created — the .gitignore allowlist
   `!secrets/README.md` was forward-looking to a missing file; the
   README now exists with one-time setup + daily-use instructions
   pointing at memory `asc-api-credentials`.

3. Collapsed duplicate comment paragraphs in both Live.swift files
   (subagent had paste-stacked two adjacent explanations of the same
   substitution chain). Now a single tight paragraph mentioning
   smoke-test (`InfoPlistAdMobKeysTests`) + runtime guard role.

CR Important #1 (pre-existing prod-ID leaks in docs/ and meetings/) +
Important #2 (`AppInfo.plist` drift risk) deferred to follow-up backlog
issues — file separately.

Build: clean on both packages.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@wei18
wei18 merged commit 262aff1 into main Jun 3, 2026
3 checks passed
@wei18
wei18 deleted the feat/admob-secret-injection-pr1 branch June 3, 2026 07:33
wei18 added a commit that referenced this pull request Jun 3, 2026
…et injection

Captures 5 PRs merged today (#256 grace inversion / #257 .minesweeper CK
config / #258 multi-app IAP / #259 MS AppComposition wire / #263 U15
LiveAdMobAdProvider + banner + toast / #264 prod-ID comment scrub /
#265 AdMob secret injection PR1) plus 5 issues filed for follow-up
(#260 #261 #262 #266 #267).

Records decisions, rejected alternatives, Architect review hand-off,
and the spec inversion (7-day grace removed). Notes Iron Law violation
on skill writing + remediation via post-hoc CR.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
wei18 added a commit that referenced this pull request Jun 3, 2026
Per issue #267 (PR #265 CR Important #2), document option (c): accept the
verbatim-copy drift risk in InfoPlistAdMobKeysTests since the test only
guards the two AdMob keys (not plausibly deleted by accident). Escalate to
a byte-for-byte sync sentinel only on a real drift incident.

Co-authored-by: Claude Opus 4.8 <[email protected]>
wei18 added a commit that referenced this pull request Jun 3, 2026
…ncy (#272)

* docs(v2): refresh v2.5-readiness for xcconfig injection + grace removal

Surfaced by docs-currency CR (2026-06-03). v2.5-readiness.md lagged two
shipped changes: #265 (AdMob build-time xcconfig injection — replaced the
LiveAdMobBridge fatalError Release branch that no longer exists) and #256
(gracePeriodDays = 0 — banner shows from first launch, no 7-day window,
including the App-Review-facing test path). Also notes the xcconfig +
Info.plist $() pattern in foundations.md §7.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* chore(telemetry): add swiftLanguageModes: [.v6] for manifest consistency

Surfaced by config CR: TelemetryKit was the only one of 9 package manifests
omitting `swiftLanguageModes: [.v6]`. Functionally near-equivalent under
swift-tools-version 6.2 (defaults to v6), but aligns with the other 8 so the
language mode is explicit everywhere. Build verified.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 <[email protected]>
wei18 added a commit that referenced this pull request Jun 3, 2026
…al (#273)

Surfaced by docs-currency CR (2026-06-03). v2.5-readiness.md lagged two
shipped changes: #265 (AdMob build-time xcconfig injection — replaced the
LiveAdMobBridge fatalError Release branch that no longer exists) and #256
(gracePeriodDays = 0 — banner shows from first launch, no 7-day window,
including the App-Review-facing test path). Also notes the xcconfig +
Info.plist $() pattern in foundations.md §7.

Co-authored-by: Claude Opus 4.8 <[email protected]>
wei18 added a commit that referenced this pull request Jun 3, 2026
README framed the repo as a single Sudoku app with 4 packages. Updated to
reflect current state: two app shells (Sudoku + Minesweeper), 9 local SPM
packages (Persistence/GameCenter/GameShell extracted from SudokuKit;
Minesweeper Core/Kit added), GameShellKit as the shared UI shell, Project.swift
two-target Game umbrella, and Minesweeper v1 in the status section. Also notes
production AdMob IDs now use build-time xcconfig injection (#265).

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.

1 participant