Guides iOS native development with Swift, SwiftUI, and UIKit. Covers architecture (MVVM, TCA, VIPER), property wrappers, Swift concurrency, and networking. Activates on iOS, Swift, SwiftUI, Xcode, Core Data.
Ships in claude-skills-collection. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
| Contexte | Architecture recommandée |
|---|---|
| Petit projet / MVP SwiftUI | MVVM + @Observable |
| SwiftUI complexe, testabilité maximale | TCA (The Composable Architecture) |
| Grande équipe, UIKit dominant | VIPER ou Clean Swift (VIP) |
| Migration progressive UIKit→SwiftUI | MVVM + Coordinator |
// MVVM avec @Observable (Swift 5.9+, iOS 17)
@Observable
final class ProfileViewModel {
var username: String = ""
var isLoading: Bool = false
private let repository: ProfileRepository
init(repository: ProfileRepository) {
self.repository = repository
}
func fetchProfile(id: String) async {
isLoading = true
defer { isLoading = false }
username = await repository.fetch(id: id).name
}
}
// Dans la View — pas besoin de @ObservedObject avec @Observable
struct ProfileView: View {
@State private var vm = ProfileViewModel(repository: .live)
var body: some View {
Group {
if vm.isLoading { ProgressView() }
else { Text(vm.username) }
}
.task { await vm.fetchProfile(id: "42") }
}
}
Critères de décision :
iOS 16+ cible minimale → SwiftUI first.WKWebView, MKMapView avancé) → UIViewRepresentable.UIHostingController.// Interop UIKit → SwiftUI
struct WebViewRepresentable: UIViewRepresentable {
let url: URL
func makeUIView(context: Context) -> WKWebView { WKWebView() }
func updateUIView(_ uiView: WKWebView, context: Context) {
uiView.load(URLRequest(url: url))
}
}
Property wrappers — règle rapide :
@State : valeur locale, non partagée.@Binding : valeur owned par le parent, mutation bidirectionnelle.@Environment : valeurs système (\.colorScheme, \.dismiss).@EnvironmentObject : objet partagé injecté haut dans l'arbre.@Observable (iOS 17) : remplace ObservableObject + @Published.// URLSession + async/await + Codable
struct APIClient {
func fetch<T: Decodable>(_ endpoint: URL) async throws -> T {
let (data, response) = try await URLSession.shared.data(from: endpoint)
guard (response as? HTTPURLResponse)?.statusCode == 200 else {
throw APIError.badStatus
}
return try JSONDecoder().decode(T.self, from: data)
}
}
// Annulation propre avec Task
func loadData() {
Task {
do {
let user: User = try await APIClient().fetch(endpoint)
await MainActor.run { self.user = user } // màj UI sur le main actor
} catch is CancellationError { /* ignoré */ }
catch { handle(error) }
}
}
Isoler le main actor : annoter les ViewModels avec @MainActor pour éviter les data races sur les propriétés UI.
@MainActor
@Observable
final class FeedViewModel { ... }
Données sensibles (tokens, mdp) → Keychain
Préférences légères → UserDefaults / @AppStorage
Modèle relationnel, migrations → Core Data (NSPersistentCloudKitContainer pour iCloud)
Nouveau projet iOS 17+ → SwiftData (@Model, .modelContainer)
Sync multi-appareils → CloudKit ou Firebase Firestore
// SwiftData (iOS 17+)
@Model
final class TodoItem {
var title: String
var isDone: Bool
init(title: String) { self.title = title; self.isDone = false }
}
// Dans App
@main
struct MyApp: App {
var body: some Scene {
WindowGroup { ContentView() }
.modelContainer(for: TodoItem.self)
}
}
// XCTest async
func testFetchProfile() async throws {
let sut = ProfileViewModel(repository: MockRepository())
await sut.fetchProfile(id: "1")
XCTAssertEqual(sut.username, "Alice")
}
// Protocol pour le mock
protocol ProfileRepository {
func fetch(_ id: String) async -> Profile
}
struct MockRepository: ProfileRepository {
func fetch(_ id: String) async -> Profile { Profile(name: "Alice") }
}
swift-snapshot-testing (Point-Free) pour régressions visuelles.XCUIApplication, utiliser les accessibilityIdentifier comme sélecteurs stables.// Keychain (wrapper simplifié)
func saveToken(_ token: String) {
let data = Data(token.utf8)
let query: [CFString: Any] = [
kSecClass: kSecClassGenericPassword,
kSecAttrAccount: "authToken",
kSecValueData: data,
kSecAttrAccessible: kSecAttrAccessibleWhenUnlockedThisDeviceOnly
]
SecItemDelete(query as CFDictionary)
SecItemAdd(query as CFDictionary, nil)
}
// Biométrie (Face ID / Touch ID)
let context = LAContext()
context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics,
localizedReason: "Confirmer votre identité") { ok, _ in
DispatchQueue.main.async { if ok { openSecureContent() } }
}
NSAllowsArbitraryLoads) exige une justification App Review.URLAuthenticationChallenge ou la lib TrustKit.NSUsageDescription dans Info.plist (caméra, micro, localisation…).| Piège | Conséquence | Remède |
|---|---|---|
URLSession sur le main thread | UI gelée | async/await ou .background queue |
Capture self forte dans closure @escaping | Fuite mémoire | [weak self] systématique |
@ObservedObject sur un objet créé dans la View | Re-init à chaque rebuild | Passer via @StateObject ou @Observable @State |
Core Data sans NSManagedObjectContext per-thread | Crash aléatoire | performAndWait ou @ModelActor (SwiftData) |
UserDefaults pour tokens/mdp | Faille sécurité (lisible) | Keychain uniquement |
Lancer Task { } sans annulation | Tasks zombies | Stocker dans @State var task: Task<…>? et .cancel() dans onDisappear |
GeometryReader enveloppant tout | Layout cassé, rebuild excessif | Limiter au besoin précis, préférer containerRelativeFrame (iOS 17) |
SWIFT_STRICT_CONCURRENCY = complete) : activer tôt, corriger les data races à la compilation.#Preview { ... } (nouveau DSL) plutôt que PreviewProvider.@Test, #expect, remplace XCTest pour les nouveaux tests.String(localized:) et le catalogue .xcstrings (Xcode 15) plutôt que NSLocalizedString..accessibilityLabel, .accessibilityHint, tester avec VoiceOver simulator dès le début.deinit des ViewModels.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
ios-development, swiftui, uikit, xcode, architecture, concurrency
/claude-skills-collection:dev-ios-swift-advisorfrom claude-skills-collection
npx claudepluginhub vantaflow/claude-skills-collection --plugin claude-skills-collection348 skills in this plugin
/agent-a2a-protocol-guideGuide du protocole Agent-to-Agent (A2A) de Google pour l'interopérabilité entre agents IA — découverte, communication et collaboration inter-agents, avec exemples de code, critères de décision et pièges à éviter. Se déclenche avec "A2A", "agent-to-agent", "protocole A2A", "Google A2A", "interopérabilité agents". Also triggers on "agent-to-agent protocol", "agent interoperability", "connect two agents"./agent-agent-observabilityInstrumentation technique d'un agent IA — tracing distribué des appels LLM et outils, spans, métriques custom, corrélation de logs et dashboards de supervision. Pour les alertes et garde-fous de production, voir agent-monitoring-setup. Se déclenche avec "observabilité agent", "tracing agent", "LangSmith", "Langfuse", "OpenTelemetry agent", "spans LLM", "corréler les logs agent". Also triggers on "trace my agent", "LLM tracing", "agent spans"./agent-api-caller-subagentSous-agent spécialisé dans les appels API REST/GraphQL avec retry, auth et transformation de données. Se déclenche avec "sous-agent API", "API caller agent", "agent qui appelle une API", "REST agent", "HTTP agent", "API integration subagent", "external API agent". Also triggers on "subagent that calls an API", "API calling agent", "agent HTTP requests".Other plugins' skills for the same job