ios-staff-engineer/SKILL.md
Advanced iOS development and staff engineer expertise. Covers Swift 6 concurrency, iOS 26 Liquid Glass, FoundationModels (on-device AI), SwiftData inheritance, Charts 3D, AppIntents, AlarmKit, architecture patterns, and technical leadership. Use for advanced iOS concepts, architecture decisions, code quality, Swift 6 migration, performance optimization, or preparing for senior/staff roles.
npx skillsauth add abanoub-ashraf/manus-skills-import ios-staff-engineerInstall 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.
// if case let - match single enum case without verbose switch
if case let .success(value) = result {
process(value)
}
// @unknown default - compiler warns on future enum cases
switch state {
case .loading: showSpinner()
case .loaded: showContent()
@unknown default: showFallback()
}
switch temperature {
case ..<0: return "freezing"
case 0..<20: return "cold"
case 20...: return "warm"
}
// Overload ~= operator for custom matching
func ~= (pattern: ClosedRange<Int>, value: StatusCode) -> Bool {
pattern.contains(value.code)
}
switch response.status {
case 200...299: handleSuccess()
case 400...499: handleClientError()
case 500...599: handleServerError()
default: handleUnknown()
}
// Switch on multiple values simultaneously
switch (isLoggedIn, hasSubscription) {
case (true, true): showPremiumContent()
case (true, false): showUpsell()
case (false, _): showLogin()
}
// Multiple optional values
switch (name, age) {
case let (name?, age?): print("\(name), \(age)")
case let (name?, nil): print("\(name), age unknown")
case (nil, _): print("Anonymous")
}
// Before: if let value = value
if let value { process(value) }
// Modify unwrapped value directly with var
if var count = optionalCount {
count += 1
save(count)
}
let displayName = user.name.map { "Hello, \($0)" } ?? "Hello, Guest"
// Get value and set to nil atomically
if let pending = pendingRequest.take() {
execute(pending)
}
// Only iterate non-nil elements
for case let item? in optionalItems {
process(item)
}
func log(_ items: Any..., separator: String = " ") {
print(items.map { "\($0)" }.joined(separator: separator))
}
struct Permissions: OptionSet {
let rawValue: Int
static let read = Permissions(rawValue: 1 << 0)
static let write = Permissions(rawValue: 1 << 1)
static let execute = Permissions(rawValue: 1 << 2)
static let all: Permissions = [.read, .write, .execute]
}
func assert(_ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String) {
guard condition() else {
fatalError(message()) // message only evaluated on failure
}
}
func fatalError(_ message: String) -> Never {
print(message)
abort()
}
// Simplify generic signatures with some
func makeCollection() -> some Collection<Int> {
[1, 2, 3]
}
let names = users.map(\.name)
let adults = users.filter(\.isAdult)
let sorted = users.sorted(by: \.age)
struct User: CustomStringConvertible, CustomDebugStringConvertible {
let id: Int, name: String
var description: String { name }
var debugDescription: String { "User(id: \(id), name: \(name))" }
}
struct Email: ExpressibleByStringLiteral {
let value: String
init(stringLiteral value: String) { self.value = value }
}
let email: Email = "[email protected]"
struct Validator {
let pattern: String
func callAsFunction(_ input: String) -> Bool {
input.range(of: pattern, options: .regularExpression) != nil
}
}
let isEmail = Validator(pattern: "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}")
if isEmail("[email protected]") { print("Valid") }
final class Storage<T> { var value: T; init(_ v: T) { value = v } }
struct COWWrapper<T> {
private var storage: Storage<T>
var value: T {
get { storage.value }
set {
if !isKnownUniquelyReferenced(&storage) {
storage = Storage(newValue)
} else {
storage.value = newValue
}
}
}
}
struct FileHandle: ~Copyable {
private let fd: Int32
consuming func close() {
Darwin.close(fd)
discard self // Suppress automatic cleanup
}
deinit { Darwin.close(fd) }
}
indirect enum Expression {
case number(Int)
case addition(Expression, Expression)
case multiplication(Expression, Expression)
}
class ViewController {
lazy var heavyResource: Resource = {
let r = Resource()
r.configure()
return r
}()
}
class Counter {
var value: Int { didSet { print("Changed to \(value)") } }
init(value: Int) {
self.value = value
defer { self.value = value } // Triggers didSet
}
}
var data: Data {
get async throws {
try await networkService.fetch()
}
}
@propertyWrapper
struct Clamped<T: Comparable> {
private var value: T
let range: ClosedRange<T>
var wrappedValue: T {
get { value }
set { value = min(max(newValue, range.lowerBound), range.upperBound) }
}
init(wrappedValue: T, _ range: ClosedRange<T>) {
self.range = range
self.value = min(max(wrappedValue, range.lowerBound), range.upperBound)
}
}
struct Settings {
@Clamped(0...100) var volume: Int = 50
}
// Compiler tracks which region values belong to
actor Database {
var cache: [String: Data] = [:]
func get(_ key: String) -> Data? {
cache[key] // Safe: accessing actor-isolated state
}
}
// Explicitly mark values that cross isolation boundaries
func process(_ data: sending Data) async {
await worker.handle(data)
}
@MainActor
class ViewModel: ObservableObject {
@Published var items: [Item] = []
func refresh() async {
let newItems = await api.fetchItems()
items = newItems // Safe: already on MainActor
}
}
// Value types are implicitly Sendable if all properties are Sendable
struct UserData: Sendable {
let id: UUID
let name: String
}
// Reference types require explicit marking
final class Config: Sendable {
let apiKey: String // Must be immutable
init(apiKey: String) { self.apiKey = apiKey }
}
// Environment container at app root
struct AppEnvironment {
let api: APIClient
let database: Database
let analytics: Analytics
static let live = AppEnvironment(
api: LiveAPIClient(),
database: SQLiteDatabase(),
analytics: FirebaseAnalytics()
)
static let mock = AppEnvironment(
api: MockAPIClient(),
database: InMemoryDatabase(),
analytics: NoOpAnalytics()
)
}
// Pass through initializers, not singletons
class ViewModel {
private let api: APIClient
init(api: APIClient) { self.api = api }
}
// Replace protocols with structs for flexibility
struct APIClient<Response> {
let fetch: (Request) async throws -> Response
}
extension APIClient where Response == User {
static let live = APIClient { request in
try await URLSession.shared.decode(User.self, from: request)
}
static let mock = APIClient { _ in
User(id: 1, name: "Test User")
}
}
@Observable
class Store<State, Action> {
private(set) var state: State
private let reducer: (inout State, Action) -> Effect<Action>
func send(_ action: Action) {
let effect = reducer(&state, action)
Task { await processEffect(effect) }
}
}
.background(.regularMaterial) // System glass
.glassEffect() // iOS 26 Liquid Glass
// Custom glass with tint
.background {
Glass()
.fill(.blue.opacity(0.1))
}
// Respond to glass region changes
@Environment(\.glassRegion) var glassRegion
var body: some View {
content
.padding(glassRegion.insets)
}
class NetworkManager {
func fetch(completion: @escaping (Result<Data, Error>) -> Void) {
task = session.dataTask(with: url) { [weak self] data, _, error in
guard let self else { return }
self.process(data, error, completion)
}
}
}
// reserveCapacity for known sizes
var items: [Item] = []
items.reserveCapacity(1000)
// Use ContiguousArray for better cache locality
var values = ContiguousArray<Int>()
// Lazy sequences for chained operations
let result = items
.lazy
.filter { $0.isValid }
.map { $0.transformed }
.prefix(10)
// Use Substring to avoid copies
let input = "Hello, World!"
let firstWord = input.prefix(while: { $0 != "," }) // Substring, no copy
// Convert to String only when needed for storage
let stored = String(firstWord)
// Mock at network boundary, not every dependency
class APIClientTests: XCTestCase {
func testFetchUser() async throws {
let mockSession = MockURLSession()
mockSession.data = userData
let client = APIClient(session: mockSession)
let user = try await client.fetchUser(id: 1)
XCTAssertEqual(user.name, "Test")
}
}
func testAsyncOperation() async throws {
let viewModel = ViewModel()
await viewModel.refresh()
// Use expectations for callbacks
let expectation = expectation(description: "completion")
viewModel.onComplete = { expectation.fulfill() }
await fulfillment(of: [expectation], timeout: 5)
}
Memory: Weak references in closures? Retain cycles avoided? Large allocations lazy?
Concurrency: MainActor for UI updates? Sendable conformance correct? Data races impossible?
Error Handling: All throws handled? User-facing errors localized? Recovery paths exist?
Performance: O(n²) operations flagged? Unnecessary copies avoided? Lazy evaluation where appropriate?
API Design: Clear naming? Progressive disclosure? Impossible states unrepresentable?
Deep Dive: See
references/ios26-new-frameworks.mdfor comprehensive coverage.
import FoundationModels
// Check availability
guard SystemLanguageModel.default.isAvailable else { return }
// Create session and generate
let session = LanguageModelSession()
let response = try await session.respond(to: "Explain Swift concurrency")
// Structured output with @Generable
@Generable
struct Summary {
@Guide("Main topic")
let topic: String
@Guide("Key points")
let points: [String]
}
let summary: Summary = try await session.respond(
to: "Summarize this article",
generating: Summary.self
)
// Tool calling
@Toolable
struct SearchTool {
func search(query: String) async -> [Result] { ... }
}
let session = LanguageModelSession(tools: [SearchTool()])
// Base model
@Model
class MediaItem {
var title: String
var rating: Double
}
// Subclasses
@Model
final class Movie: MediaItem {
var director: String
}
@Model
final class TVShow: MediaItem {
var seasons: Int
}
// Polymorphic queries
@Query var allMedia: [MediaItem] // Returns both Movies and TVShows
@Query var movies: [Movie] // Only Movies
// Type-based predicates
let descriptor = FetchDescriptor<MediaItem>(
predicate: #Predicate { $0 is Movie && $0.rating > 8.0 }
)
import Charts
// 3D Surface Plot
Chart3D {
SurfacePlot(data) { point in
PlotPoint3D(x: point.x, y: point.y, z: point.z)
}
.foregroundStyle(.blue.gradient)
}
.chart3DPose($pose) // Enable rotation gestures
// Mathematical surface
Chart3D {
SurfacePlot(x: -10...10, y: -10...10) { x, y in
sin(sqrt(x * x + y * y))
}
}
// Fixed-size stack-allocated array
var buffer: InlineArray<Int, 16> = .init(repeating: 0)
buffer[0] = 42
// Safe memory view without copying
array.withSpan { span in
for value in span { process(value) }
let slice = span[0..<10] // Zero-copy slice
}
import AlarmKit
let manager = AlarmManager()
await manager.requestAuthorization()
let alarm = AlarmPresentation(
title: "Workout",
scheduledTime: DateComponents(hour: 6, minute: 30),
repeatSchedule: .weekdays
)
try await manager.schedule(alarm)
import SwiftUI
struct BrowserView: View {
@State private var page = WebPage()
var body: some View {
VStack {
HStack {
Button("Back") { page.goBack() }
.disabled(!page.canGoBack)
if page.isLoading { ProgressView() }
}
WebView(page: page)
}
.onAppear { page.load(URL(string: "https://apple.com")!) }
}
}
// JavaScript execution
let title = try await page.evaluateJavaScript("document.title")
// Visual context queries
struct IdentifyItemIntent: AppIntent {
@Parameter var imageQuery: IntentValueQuery<ItemInfo>
func perform() async throws -> some IntentResult {
let item = try await imageQuery.value
return .result(value: item.description)
}
}
// Execution modes
static var executionMode: IntentExecutionMode = .background
static var executionMode: IntentExecutionMode { .foreground(.dynamic) }
// Computed properties
@ComputedProperty var total: Decimal { items.reduce(0) { $0 + $1.price } }
// Customizable toolbar with IDs
.toolbar(id: "editor") {
ToolbarItem(id: "bold") { Button("Bold") { } }
ToolbarSpacer(id: "spacer")
ToolbarItem(id: "color") { ColorPicker("Color", selection: $color) }
}
// Search behavior
.searchable(text: $query)
.searchToolbarBehavior(.minimize) // Collapse when not focused
var text = AttributedString("Styled Text")
text.textAlignment = .center
text.lineHeight = .multiplier(1.5)
// Selection-based editing
@State var selection = AttributedTextSelection()
TextEditor(text: $text, selection: $selection)
.toolbar {
Button("Bold") {
text.transformAttributes(in: selection.range) { $0.font = .bold }
}
}
@main
struct MyApp: App {
var body: some Scene {
WindowGroup { ContentView() }
AssistiveAccess { SimplifiedView() } // Simplified UI
}
}
// Adapt to mode
@Environment(\.assistiveAccessEnabled) var isAssistiveAccess
if isAssistiveAccess {
LargeSimplifiedUI()
}
// Mounting styles
.mountingStyle(.elevated) // Float above surfaces
.mountingStyle(.recessed) // Sit into surfaces
// Textures
.widgetTexture(.glass)
.widgetTexture(.paper)
// Level of detail
@Environment(\.levelOfDetail) var detail
switch detail {
case .full: FullView()
case .reduced: SimpleView()
}
development
Design principles for building polished, native-feeling SwiftUI apps and widgets. Use this skill when creating or modifying SwiftUI views, iOS widgets (WidgetKit), or any native Apple UI. Ensures proper spacing, typography, colors, and widget implementations that look and feel like quality apps rather than AI-generated slop.
data-ai
Design and implement SwiftUI views, components, and app architecture. Use when creating new SwiftUI views, implementing MVVM/TCA patterns, managing state with @Observable, @State, @Binding, or @Environment, designing navigation flows, or structuring iOS app architecture. Triggers on SwiftUI, view model, state management, navigation, coordinator pattern.
development
Implement, review, or improve SwiftUI animations and transitions. Use when adding implicit or explicit animations with withAnimation, configuring spring animations (.smooth, .snappy, .bouncy), building phase or keyframe animations with PhaseAnimator/KeyframeAnimator, creating hero transitions with matchedGeometryEffect or matchedTransitionSource, adding SF Symbol effects (bounce, pulse, variableColor, breathe, rotate, wiggle), implementing custom Transition or CustomAnimation types, or ensuring animations respect accessibilityReduceMotion.
testing
Audit SwiftUI views for accessibility (iOS + macOS) with patch-ready fixes