home / skills / pproenca / dot-skills / ios-xcode

This skill helps you set up Xcode projects, manage SwiftData models, tests, debugging, and distribution for iOS, visionOS, and ML features.

npx playbooks add skill pproenca/dot-skills --skill ios-xcode

Review the files below or copy the command above to add this skill to your agents.

Files (22)
SKILL.md
3.9 KB
---
name: ios-xcode
description: Xcode project setup, SwiftData persistence, testing, debugging, profiling, and app distribution for iOS development. This skill should be used when setting up Xcode projects, working with SwiftData models and queries, writing Swift tests, debugging with breakpoints, profiling with Instruments, distributing via TestFlight, or building for visionOS and ML features.
---

# iOS Xcode & Tooling Best Practices

Comprehensive guide for Xcode project configuration, SwiftData persistence, testing, debugging, profiling, and app distribution. Contains 19 rules across 6 categories.

## When to Apply

Reference these guidelines when:
- Setting up Xcode projects with AppStorage, ScenePhase, or widgets
- Implementing SwiftData models, queries, and CRUD operations
- Writing tests with Swift Testing framework
- Debugging with breakpoints and console output
- Profiling performance with Instruments
- Distributing apps via TestFlight
- Building for visionOS or integrating ML features

## Rule Categories by Priority

| Priority | Category | Impact | Prefix |
|----------|----------|--------|--------|
| 1 | SwiftData & Persistence | CRITICAL | `data-` |
| 2 | Project & Platform | HIGH | `platform-` |
| 3 | Testing | HIGH | `test-` |
| 4 | Debugging & Profiling | MEDIUM-HIGH | `debug-`, `perf-` |
| 5 | Distribution | MEDIUM | `dist-` |
| 6 | Specialty Platforms | MEDIUM | `ml-`, `spatial-` |

## Quick Reference

### 1. Project & Platform (HIGH)

- [`platform-app-storage`](references/platform-app-storage.md) - Use AppStorage for user preferences
- [`platform-scene-phase`](references/platform-scene-phase.md) - Respond to app lifecycle with ScenePhase
- [`platform-widget-integration`](references/platform-widget-integration.md) - Design for widget and Live Activity integration
- [`platform-system-features`](references/platform-system-features.md) - Integrate system features natively

### 2. SwiftData & Persistence (CRITICAL)

- [`data-model-macro`](references/data-model-macro.md) - Define models with @Model macro
- [`data-query-for-fetching`](references/data-query-for-fetching.md) - Use @Query for fetching data
- [`data-model-container`](references/data-model-container.md) - Configure model containers
- [`data-relationships`](references/data-relationships.md) - Define model relationships
- [`data-crud-operations`](references/data-crud-operations.md) - Implement CRUD operations

### 3. Testing (HIGH)

- [`test-swift-testing`](references/test-swift-testing.md) - Use Swift Testing framework
- [`test-preview-sample-data`](references/test-preview-sample-data.md) - Create preview sample data
- [`test-preview-macro`](references/test-preview-macro.md) - Use #Preview macro for rapid iteration

### 4. Debugging & Profiling (MEDIUM-HIGH)

- [`debug-breakpoints`](references/debug-breakpoints.md) - Use breakpoints for debugging
- [`debug-console-output`](references/debug-console-output.md) - Use console output for debugging
- [`perf-instruments-profiling`](references/perf-instruments-profiling.md) - Profile SwiftUI with Instruments

### 5. Distribution (MEDIUM)

- [`dist-testflight`](references/dist-testflight.md) - Distribute via TestFlight
- [`dist-app-icons`](references/dist-app-icons.md) - Design app icons for distribution

### 6. Specialty Platforms (MEDIUM)

- [`ml-natural-language`](references/ml-natural-language.md) - Integrate Natural Language ML
- [`spatial-visionos-windows`](references/spatial-visionos-windows.md) - Build for visionOS spatial computing

## How to Use

Read individual reference files for detailed explanations and code examples:

- [Section definitions](references/_sections.md) - Category structure and impact levels
- [Rule template](assets/templates/_template.md) - Template for adding new rules

## Reference Files

| File | Description |
|------|-------------|
| [references/_sections.md](references/_sections.md) | Category definitions and ordering |
| [assets/templates/_template.md](assets/templates/_template.md) | Template for new rules |

Overview

This skill provides practical guidance for Xcode project setup, SwiftData persistence, testing, debugging, profiling, and app distribution for iOS and visionOS. It bundles prioritized rules and actionable references to help you configure projects, model data, validate behavior with tests, and ship builds via TestFlight. Use it to streamline development workflows and avoid common pitfalls across platform, data, and tooling tasks.

How this skill works

The skill inspects your development goal and points you to focused rules and reference files organized by priority: SwiftData (critical), project/platform, testing, debugging/profiling, distribution, and specialty platforms. Each rule links to concise guidance and code patterns such as @Model, @Query, model containers, breakpoints, Instruments usage, and TestFlight distribution steps. Follow the referenced rule pages for examples and step-by-step actions.

When to use it

  • When creating or configuring an Xcode project that uses AppStorage, ScenePhase, widgets, or system features.
  • When defining persistence with SwiftData models, relationships, model containers, and CRUD operations.
  • When writing unit and integration tests with Swift Testing and creating preview sample data.
  • When debugging runtime issues with breakpoints, console logs, or needing to profile performance with Instruments.
  • When preparing builds and metadata for TestFlight distribution or optimizing app icons and assets.
  • When targeting visionOS or integrating ML features like Natural Language models and spatial windows.

Best practices

  • Define data models with the @Model macro and keep relationships explicit for predictable queries.
  • Use @Query for fetching and separate data access from UI logic; inject model containers for testability.
  • Leverage Swift Testing and preview sample data to validate UI and data flows quickly before device runs.
  • Use symbolic breakpoints, conditional logging, and Instruments (Time Profiler, Allocations) for targeted profiling.
  • Automate builds and ensure asset catalogs and icons meet platform requirements before TestFlight upload.
  • Apply platform features (AppStorage, ScenePhase) conservatively and test lifecycle changes across device states.

Example use cases

  • Set up a new Xcode app using SwiftData to persist user-created records and sync relationships.
  • Write unit tests for model CRUD operations and use preview sample data to iterate UI components.
  • Diagnose a memory spike by profiling with Instruments and tracking suspected retain cycles in SwiftUI views.
  • Prepare a beta build, verify app icons and entitlements, and distribute via TestFlight to QA testers.
  • Adapt an iOS app for visionOS with spatial windows and integrate a Natural Language ML model for on-device features.

FAQ

When should I prefer SwiftData over Core Data or other stores?

Use SwiftData when you want a modern, Swift-native persistence layer with macros, easy queries, and tight SwiftUI integration; consider Core Data only for legacy compatibility or specific advanced features not yet covered by SwiftData.

How do I test SwiftData models without touching production storage?

Configure an in-memory model container for tests and inject it into your view models or repositories so tests run isolated from production files.