Skip to content

fix(app-store): make screenshot capture actually work - #84

Open
kandotrun wants to merge 3 commits into
mainfrom
kan/fix-app-store-screenshot-capture
Open

kandotrun wants to merge 3 commits into
mainfrom
kan/fix-app-store-screenshot-capture

Conversation

@kandotrun

@kandotrun kandotrun commented Sep 16, 2026

Copy link
Copy Markdown
Owner

何が壊れていたか

App Store screenshots ワークフローは一度も成功していませんでしたnpm run screenshots:app-store は4つの欠陥で必ず失敗していました。run履歴が空だったのはそのためです。

# 欠陥 症状
1 AFTERIMAGE_DEVICE_NAME=... xcrun ... | python3 パイプ左の代入は右のpythonに届かず KeyError で即死
2 AFTERIMAGE_SCREENSHOT_OUTPUT_DIR をそのまま export xcodebuild はシェルenvをテストランナーへ渡さないため XCTSkip
3 app.otherElements["app-store-screenshot-ready-*"] ScrollView 背後の scene が .other にならず要素を発見できない
4 UIGraphicsImageRendererFormat.opaque = true それでも colorType 6(alpha付き)で出力 → 提出不可

修正

  • シミュレータ名を argv で渡す(env ではなく)
  • TEST_RUNNER_AFTERIMAGE_SCREENSHOT_OUTPUT_DIR として export(xcodebuild の公式な受け渡し方法)
  • descendants(matching: .any) で識別子を照合
  • スクリーンショットを alpha無し device-RGB CGContext で再エンコード → colorType 2

契約マーカー(verify-app-store.mjs が検査する文字列)はすべて維持しています。

検証(実測)

self-hosted macOS 実機で生成 → CI でも実走:

  • app-store-screenshots ワークフロー: success(初)
  • 生成物: 1320x2868, colorType=2, alpha なし, portrait ×3
  • verification.json: status: "passed", failures: []
  • npm test: 122 passed
  • npm run verify:app-store: PASS

残り

submission モードの15ゲート(releaseCommit、法務記録、実機スモーク等)は本PRの対象外です。

Summary by CodeRabbit

  • アクセシビリティ

    • アプリ内のフィクスチャ画面が、関連するコンテンツをまとめた単一のアクセシビリティ要素として認識されるよう改善しました。
  • バグ修正

    • 画面キャプチャのPNG生成と準備状態の検出方法を見直し、App Store向けスクリーンショットの取得安定性を向上しました。
    • スクリーンショット保存先の指定処理を改善しました。

AFTERIMAGE_DEVICE_NAME=<name> xcrun ... | python3 only exported the
variable to xcrun, so the parser raised KeyError and screenshot capture
never succeeded. Pass the name as argv instead.

Also created the iPhone 16 Pro Max / iOS 26.5 simulator the contract
requires, which was missing on the self-hosted runner.
xcodebuild does not forward the shell environment to test runner processes
unless the variable is prefixed with TEST_RUNNER_. The UI test therefore never
saw AFTERIMAGE_SCREENSHOT_OUTPUT_DIR, skipped itself, and the screenshot gate
failed with three missing artifacts on every run.
…iably

The screenshot capture had never succeeded end to end. Three defects:

- AFTERIMAGE_DEVICE_NAME was set on the left side of a pipe, so it reached
  xcrun but not the python reader, which died on KeyError.
- xcodebuild does not forward shell environment to the test runner without
  a TEST_RUNNER_ prefix, so the UI test hit XCTSkip on every run.
- The ready marker was queried only via otherElements, which misses the
  scroll-view-backed scenes, and the rendered PNG kept an alpha channel
  (colorType 6) that App Store submission rejects.

Simulator name now passes as argv, the output dir is exported as
TEST_RUNNER_AFTERIMAGE_SCREENSHOT_OUTPUT_DIR, the marker is matched with
descendants(matching: .any), and the screenshot is re-encoded through an
opaque device-RGB context so the PNG is colorType 2 (no alpha).
@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 1062bd39-bd7e-4ee3-8690-7d2057b0b7ca

📥 Commits

Reviewing files that changed from the base of the PR and between 46db4de and 9e995f6.

📒 Files selected for processing (3)
  • ios/Sources/Features/AppStore/AppStoreScreenshotFixtureView.swift
  • ios/UITests/AppStoreScreenshotUITests.swift
  • scripts/generate-app-store-screenshots.sh

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

App Storeスクリーンショット処理を更新しました。アクセシビリティ検索、不透明PNG生成、シミュレータ名の引数渡し、出力先環境変数名を変更しました。

Changes

App Storeスクリーンショット処理

Layer / File(s) Summary
準備マーカーのアクセシビリティ対応
ios/Sources/Features/AppStore/AppStoreScreenshotFixtureView.swift, ios/UITests/AppStoreScreenshotUITests.swift
フィクスチャをアクセシビリティコンテナとして扱います。UIテストは識別子を持つ任意の子孫要素を検索します。
不透明PNGの生成方式変更
ios/UITests/AppStoreScreenshotUITests.swift
UIImageをデバイスRGBの不透明CGContextへ再描画し、CGImageDestinationでPNGを生成します。
生成スクリプトの引数と環境変数更新
scripts/generate-app-store-screenshots.sh
デバイス名をPythonへコマンドライン引数で渡します。出力先環境変数名をTEST_RUNNER_AFTERIMAGE_SCREENSHOT_OUTPUT_DIRへ変更します。

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 9e995

No concrete merge-blocking issue was established in the changed screenshot workflow.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed タイトルは、App Store スクリーンショット取得ワークフローを修正する主な変更を正確かつ簡潔に示しています。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch kan/fix-app-store-screenshot-capture

Warning

Git: CodeRabbit could not clone the repository, so clone-backed analysis was skipped and this review may be incomplete. Verify repository clone access, such as SSH credentials, before requesting another full review. If clone access is intentionally unavailable, use path_filters to narrow the review scope.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

ウサギが準備マーカーを見つけたよ
黒い背景に画像を描いたよ
PNGの道をまっすぐ進むよ
デバイス名を引数で渡すよ
スクリーンショットが静かに跳ねるよ

Comment @coderabbitai help to get the list of available commands.

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