mcpField
S
swift-development

swift-development

github.com/hmohamed01開発6154 回インストール29 週間前に更新
リポジトリ

swift-development について

Swift開発者向けの開発スキルです。パッケージやアプリのビルド、テスト、フォーマット、シミュレーター管理を扱い、スクリプト、テンプレート、分野別の参考資料を含みます。

主な機能

  1. 01Swift Package作成用スクリプトとテンプレート
  2. 02SwiftPMとxcodebuildによるビルドとテスト
  3. 03SwiftコードのフォーマットとLint
  4. 04iOSシミュレーター管理スクリプト
  5. 05SwiftUI、並行処理、アーキテクチャの参考資料

活用シーン

  1. 01新しいSwiftライブラリパッケージの作成
  2. 02iOSアプリのビルドとテスト
  3. 03SwiftソースのフォーマットとLint
  4. 04シミュレーターの起動とアプリのインストール

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/hmohamed01/swift-development --skill swift-development

インストール後、Claude Code で/swift-developmentを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

assets/
.swiftformat
.swiftlint.yml
Package.swift.template
assets/ExportOptions/
ad-hoc.plist
app-store.plist
development.plist
references/
architecture.md
best-practices.md
cicd.md
code-signing.md
concurrency.md
simctl.md
spm.md
swiftui-patterns.md
testing-patterns.md
troubleshooting.md
xcodebuild.md
scripts/
format_and_lint.sh
new_package.sh
run_tests.sh
simulator.sh

詳細

Swift 開発

前提条件

  • Xcode 15 以降がインストールされた macOS(Swift 6 の場合は Xcode 16 以降)
  • Xcode Command Line Tools:xcode-select --install
  • 確認:xcodebuild -version と swift --version

クイックスタート

新しい Swift パッケージ
# Use the included script for full setup
./scripts/new_package.sh MyLibrary --type library --ios --macos

# Or manually
swift package init --type library --name MyLibrary
ビルドとテスト
# SPM packages
swift build
swift test

# Xcode projects
xcodebuild -workspace App.xcworkspace -scheme App \
    -destination 'platform=iOS Simulator,name=iPhone 15' build

# Use included script for common options
./scripts/run_tests.sh --parallel --coverage
フォーマットとリンティング
# Use included script
./scripts/format_and_lint.sh Sources/

# Check mode (CI)
./scripts/format_and_lint.sh --check
シミュレーターの管理
# Use included script
./scripts/simulator.sh list
./scripts/simulator.sh boot "iPhone 15"
./scripts/simulator.sh screenshot
./scripts/simulator.sh dark

主要なワークフロー

iOS アプリのビルド
# Debug build for simulator
xcodebuild -workspace App.xcworkspace -scheme App \
    -destination 'platform=iOS Simulator,name=iPhone 15' \
    build

# Release archive
xcodebuild archive \
    -workspace App.xcworkspace -scheme App \
    -archivePath ./build/App.xcarchive \
    -configuration Release

# Export IPA (use templates from assets/ExportOptions/)
xcodebuild -exportArchive \
    -archivePath ./build/App.xcarchive \
    -exportPath ./build/export \
    -exportOptionsPlist assets/ExportOptions/app-store.plist
テスト
# All tests
xcodebuild test -workspace App.xcworkspace -scheme App \
    -destination 'platform=iOS Simulator,name=iPhone 15'

# Specific test
xcodebuild test -only-testing:AppTests/MyTestClass/testMethod

# With coverage
xcodebuild test -enableCodeCoverage YES \
    -resultBundlePath ./TestResults.xcresult
アプリのインストール
# Install on booted simulator
xcrun simctl install booted ./Build/Products/Debug-iphonesimulator/App.app

# Launch
xcrun simctl launch booted com.company.app

公式ドキュメント

参考リンク(人間向け)

以下は、手動で閲覧するための Apple 公式ドキュメントへのリンクです。

リソースURL
Swift ドキュメントhttps://developer.apple.com/documentation/swift
SwiftUIhttps://developer.apple.com/documentation/swiftui
Swift Concurrencyhttps://developer.apple.com/documentation/swift/concurrency
Swift Testinghttps://developer.apple.com/documentation/testing

注:Apple のドキュメントサイトは JavaScript の SPA であり、WebFetch ではプログラムから取得できません。代わりに、以下の GitHub ベースのソースを使用してください。

WebFetch 対応ソース(GitHub の raw URL)

必ず raw.githubusercontent.com の URL を使用してください。通常の github.com の URL は文字化けした HTML/JSON を返します。

ベース URL のプレフィックス:https://raw.githubusercontent.com/apple

Swift Testing(/swift-testing/main/):

