/mobile-plugin:ios-snapshot-testfrom mobile-plugin
スナップショットテスト支援。swift-snapshot-testing、UI変更検出。使用タイミング: (1) UIコンポーネントのリグレッションテスト、(2) デザインシステムの検証、(3) 複数デバイス・ダークモード対応の確認、(4) UIリファクタリング時の安全性確保
Ships in mobile-plugin. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
swift-snapshot-testingを使用したUIスナップショットテストをガイドする。
// Package.swift
dependencies: [
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.15.0")
]
// テストターゲットに追加
.testTarget(
name: "MyAppTests",
dependencies: [
.product(name: "SnapshotTesting", package: "swift-snapshot-testing")
]
)
import XCTest
import SnapshotTesting
@testable import MyApp
final class ProfileViewSnapshotTests: XCTestCase {
// 初回・意図的な変更時の記録は withSnapshotTesting(record: .all) { ... } でラップして実行
func testProfileView() {
let view = ProfileView(user: .mock)
assertSnapshot(of: view, as: .image)
}
func testProfileView_darkMode() {
let view = ProfileView(user: .mock)
assertSnapshot(of: view, as: .image(traits: .init(userInterfaceStyle: .dark)))
}
func testProfileView_largeText() {
let view = ProfileView(user: .mock)
assertSnapshot(
of: view,
as: .image(traits: .init(preferredContentSizeCategory: .accessibilityLarge))
)
}
}
import SwiftUI
import SnapshotTesting
final class SwiftUISnapshotTests: XCTestCase {
func testContentView() {
let view = ContentView()
let controller = UIHostingController(rootView: view)
// サイズを指定
controller.view.frame = CGRect(x: 0, y: 0, width: 375, height: 812)
assertSnapshot(of: controller, as: .image)
}
func testButtonStyles() {
let view = VStack(spacing: 16) {
Button("Primary") {}
.buttonStyle(PrimaryButtonStyle())
Button("Secondary") {}
.buttonStyle(SecondaryButtonStyle())
Button("Destructive") {}
.buttonStyle(DestructiveButtonStyle())
}
.padding()
let controller = UIHostingController(rootView: view)
controller.view.frame = CGRect(x: 0, y: 0, width: 300, height: 200)
assertSnapshot(of: controller, as: .image)
}
}
extension Snapshotting where Value: SwiftUI.View, Format == UIImage {
static func swiftUIImage(
drawHierarchyInKeyWindow: Bool = false,
precision: Float = 1,
perceptualPrecision: Float = 1,
size: CGSize? = nil,
traits: UITraitCollection = .init()
) -> Snapshotting {
return Snapshotting<UIViewController, UIImage>.image(
drawHierarchyInKeyWindow: drawHierarchyInKeyWindow,
precision: precision,
perceptualPrecision: perceptualPrecision,
size: size,
traits: traits
).pullback { view in
UIHostingController(rootView: view)
}
}
}
// 使用例
func testCustomStrategy() {
let view = MyCustomView()
assertSnapshot(
of: view,
as: .swiftUIImage(size: CGSize(width: 320, height: 480))
)
}
final class StateSnapshotTests: XCTestCase {
func testUserList_loading() {
let view = UserListView(state: .loading)
assertSnapshot(of: view, as: .swiftUIImage())
}
func testUserList_loaded() {
let view = UserListView(state: .loaded(users: User.mockList))
assertSnapshot(of: view, as: .swiftUIImage())
}
func testUserList_empty() {
let view = UserListView(state: .loaded(users: []))
assertSnapshot(of: view, as: .swiftUIImage())
}
func testUserList_error() {
let view = UserListView(state: .error(message: "Network connection failed"))
assertSnapshot(of: view, as: .swiftUIImage())
}
}
func testProgressAnimation_midway() {
let view = CircularProgressView(progress: 0.5)
assertSnapshot(of: view, as: .swiftUIImage(), named: "50percent")
}
func testProgressAnimation_complete() {
let view = CircularProgressView(progress: 1.0)
assertSnapshot(of: view, as: .swiftUIImage(), named: "complete")
}
MyAppTests/
├── __Snapshots__/
│ ├── ProfileViewSnapshotTests/
│ │ ├── testProfileView.1.png
│ │ ├── testProfileView_darkMode.1.png
│ │ └── testProfileView_largeText.1.png
│ └── HomeScreenSnapshotTests/
│ ├── testHomeScreen_iPhone15Pro.1.png
│ └── testHomeScreen_iPadPro12_9.1.png
# スナップショット画像をLFSで管理
*/__Snapshots__/**/*.png filter=lfs diff=lfs merge=lfs -text
name: Snapshot Tests
on:
pull_request:
paths:
- '**/*.swift'
- '**/Assets.xcassets/**'
jobs:
snapshot-test:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_15.2.app
- name: Run Snapshot Tests
run: |
xcodebuild test \
-workspace MyApp.xcworkspace \
-scheme MyAppTests \
-destination 'platform=iOS Simulator,name=iPhone 15 Pro'
- name: Upload Failed Snapshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: failed-snapshots
path: |
**/Failures/**
**/__Snapshots__/**
// わずかなアンチエイリアスの差異を許容
assertSnapshot(
of: view,
as: .image(perceptualPrecision: 0.98) // 98%一致で合格
)
// より厳密なチェック
assertSnapshot(
of: view,
as: .image(precision: 1.0, perceptualPrecision: 1.0)
)
extension UIView {
func maskDynamicContent() -> UIView {
// 日時表示などをマスク
subviews.filter { $0.accessibilityIdentifier == "timestamp" }
.forEach { $0.isHidden = true }
return self
}
}
func testFeed_maskTimestamps() {
let view = FeedView(posts: Post.mockList)
let controller = UIHostingController(rootView: view)
// タイムスタンプをマスクしてスナップショット
assertSnapshot(
of: controller.view.maskDynamicContent(),
as: .image
)
}
// ファイル名: {ViewName}SnapshotTests.swift
// テスト名: test{ViewName}_{State}_{Device}_{Theme}
func testProfileView_editing_iPhone15Pro_dark() { }
func testProfileView_viewing_iPadPro_light() { }
final class ProfileViewSnapshotTests: XCTestCase {
// MARK: - Default State
func testDefaultState() {
assertSnapshot(of: makeView(), as: .swiftUIImage())
}
// MARK: - User Interaction States
func testEditingState() {
assertSnapshot(of: makeView(isEditing: true), as: .swiftUIImage())
}
// MARK: - Device Variations
func testOnSmallDevice() {
assertSnapshot(of: makeView(), as: .swiftUIImage(size: SnapshotDevice.iPhoneSE.size))
}
// MARK: - Accessibility
func testLargeText() {
assertSnapshot(
of: makeView(),
as: .swiftUIImage(traits: .init(preferredContentSizeCategory: .accessibilityLarge))
)
}
// MARK: - Helpers
private func makeView(isEditing: Bool = false) -> some View {
ProfileView(user: .mock, isEditing: isEditing)
}
}
withSnapshotTesting(record: .all) { ... } でラップして再生成What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub caphtech/claude-marketplace --plugin mobile-plugin10 skills in this plugin
/flutter-widget-splittingFlutter Widgetの肥大化を、責務分離・共通化・Riverpod境界の整理でリファクタリングする。build()が長い、Widgetを分割したい、Riverpodのwatch/read/listen/select境界を見直したい、共通化したい、Flutter UIを整理したい時に使用。/ios-archiveアーカイブ・配布支援。App Store Connect、TestFlight、Ad Hoc/Enterprise配布。使用タイミング: (1) App Storeへの提出準備時、(2) TestFlight配布時、(3) Ad Hoc/Enterprise配布時、(4) CI/CDでの自動配布設定時/ios-ia-navigationiOSアプリの情報設計(IA)と画面遷移(ナビゲーション)を設計するスキル。Apple HIGとWWDCセッションに基づき、タブ/階層push/モーダルを情報階層とタスク構造から逆算して選定し、根拠と未確定事項を可視化しながら設計を完遂する。使用タイミング: (1) 新規アプリの情報設計時、(2) 画面遷移設計時、(3) 「IAを設計したい」「ナビゲーション構造を決めたい」、(4) iPad/iPhone両対応の構造設計時、(5) ディープリンク対応設計時、(6) 既存アプリのリファクタリング時Other plugins' skills for the same job