From 300b6715f960f26302df250fc53058292211d1a8 Mon Sep 17 00:00:00 2001 From: Okmin Date: Tue, 24 Feb 2026 14:39:25 +0900 Subject: [PATCH] fix(skills): improve code examples in iOS 26 skills - Add do-catch error handling to SwiftUI streaming example in foundation-models-on-device - Add Auto Layout constraints to UIKit glass effect example in liquid-glass-design - Promote build settings prerequisite from code comment to visible blockquote warning in swift-concurrency-6-2 --- skills/foundation-models-on-device/SKILL.md | 14 +++++++++++--- skills/liquid-glass-design/SKILL.md | 14 ++++++++++++++ skills/swift-concurrency-6-2/SKILL.md | 5 ++--- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/skills/foundation-models-on-device/SKILL.md b/skills/foundation-models-on-device/SKILL.md index 074598f0..2304ca0e 100644 --- a/skills/foundation-models-on-device/SKILL.md +++ b/skills/foundation-models-on-device/SKILL.md @@ -178,6 +178,7 @@ for try await partial in stream { ```swift @State private var partialResult: TripIdeas.PartiallyGenerated? +@State private var errorMessage: String? var body: some View { List { @@ -185,10 +186,17 @@ var body: some View { Text(idea) } } + .overlay { + if let errorMessage { Text(errorMessage).foregroundStyle(.red) } + } .task { - let stream = session.streamResponse(to: prompt, generating: TripIdeas.self) - for try await partial in stream { - partialResult = partial + do { + let stream = session.streamResponse(to: prompt, generating: TripIdeas.self) + for try await partial in stream { + partialResult = partial + } + } catch { + errorMessage = error.localizedDescription } } } diff --git a/skills/liquid-glass-design/SKILL.md b/skills/liquid-glass-design/SKILL.md index 03a49b40..60551c2a 100644 --- a/skills/liquid-glass-design/SKILL.md +++ b/skills/liquid-glass-design/SKILL.md @@ -138,13 +138,27 @@ glassEffect.tintColor = UIColor.systemBlue.withAlphaComponent(0.3) glassEffect.isInteractive = true let visualEffectView = UIVisualEffectView(effect: glassEffect) +visualEffectView.translatesAutoresizingMaskIntoConstraints = false visualEffectView.layer.cornerRadius = 20 visualEffectView.clipsToBounds = true +view.addSubview(visualEffectView) +NSLayoutConstraint.activate([ + visualEffectView.centerXAnchor.constraint(equalTo: view.centerXAnchor), + visualEffectView.centerYAnchor.constraint(equalTo: view.centerYAnchor), + visualEffectView.widthAnchor.constraint(equalToConstant: 200), + visualEffectView.heightAnchor.constraint(equalToConstant: 120) +]) + // Add content to contentView let label = UILabel() label.text = "Liquid Glass" +label.translatesAutoresizingMaskIntoConstraints = false visualEffectView.contentView.addSubview(label) +NSLayoutConstraint.activate([ + label.centerXAnchor.constraint(equalTo: visualEffectView.contentView.centerXAnchor), + label.centerYAnchor.constraint(equalTo: visualEffectView.contentView.centerYAnchor) +]) ``` ### UIGlassContainerEffect for Multiple Elements diff --git a/skills/swift-concurrency-6-2/SKILL.md b/skills/swift-concurrency-6-2/SKILL.md index 9fff71da..d9864cc4 100644 --- a/skills/swift-concurrency-6-2/SKILL.md +++ b/skills/swift-concurrency-6-2/SKILL.md @@ -136,10 +136,9 @@ This mode is opt-in and recommended for apps, scripts, and other executable targ When you need actual parallelism, explicitly offload with `@concurrent`: +> **Important:** This example requires Approachable Concurrency build settings — SE-0466 (MainActor default isolation) and SE-0461 (NonisolatedNonsendingByDefault). With these enabled, `extractSticker` stays on the caller's actor, making mutable state access safe. **Without these settings, this code has a data race** — the compiler will flag it. + ```swift -// Assumes Approachable Concurrency build settings are enabled: -// SE-0466 (MainActor default isolation) and SE-0461 (NonisolatedNonsendingByDefault). -// Safe mutation of cachedStickers via await depends on these compiler options. nonisolated final class PhotoProcessor { private var cachedStickers: [String: Sticker] = [:]