swiftship/internal/skills/data/ui/swift-conventions-ui/SKILL.md
Swift coding conventions: naming, access control, error handling, async/await. Use when implementing code following Swift conventions.
npx skillsauth add abdullah4ai/apple-developer-toolkit swift-conventionsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Only import from this list:
SwiftUIFoundationSwiftDataObservationOSLog (for logging)UIKit (only for required bridges or APIs without a SwiftUI equivalent)PhotosUI (only when the app requires photo picking)AVFoundation (only when the app requires audio/video)MapKit (only when the app requires maps)CoreLocation (only when the app requires location)Use modern APIs — avoid deprecated alternatives:
| Use This | Not This |
|----------|----------|
| foregroundStyle() | foregroundColor() |
| clipShape(.rect(cornerRadius:)) | .cornerRadius() |
| @Observable | ObservableObject |
| @State with @Observable | @StateObject |
| .onChange(of:) { new in } | .onChange(of:) { old, new in } (iOS 17+ form) |
| .task { await … } | .onAppear { Task { await … } } (use .task for async work) |
| .onAppear { } | (acceptable for synchronous setup like passing modelContext) |
| NavigationStack | NavigationView |
Swift 6 enables strict concurrency checking by default. All data races are compile-time errors.
Sendable.final and have only immutable (let) Sendable stored properties, OR be marked @unchecked Sendable with manual thread safety (mutex/lock).@Sendable — they cannot capture mutable local state.@Published or @Observable state MUST be annotated @MainActor.@MainActor.@MainActor, so @State var vm: SomeViewModel works if SomeViewModel is @MainActor.@MainActor on the class/actor declaration, not on individual methods — partial isolation causes confusing errors.nonisolated.Hashable.hash(into:), CustomStringConvertible.description) on @MainActor types must be nonisolated.nonisolated(unsafe) only as a last resort for legacy API bridging.@MainActor-isolated values directly into APIs that execute in @concurrent contexts.MainActor for state updates:
// WRONG: passing actor-isolated self.items into concurrent context
let result = await processor.process(items)
// RIGHT: snapshot first
let snapshot = items // Copy Sendable data
let result = await processor.process(snapshot)
await MainActor.run { self.items = result }
sending parameter keyword marks closure parameters that cross isolation boundaries — use it when writing APIs that accept callbacks from different isolation domains.static let for shared constants — static var is a mutable global and violates strict concurrency.actor or @MainActor-isolated type.AppIntent static properties (title, description) MUST be static let.await inside an actor.@preconcurrency import FrameworkName for frameworks not yet annotated for Sendable (e.g., some older Apple frameworks)..translationTask { session in ... } flows, do NOT call session.translate(...) inside @MainActor-isolated methods.@MainActor only for UI state updates.import statementSwiftUI in a model file that only needs FoundationSwiftUI and UIKit when needed for framework types or platform bridges, but must not declare Views/UIViewControllerstesting
Use for 3D games: racing, 3D sports, board games, marble maze, tower defense, bowling. SceneKit + SceneView architecture, 3D scene hierarchy, physics, game loop, primitives, materials, cameras, particles, audio.
documentation
Game UI patterns: SwiftUI HUD overlays on SpriteKit, menus (main/pause/game-over), virtual joystick/d-pad, score displays, health bars, tutorial onboarding.
tools
Download free game sprites/textures/3D models and generate procedural assets. Covers nw_download_asset tool, texture factories, sprite atlas organization, 3D model loading, and programmatic asset creation.
testing
Use for 2D games: arcade, puzzle, sports, ping pong, platformer, shooter, 2D racing. SpriteKit + SpriteView architecture, scene hierarchy, physics, game loop, audio, particles, game feel.