リソースパス
READMEREADME.md
テストの定義Sources/Testing/Testing.docc/DefiningTests.md
テストの整理Sources/Testing/Testing.docc/OrganizingTests.md
期待値Sources/Testing/Testing.docc/Expectations.md
パラメーター化テストSources/Testing/Testing.docc/ParameterizedTesting.md
Trait の概要Sources/Testing/Testing.docc/Traits.md
Trait のリファレンスSources/Testing/Testing.docc/Traits/Trait.md
タグの追加Sources/Testing/Testing.docc/AddingTags.md
コメントの追加Sources/Testing/Testing.docc/AddingComments.md
バグの関連付けSources/Testing/Testing.docc/AssociatingBugs.md
バグ識別子Sources/Testing/Testing.docc/BugIdentifiers.md
添付ファイルSources/Testing/Testing.docc/Attachments.md
テストの有効化/無効化Sources/Testing/Testing.docc/EnablingAndDisabling.md
実行時間の制限Sources/Testing/Testing.docc/LimitingExecutionTime.md
並列化Sources/Testing/Testing.docc/Parallelization.md
終了テストSources/Testing/Testing.docc/exit-testing.md
既知の問題Sources/Testing/Testing.docc/known-issues.md
非同期コードのテストSources/Testing/Testing.docc/testing-asynchronous-code.md
エラーのテストSources/Testing/Testing.docc/testing-for-errors-in-swift-code.md
XCTest からの移行Sources/Testing/Testing.docc/MigratingFromXCTest.md
ビジョンと設計Documentation/Vision.md
CLI のデバッグDocumentation/CommandlineDebugging.md
環境変数Documentation/EnvironmentVariables.md

その他の Swift パッケージ:

リソースRaw URL 全体
Swift Async Algorithmshttps://raw.githubusercontent.com/apple/swift-async-algorithms/main/README.md
Swift Collectionshttps://raw.githubusercontent.com/apple/swift-collections/main/README.md

Swift Evolution の提案については、提案番号から raw URL を組み立ててください。 https://raw.githubusercontent.com/apple/swift-evolution/main/proposals/NNNN-proposal-name.md

例:https://raw.githubusercontent.com/apple/swift-evolution/main/proposals/0409-access-level-on-imports.md

ディレクトリの検索(提案番号やドキュメントのファイル名の検索)には、WebFetch ではなく WebSearch を使用してください。GitHub のディレクトリ一覧は解析できません。

ドキュメントを取得するタイミング

次のような場合は、WebFetch と GitHub の raw URL を使用します。

  1. Swift Testing:@Test、#expect、#require、トレイト、またはパラメーター化テストの詳細が必要な場合
  2. Swift Evolution:新しい言語機能に関する採択済みの提案を確認する場合
  3. フレームワークの詳細:Apple のオープンソース Swift パッケージの機能を実装する場合
  4. 不明点がある場合:現在の API のパターンやベストプラクティスがわからない場合

URL の変換ルール:github.com/{owner}/{repo}/blob/{branch}/ を raw.githubusercontent.com/{owner}/{repo}/{branch}/ に置き換えます。

フォールバック:raw URL に対する WebFetch が失敗した場合は、site:github.com/apple {topic} というクエリで WebSearch を使用して正しいファイルパスを確認し、raw URL を組み立てます。

WebFetch 用のプロンプト例:「このドキュメントから主な機能、マクロ、使用例を抽出してください」


参照ファイル

特定のトピックに関する詳細なドキュメントです。

トピックファイル
SwiftUI のパターンreferences/swiftui-patterns.md
テストのパターンreferences/testing-patterns.md
Swift 6 の並行処理references/concurrency.md
アーキテクチャのパターンreferences/architecture.md
ベストプラクティスreferences/best-practices.md
Swift Package Managerreferences/spm.md
xcodebuild コマンドreferences/xcodebuild.md
シミュレーターの操作references/simctl.md
コード署名references/code-signing.md
CI/CD のセットアップreferences/cicd.md
トラブルシューティングreferences/troubleshooting.md

同梱スクリプト

スクリプト用途
scripts/new_package.sh設定ファイルを含む新しい Swift パッケージを作成します
scripts/run_tests.sh一般的なオプションを指定してテストを実行します
scripts/format_and_lint.shSwift コードをフォーマットし、リンティングします
scripts/simulator.shシミュレーターをすばやく管理します

アセットテンプレート

アセット用途
assets/Package.swift.templateSwift パッケージのテンプレート
assets/.swiftformatSwiftFormat の設定
assets/.swiftlint.ymlSwiftLint の設定
assets/ExportOptions/アーカイブ書き出し用 plist テンプレート

クイックリファレンス

基本コマンド
タスクコマンド
パッケージをビルドswift build
リリース版をビルドswift build -c release
テストを実行swift test
依存関係を更新swift package update
シミュレーターを一覧表示xcrun simctl list devices
シミュレーターを起動xcrun simctl boot "iPhone 15"
アプリをインストールxcrun simctl install booted ./App.app
コードをフォーマットswiftformat .
コードをリンティングswiftlint
よく使う実行先
# iOS Simulator
-destination 'platform=iOS Simulator,name=iPhone 15'

# macOS
-destination 'platform=macOS'

# Generic iOS (for archives)
-destination 'generic/platform=iOS'

コメント