agentleFS
VincentShipsItVincentShipsIt/meterbar.dev/skills/xcode-swift-dev/SKILL.md

xcode-swift-dev

Skill12 starsChanged 6 days agoMITView on GitHub

Expert in Swift/SwiftUI development for macOS menu bar apps, iOS apps, widgets, and Xcode project configuration. Use for Swift architecture, SwiftUI patterns, App Intents, WidgetKit, and native Apple platform development.

The file

Show its rules and text

We split this skill into the rules it gives an agent

16 rules. About 0 are common, 6 are distinctive, and 10 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 10

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use MVVM with @Observable (iOS 17+) or ObservableObject

    line 25
  2. Distinctive:

    Prefer composition over inheritance

    line 26
  3. Distinctive:

    Keep views small and focused

    line 27
  4. Very specific:

    Use TimelineProvider for data updates

    line 78
  5. Distinctive:

    Keep widget views lightweight

    line 79
  6. Very specific:

    Use @Environment(\.widgetFamily) for adaptive layouts

    line 81
  7. Very specific:

    Use kSecClassGenericPassword for API keys

    line 86
  8. Very specific:

    Use async/await for asynchronous operations

    line 93
  9. Very specific:

    Use Task for launching async work from sync contexts

    line 95
  10. Very specific:

    Prefer AsyncStream for continuous data

    line 96
  11. Distinctive:

    Use XCTest for unit tests

    line 179
  12. Distinctive:

    Test business logic in Services

    line 180
  13. Very specific:

    Use @testable import for internal access

    line 181
  14. Very specific:

    Use #if DEBUG for debug-only code

    line 189
  15. Very specific:

    Use .xcconfig files for build settings

    line 191
  16. Distinctive:

    Keep secrets out of source (use Keychain or secure config)

    line 192

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Xcode Swift Developer

Expert guidance for native Apple platform development with Swift and SwiftUI.

When to Use

  • Building macOS menu bar apps
  • Creating iOS/macOS widgets (WidgetKit)
  • Implementing App Intents and Shortcuts
  • SwiftUI component architecture
  • Xcode project configuration
  • Swift Package Manager setup
  • Code signing and entitlements
  • App Store / TestFlight preparation

Core Principles

SwiftUI Architecture

  • Use MVVM with @Observable (iOS 17+) or ObservableObject
  • Prefer composition over inheritance
  • Keep views small and focused
  • Extract reusable components to separate files

Project Structure (macOS Menu Bar App)

AppName/
├── App/
│   └── AppNameApp.swift          # @main entry point
├── Models/
│   ├── ServiceType.swift         # Enums and data models
│   └── UsageMetrics.swift        # Core data structures
├── Services/
│   ├── ServiceManager.swift      # Business logic
│   ├── KeychainManager.swift     # Secure storage
│   └── APIClient.swift           # Network layer
├── Views/
│   ├── MenuBarView.swift         # Main menu bar content
│   ├── SettingsView.swift        # Preferences window
│   └── Components/               # Reusable UI components
└── Info.plist

AppNameWidget/
├── AppNameWidgetBundle.swift     # Widget bundle entry
├── UsageWidget.swift             # Widget implementation
├── Assets.xcassets/
└── Info.plist

Menu Bar App Pattern

@main
struct AppNameApp: App {
    @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate

    var body: some Scene {
        MenuBarExtra("App Name", systemImage: "chart.bar") {
            MenuBarView()
        }
        .menuBarExtraStyle(.window)

        Settings {
            SettingsView()
        }
    }
}

Widget Development

  • Use TimelineProvider for data updates
  • Keep widget views lightweight
  • Support multiple widget families (small, medium, large)
  • Use @Environment(\.widgetFamily) for adaptive layouts
  • Share data via App Groups

Keychain Best Practices

  • Use kSecClassGenericPassword for API keys
  • Set kSecAttrAccessible appropriately
  • Group related items with kSecAttrService
  • Handle errors gracefully (item not found, access denied)

Swift Concurrency

  • Use async/await for asynchronous operations
  • Mark main-thread-bound code with @MainActor
  • Use Task for launching async work from sync contexts
  • Prefer AsyncStream for continuous data

Code Signing & Entitlements

Common entitlements for menu bar apps:

  • com.apple.security.app-sandbox
  • com.apple.security.network.client
  • com.apple.security.keychain-access-groups
  • com.apple.security.application-groups (for widget data sharing)

SwiftLint Configuration

disabled_rules:
  - line_length
  - trailing_whitespace

opt_in_rules:
  - empty_count
  - closure_spacing
  - force_unwrapping

excluded:
  - .build
  - .swiftpm

Common Patterns

API Client

actor APIClient {
    private let session = URLSession.shared
    private let baseURL: URL

    func fetch<T: Decodable>(_ endpoint: String) async throws -> T {
        let url = baseURL.appendingPathComponent(endpoint)
        let (data, response) = try await session.data(from: url)
        guard let httpResponse = response as? HTTPURLResponse,
              (200...299).contains(httpResponse.statusCode) else {
            throw APIError.invalidResponse
        }
        return try JSONDecoder().decode(T.self, from: data)
    }
}

Shared Data Store (App Groups)

final class SharedDataStore {
    static let shared = SharedDataStore()

    private let defaults: UserDefaults

    init() {
        defaults = UserDefaults(suiteName: "group.com.company.appname")!
    }

    var usageData: UsageData? {
        get {
            guard let data = defaults.data(forKey: "usageData") else { return nil }
            return try? JSONDecoder().decode(UsageData.self, from: data)
        }
        set {
            let data = try? JSONEncoder().encode(newValue)
            defaults.set(data, forKey: "usageData")
        }
    }
}

File Naming Conventions

  • Views: *View.swift (e.g., SettingsView.swift)
  • Models: Descriptive nouns (e.g., UsageMetrics.swift)
  • Services: *Manager.swift or *Service.swift
  • Extensions: Type+Extension.swift
  • Protocols: *Protocol.swift or *able.swift

Testing

  • Use XCTest for unit tests
  • Test business logic in Services
  • Use @testable import for internal access
  • Mock network with URLProtocol
  • Snapshot test SwiftUI views with swift-snapshot-testing

Build Configuration

Debug vs Release

  • Use #if DEBUG for debug-only code
  • Configure schemes for different environments
  • Use .xcconfig files for build settings
  • Keep secrets out of source (use Keychain or secure config)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.