Get the FREE Ultimate OpenClaw Setup Guide →

building-apple-platform-products

Scanned
npx machina-cli add skill kylehughes/apple-platform-build-tools-claude-code-plugin/building-apple-platform-products --openclaw
Files (1)
SKILL.md
5.9 KB

Building Apple Platform Products

Build, test, and archive Swift packages and Xcode projects for Apple platforms.

When to Use This Skill

Use this skill when you need to:

  • Build an iOS, macOS, tvOS, watchOS, or visionOS app
  • Build a Swift package
  • Run unit tests or UI tests
  • Create an archive for distribution
  • Discover project structure (schemes, targets, configurations)

Tool Selection

Project TypePrimary ToolWhen to Use
Standalone Package.swiftswift buildLibraries, CLI tools, cross-platform Swift (no .xcodeproj)
.xcworkspacexcodebuild -workspaceCocoaPods or multi-project setups
.xcodeprojxcodebuildStandard Xcode projects (including those with SPM dependencies)

Important: The swift build / swift test commands only work for standalone Swift packages. If a Swift package is embedded as a submodule within an Xcode project, you must use xcodebuild with the appropriate scheme—the Swift CLI cannot orchestrate builds in that context.

Project Discovery

Before building, discover the project structure:

# Find what project files exist
ls Package.swift *.xcworkspace *.xcodeproj 2>/dev/null

# List schemes and targets (auto-detects project)
xcodebuild -list

# Describe package (standalone SPM only)
swift package describe

Note: When an Xcode project references a local Swift package, each package target gets its own scheme (named after the target, not the package). Use these schemes to build individual targets without building the entire app.

For mixed projects, shared schemes, or detailed output parsing, see project-discovery.md.

Swift Package Manager Commands

Important: These commands only work for standalone Swift packages, not Swift Package Manager submodules in Xcode projects.

GoalCommand
Build (debug)swift build
Build (release)swift build -c release
Run executableswift run [<target>]
Run testsswift test
Run specific testswift test --filter <TestClass.testMethod>
Show binary pathswift build --show-bin-path
Cleanswift package clean
Initializeswift package init [--type library|executable]

For cross-compilation, Package.swift syntax, or dependency management, see swift-package-manager.md.

xcodebuild Commands

Command structure: xcodebuild [action] -scheme <name> [-workspace|-project] [options] [BUILD_SETTING=value]

GoalCommand
List schemesxcodebuild -list
Buildxcodebuild build -scheme <name>
Testxcodebuild test -scheme <name> -destination '<spec>'
Build for testingxcodebuild build-for-testing -scheme <name> -destination '<spec>'
Test without buildxcodebuild test-without-building -scheme <name> -destination '<spec>'
Archivexcodebuild archive -scheme <name> -archivePath <path>.xcarchive
Cleanxcodebuild clean -scheme <name>

Required: -scheme is always required. Add -workspace or -project when multiple exist. For tests: -destination is required for iOS/tvOS/watchOS/visionOS targets.

For build settings, SDK selection, or CI configuration, see xcodebuild-basics.md.

Common Destinations

PlatformDestination Specifier
macOS'platform=macOS'
iOS Simulator'platform=iOS Simulator,name=iPhone 17'
iOS Device'platform=iOS,id=<UDID>'
tvOS Simulator'platform=tvOS Simulator,name=Apple TV'
watchOS Simulator'platform=watchOS Simulator,name=Apple Watch Series 11 (46mm)'
visionOS Simulator'platform=visionOS Simulator,name=Apple Vision Pro'
Generic (build only)'generic/platform=iOS'

Note: Simulator names change with each Xcode release. Always verify available simulators:

xcrun simctl list devices available

For all platforms, multiple destinations, or troubleshooting destination errors, see destinations.md.

Reference Files

TopicFileWhen to Read
Project Discoveryproject-discovery.mdMixed projects, shared schemes
Swift Package Managerswift-package-manager.mdCross-compilation, Package.swift syntax
xcodebuild Basicsxcodebuild-basics.mdBuild settings, SDK selection
Destinationsdestinations.mdAll platforms, multiple destinations
Testingtesting.mdTest filtering, parallel execution, coverage
Archivingarchiving.mdArchive creation
Troubleshootingtroubleshooting.mdBuild/test failures, error recovery

Common Pitfalls

  1. swift build with Xcode submodules: Only works for standalone packages. Use xcodebuild with the package's scheme instead.
  2. Missing destination for iOS: Use -destination 'generic/platform=iOS' for builds, or specify a simulator for tests.
  3. Unnecessary workspace flag: Only use -workspace for CocoaPods or multi-project setups. Standard projects with SPM dependencies just use .xcodeproj.
  4. Case-sensitive scheme names: Run xcodebuild -list to see exact scheme names.
  5. Outdated simulator names: Names change with Xcode versions. Run xcrun simctl list devices available.
  6. Code signing errors: Add CODE_SIGNING_ALLOWED=NO for builds that don't require signing.

Source

git clone https://github.com/kylehughes/apple-platform-build-tools-claude-code-plugin/blob/main/skills/building-apple-platform-products/SKILL.mdView on GitHub

Overview

This skill builds, tests, and archives Swift packages and Xcode projects for Apple platforms such as iOS, macOS, tvOS, watchOS, and visionOS. It guides you in choosing the right tool (swift build/ swift test vs xcodebuild), discovering schemes and targets, and selecting simulator destinations. It helps you understand project structure and how to orchestrate builds in mixed environments.

How This Skill Works

Use swift build, swift test, and swift run for standalone Swift packages. Use xcodebuild with -scheme (and -workspace or -project) for Xcode projects or workspaces, including those with Swift package manager dependencies. Discover project structure with ls Package.swift and xcodebuild -list, and map each package target to its own scheme when applicable.

When to Use It

  • Build an iOS, macOS, tvOS, watchOS, or visionOS app
  • Build a Swift package
  • Run unit tests or UI tests
  • Create an archive for distribution
  • Discover project structure (schemes, targets, configurations)

Quick Start

  1. Step 1: Discover project structure with ls Package.swift *.xcworkspace *.xcodeproj and xcodebuild -list
  2. Step 2: Choose the right tool: swift build for standalone packages, or xcodebuild with -scheme for Xcode projects
  3. Step 3: Run the appropriate command (build/test/archive) and specify -destination for iOS/tvOS/watchOS/visionOS tests

Best Practices

  • Use xcodebuild -list to discover available schemes before building
  • Choose swift build for standalone Swift packages and xcodebuild for Xcode projects
  • For tests, include -destination for iOS/tvOS/watchOS/visionOS targets
  • When a Swift package is embedded in an Xcode project, use xcodebuild with the appropriate scheme
  • Remember that swift build only works for standalone packages; submodules inside Xcode projects require xcodebuild

Example Use Cases

  • Build an iOS app with xcodebuild -workspace App.xcworkspace -scheme MyApp -destination 'platform=iOS Simulator,name=iPhone 17'
  • Build a standalone Swift package with swift build
  • Describe a package with swift package describe
  • List available schemes with xcodebuild -list
  • Archive an app with xcodebuild archive -scheme MyApp -archivePath MyApp.xcarchive

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers