swift-build
SwiftプロジェクトのビルドとテストをXcodeコマンドラインで実行(iOS/macOS対応)。Use when: ビルド、テスト、xcodebuild、swift test を依頼された時。
When & Why to Use This Skill
This Claude skill automates Swift and Xcode development workflows by providing a comprehensive interface for building, testing, and archiving iOS and macOS applications via the command line. It simplifies complex xcodebuild operations, manages multi-platform destinations (including Mac Catalyst and Universal Binaries), and integrates essential code quality tools like SwiftLint and swift-format to ensure high-performance, error-free software delivery.
Use Cases
- Automated Testing: Execute unit tests across various iOS simulators and macOS environments to ensure code reliability and catch regressions early.
- Continuous Integration: Streamline the build process for different architectures, including creating Universal Binaries (arm64 + x86_64) for macOS.
- Release Preparation: Generate production-ready archives (.xcarchive) for iOS and macOS apps, ready for App Store distribution or enterprise deployment.
- Code Quality Auditing: Automatically run static analysis and formatting checks using SwiftLint and swift-format to maintain consistent coding standards.
- Environment Troubleshooting: Quickly diagnose build issues by listing available simulators, schemes, and destinations directly through the agent.
| name | swift-build |
|---|---|
| description | "SwiftプロジェクトのビルドとテストをXcodeコマンドラインで実行(iOS/macOS対応)。Use when: ビルド、テスト、xcodebuild、swift test を依頼された時。" |
Swift ビルド&テスト(iOS / macOS 対応)
プラットフォーム別コマンド
iOS Simulator
xcodebuild build -scheme YourApp -destination 'platform=iOS Simulator,name=iPhone 16e'
xcodebuild test -scheme YourApp -destination 'platform=iOS Simulator,name=iPhone 16e'
macOS
xcodebuild build -scheme YourApp -destination 'platform=macOS'
xcodebuild test -scheme YourApp -destination 'platform=macOS'
Mac Catalyst
xcodebuild build -scheme YourApp -destination 'platform=macOS,variant=Mac Catalyst'
実行手順
- スキーム確認:
xcodebuild -list - フォーマットチェック:
swift-format lint -r Sources/ - ビルド: 上記プラットフォーム別コマンド
- ユニットテスト: 上記プラットフォーム別コマンド
- 静的解析:
swiftlint lint
Universal Binary(macOS)
# arm64 + x86_64 のユニバーサルビルド
xcodebuild build -scheme YourApp -destination 'platform=macOS' \
ARCHS="arm64 x86_64" ONLY_ACTIVE_ARCH=NO
クリーンビルド
xcodebuild clean build -scheme YourApp -destination 'platform=macOS'
アーカイブ(リリース用)
iOS
xcodebuild archive -scheme YourApp -archivePath ./build/YourApp.xcarchive \
-destination 'generic/platform=iOS'
macOS
xcodebuild archive -scheme YourApp -archivePath ./build/YourApp.xcarchive \
-destination 'platform=macOS'
トラブルシューティング
シミュレーター一覧
xcrun simctl list devices available
利用可能なデスティネーション
xcodebuild -showdestinations -scheme YourApp