All skills
johnrogers avatar

/swiftui-patterns

@1dc2cf4

Use when implementing iOS 17+ SwiftUI patterns: @Observable/@Bindable, MVVM architecture, NavigationStack, lazy loading, UIKit interop, accessibility (VoiceOver/Dynamic Type), async operations (.task/.refreshable), or migrating from ObservableObject/@StateObject.

Use this Skill: https://skilld.dev/gh/johnrogers/claude-swift-engineering/swiftui-patterns

This session only. Nothing lands on disk.

referencesmigration-guide.md

≈335 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Migration Checklist

When updating legacy SwiftUI code to iOS 17+:

  • Replace ObservableObject with @Observable
  • Remove all @Published (regular properties auto-publish)
  • Replace @StateObject with @State
  • Replace @ObservedObject with @Bindable
  • Replace environmentObject(_:) with environment(_:)
  • Replace @EnvironmentObject with @Environment(Type.self)
  • Update onChange(of:perform:) to onChange(of:initial:_:)
  • Replace .onAppear { Task {} } with .task

Before & After Example

Before (iOS 16)

class UserProfileModel: ObservableObject {
    @Published var name: String = ""
    @Published var email: String = ""
}

struct ProfileView: View {
    @StateObject private var model = UserProfileModel()

    var body: some View {
        TextField("Name", text: $model.name)
            .onAppear {
                Task {
                    await model.load()
                }
            }
    }
}

After (iOS 17+)

@Observable
class UserProfileModel {
    var name: String = ""
    var email: String = ""
}

struct ProfileView: View {
    @State private var model = UserProfileModel()

    var body: some View {
        TextField("Name", text: $model.name)
            .task {
                await model.load()
            }
    }
}

Source: SKILL.md on GitHub

1 warning16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    This skill is a collection of documentation and code snippets for modern SwiftUI development on iOS 17+. No security issues or malicious patterns were detected.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer7mo

    13/13 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 1dc2cf4. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 9 months ago

README badge

README badge for johnrogers/claude-swift-engineering/swiftui-patterns