jpskill.com
📦 その他 コミュニティ

ios-uikit

UIKit: UIViewController, UITableView/CollectionView, Auto Layout, programmatic UI, UIHostingController bridge

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o ios-uikit.zip https://jpskill.com/download/22261.zip && unzip -o ios-uikit.zip && rm ios-uikit.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/22261.zip -OutFile "$d\ios-uikit.zip"; Expand-Archive "$d\ios-uikit.zip" -DestinationPath $d -Force; ri "$d\ios-uikit.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して ios-uikit.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → ios-uikit フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

ios-uikit

目的

このスキルは、UIKit を使用した iOS アプリ開発において、AI がユーザーインターフェースの構築と管理を支援することを目的としています。具体的には、UIViewController、UITableView/CollectionView、Auto Layout、プログラムによる UI 作成、および UIHostingController を介した SwiftUI へのブリッジングに焦点を当てています。

使用場面

このスキルは、ストーリーボードを使用せずにカスタムビュー、リスト、またはレイアウトが必要な iOS プロジェクトに活用できます。Swift アプリでのプログラムによる UI、UIKit と SwiftUI の統合、または UITableView での動的コンテンツの処理に最適です。SwiftUI のみを排他的に使用する場合や、iOS 以外のプラットフォームでは使用を避けてください。

主要な機能

  • UIViewController のライフサイクル管理: viewDidLoadviewWillAppear を実装してセットアップと更新を行います。
  • UITableView/CollectionView の処理: データソース、デリゲート、セル再利用を設定して、効率的なリストレンダリングを実現します。
  • Auto Layout をプログラムで適用: NSLayoutConstraint を使用してレイアウトを動的に定義し、デバイスサイズへの適応性を確保します。
  • プログラムによる UI の作成: UIView サブクラスを使用してビューを構築し、Interface Builder を介さずにコードでサブビューを追加します。
  • SwiftUI へのブリッジング: UIHostingController を使用して、UIKit アプリに SwiftUI ビューを埋め込み、混合アーキテクチャをサポートします。

使用パターン

UIViewController サブクラスを作成するには、UIViewController を継承する新しいクラスを定義し、主要なメソッドをオーバーライドします。たとえば、新しいファイルで次のように記述します。

import UIKit

class MyViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .white
    }
}

UITableView の場合、UITableViewDataSource を実装します。データソースを設定し、numberOfRowsInSectioncellForRowAt を定義します。次のようにセルクラスを登録してください。

let tableView = UITableView(frame: view.bounds)
tableView.dataSource = self
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")

Auto Layout を使用する場合は、制約をプログラムで追加します。アンカーを使用して配置します。たとえば、ボタンを中央に固定するには次のようにします。

let button = UIButton()
view.addSubview(button)
button.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true

UIHostingController ブリッジの場合、SwiftUI ビューを埋め込みます。インスタンスを作成し、それをルートビューコントローラーとして設定します。

let hostingController = UIHostingController(rootView: MySwiftUIView())
present(hostingController, animated: true)

リテインサイクルを避けるために、デリゲートでは常に weak 参照を使用し、レイアウトの応答性を確認するためにさまざまなデバイスでテストしてください。

一般的なコマンド/API

主要な API には、初期設定のための UIViewController メソッドである viewDidLoad() が含まれます。UITableView の場合、コンテンツを更新するには tableView.reloadData() を使用します。Auto Layout 制約を追加するには、配列とともに NSLayoutConstraint.activate() を使用します。Xcode でビルドするための CLI の例: xcodebuild -scheme MyApp -configuration Debug。プログラムによる UI の場合、UIView.addSubview() を使用し、フレームまたは制約を設定します。Info.plist の構成形式には、デバイスチェックのための UIRequiredDeviceCapabilities が含まれる場合があります。認証は直接必要ありませんが、サービスと統合する場合は、ビルドスクリプトで $API_KEY のような環境変数を使用します。特定のパターン: xcodebuild を実行する前に export API_KEY=your_key としてエクスポートします。一般的なエンドポイントはここでは適用されませんが、UIKit でのネットワーク呼び出しには、デリゲートとともに URLSession を使用します。基本的な URLSession のコードスニペット:

let session = URLSession.shared
let task = session.dataTask(with: URL(string: "https://example.com")!) { data, response, error in
    // Handle response
}
task.resume()

Auto Layout をエラーなく使用するには、更新後に常に layoutIfNeeded() を呼び出してください。

統合に関する注意事項

このスキルを統合するには、Swift ファイルで UIKit をインポートします。SwiftUI ブリッジの場合、SwiftUI もインポートされていることを確認してください。他のフレームワークと組み合わせる場合は、UIHostingController を使用して SwiftUI ビューをラップし、子ビューコントローラーとして追加します。設定については、AppDelegate または SceneDelegate で、たとえば application(_:didFinishLaunchingWithOptions:) でビューコントローラーをインスタンス化して表示します。Pod を使用する場合は、Podfile を介して pod 'SomeUIKitLib' を追加し、pod install を実行します。xcrun simctl boot "iPhone 14" でシミュレーターで統合をテストしてデバイスを起動します。環境変数については、コード内で let key = ProcessInfo.processInfo.environment["API_KEY"] のように参照します。制約を適用する前に、すべてのビューがビュー階層に追加されていることを確認してください。

エラー処理

Auto Layout の競合などの一般的なエラーは、ビジュアルフォーマット言語またはアンカーを正しく使用して処理します。Xcode の Debug View Hierarchy でデバッグします。UITableView の場合、didSelectRowAt を実装し、インデックスをチェックすることでデータソースのエラーを捕捉します。URLSession コールバックなどで、ランタイムの問題に対して try-catch を使用し、エラーをチェックします。

if let error = error {
    print("Error: \(error.localizedDescription)")
    return
}

UIViewController の場合、didReceiveMemoryWarning をオーバーライドしてリソースを解放します。デバッグのために os_log または print でエラーをログに記録し、デリゲートでの nil チェックには guard ステートメントを使用します。

グラフの関係

  • クラスター mobile に関連しています (例: クロスプラットフォーム UI パターンのために android-jetpack とタグを共有しています)。
  • タグを介して接続されています: uikit (ブリッジングのために swiftui にリンクしています)、ios (開発ワークフローのために xcode-build に接続しています)、viewcontroller (アプリフローのために navigation-stack に関連しています)、autolayout (適応型 UI のために responsive-design に結びついています)。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

ios-uikit

Purpose

This skill equips the AI to assist in iOS app development using UIKit, focusing on building and managing user interfaces with UIViewController, UITableView/CollectionView, Auto Layout, programmatic UI creation, and bridging to SwiftUI via UIHostingController.

When to Use

Use this skill for iOS projects needing custom views, lists, or layouts without storyboards; ideal for programmatic UI in Swift apps, integrating UIKit with SwiftUI, or handling dynamic content in UITableView; avoid if using SwiftUI exclusively or for non-iOS platforms.

Key Capabilities

  • Manage UIViewController lifecycle: Implement viewDidLoad, viewWillAppear for setup and updates.
  • Handle UITableView/CollectionView: Set up data sources, delegates, and cell reuse for efficient list rendering.
  • Apply Auto Layout programmatically: Use NSLayoutConstraint to define layouts dynamically, ensuring adaptability to device sizes.
  • Create programmatic UI: Build views using UIView subclasses and add subviews via code, bypassing Interface Builder.
  • Bridge to SwiftUI: Use UIHostingController to embed SwiftUI views in UIKit apps for mixed architecture support.

Usage Patterns

To create a UIViewController subclass, define a new class inheriting from UIViewController and override key methods; for example, in a new file, write:

import UIKit

class MyViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .white
    }
}

For UITableView, implement UITableViewDataSource: Set the data source, define numberOfRowsInSection, and cellForRowAt; ensure to register cell classes like this:

let tableView = UITableView(frame: view.bounds)
tableView.dataSource = self
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")

When using Auto Layout, add constraints programmatically: Use anchors for positioning, e.g., pin a button to the center:

let button = UIButton()
view.addSubview(button)
button.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true

For UIHostingController bridge, embed a SwiftUI view: Create an instance and set it as the root view controller:

let hostingController = UIHostingController(rootView: MySwiftUIView())
present(hostingController, animated: true)

Always use weak references in delegates to avoid retain cycles, and test on different devices for layout responsiveness.

Common Commands/API

Key APIs include UIViewController methods like viewDidLoad() for initial setup; for UITableView, use tableView.reloadData() to refresh content. To add Auto Layout constraints, employ NSLayoutConstraint.activate() with an array. Example CLI for building in Xcode: xcodebuild -scheme MyApp -configuration Debug. For programmatic UI, use UIView.addSubview() and set frames or constraints. Config format for Info.plist might include UIRequiredDeviceCapabilities for device checks. Auth isn't directly required, but if integrating with services, use env vars like $API_KEY in build scripts. Specific pattern: Export as export API_KEY=your_key before running xcodebuild. Common endpoints aren't applicable here, but for network calls in UIKit, use URLSession with delegates. Code snippet for basic URLSession:

let session = URLSession.shared
let task = session.dataTask(with: URL(string: "https://example.com")!) { data, response, error in
    // Handle response
}
task.resume()

For error-free Auto Layout, always call layoutIfNeeded() after updates.

Integration Notes

Integrate this skill by importing UIKit in Swift files; for SwiftUI bridges, ensure SwiftUI is also imported. When combining with other frameworks, use UIHostingController to wrap SwiftUI views and add as child view controllers. For config, set up in AppDelegate or SceneDelegate, e.g., in application(_:didFinishLaunchingWithOptions:), instantiate and present view controllers. If using pods, add via Podfile: pod 'SomeUIKitLib' and run pod install. Test integrations in a simulator with xcrun simctl boot "iPhone 14" to launch devices. For env vars, reference like let key = ProcessInfo.processInfo.environment["API_KEY"] in code. Ensure all views are added to the view hierarchy before applying constraints.

Error Handling

Handle common errors like Auto Layout conflicts by using visual format language or anchors correctly; debug with Xcode's Debug View Hierarchy. For UITableView, catch data source errors by implementing didSelectRowAt and checking indices. Use try-catch for runtime issues, e.g., in URLSession callbacks, check for errors:

if let error = error {
    print("Error: \(error.localizedDescription)")
    return
}

For UIViewController, override didReceiveMemoryWarning to release resources. Log errors with os_log or print for debugging, and use guard statements for nil checks in delegates.

Graph Relationships

  • Related to cluster: mobile (e.g., shares tags with android-jetpack for cross-platform UI patterns).
  • Connected via tags: uikit (links to swiftui for bridging), ios (connects to xcode-build for development workflows), viewcontroller (relates to navigation-stack for app flow), autolayout (ties to responsive-design for adaptive UIs).