/uikit-specialist:uikit-specialist-slimfrom uikit-specialist
Covers common mistakes and iOS 18+ API changes when building UIKit screens, especially chat/feed lists with UICollectionView, diffable data sources, scroll position, self-sizing cells, trait changes, edit menus, and main-actor rules.
Ships in uikit-specialist. 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.
You already know UIKit. This skill holds only the things that go wrong or have changed. Target iOS 18 unless the project says otherwise; guard newer APIs with if #available. Match the project's architecture; do not migrate working code unless it is the bug.
| Do not write | Write |
|---|---|
traitCollectionDidChange(_:) (deprecated iOS 17) | registerForTraitChanges([UITraitPreferredContentSizeCategory.self]) { (self: Self, previous: UITraitCollection) in ... }. The closure gets self, so no [weak self]. |
| Caching a trait in a property | On iOS 18, traits read inside layoutSubviews(), updateConstraints(), draw(_:), viewWillLayoutSubviews(), updateConfiguration(using:), configurationUpdateHandler and a compositional section provider are tracked: UIKit re-runs the method when the trait changes. Read them there. |
setOverrideTraitCollection(_:forChild:) | traitOverrides |
UIMenuController | UIEditMenuInteraction (custom views) or UITextViewDelegate textView(_:editMenuForTextIn:suggestedActions:) |
| Only the single-range edit menu method | iOS 26 adds textView(_:editMenuForTextInRanges:suggestedActions:) for multi-range selections. Implement both when building with the iOS 26 SDK. |
UITableViewCell.textLabel, detailTextLabel, imageView (deprecated in the iOS 27 SDK) | defaultContentConfiguration(), then assign to contentConfiguration |
UIScreen.main, UIApplication.shared.windows, keyWindow | view.window?.windowScene, traitCollection.displayScale, container size |
| Keyboard notifications plus frame math | view.keyboardLayoutGuide |
contentEdgeInsets, titleEdgeInsets, imageEdgeInsets | UIButton.Configuration |
UIGraphicsBeginImageContextWithOptions | UIGraphicsImageRenderer |
UIActivityIndicatorView as an empty or loading screen | contentUnavailableConfiguration (.loading(), .empty(), .search()); set it in updateContentUnavailableConfiguration(using:) |
| Link taps through the old URL delegate methods | textView(_:primaryActionFor:defaultAction:) and textView(_:menuConfigurationFor:defaultMenu:) (iOS 17) |
viewDidLoad for first scroll or bounds | viewIsAppearing(_:); bounds are not final in viewDidLoad |
| Observation in UIKit | iOS 26: @Observable properties read in layoutSubviews(), updateProperties(), updateConfiguration(using:) are tracked (on iOS 18 only with the UIObservationTrackingEnabled Info.plist key). On iOS 18 keep an explicit update path. |
UIUpdateLink | iOS 18 replacement for CADisplayLink for per-frame work tied to the display |
| Zoom transition by hand | iOS 18: preferredTransition = .zoom(sourceViewProvider:); return the current cell, since cells are reused |
| Opaque backgrounds behind bars | iOS 26 Liquid Glass restyles standard bars and controls; leave them transparent and use system colors and SF Symbols |
uniformAcrossSiblings(estimate:) | iOS 17: group height shared by the tallest item in a row |
UILabel cannot be selected. For selectable message text use a non-editable UITextView; selection fails silently if any of these is missing:
let textView = UITextView()
textView.isEditable = false
textView.isSelectable = true // the default, but set it
textView.isScrollEnabled = false // sizes like a label; needed in self-sizing cells
textView.textContainerInset = .zero
textView.textContainer.lineFragmentPadding = 0
textView.backgroundColor = .clear
textView.adjustsFontForContentSizeCategory = true
textView.font = .preferredFont(forTextStyle: .body)
UIContextMenuInteraction on the whole cell also uses long press, so it competes with selecting a word. Decide which wins: put the menu on the cell and add a "Select Text" action, or attach the menu outside the text area. Verify by long-pressing text on a device: the simulator hides this.isUserInteractionEnabled = false on the text view or on contentView ancestors.UIPasteboard.general is enough and cheaper.delegate set for the edit menu methods above.Never "add the content size delta to the offset": with estimated cell sizes the content size keeps changing. Anchor on a visible item instead, in one main-actor turn with no animation:
@MainActor
func prepend(_ olderIDs: [ItemID]) async {
let visibleTop = collectionView.contentOffset.y + collectionView.adjustedContentInset.top
let anchor = collectionView.indexPathsForVisibleItems.sorted().lazy
.compactMap { ip -> (ItemID, CGFloat)? in
guard let a = self.collectionView.layoutAttributesForItem(at: ip),
a.frame.minY >= visibleTop,
let id = self.dataSource.itemIdentifier(for: ip) else { return nil }
return (id, a.frame.minY - visibleTop)
}.first
var snapshot = dataSource.snapshot()
if let first = snapshot.itemIdentifiers.first {
snapshot.insertItems(olderIDs, beforeItem: first)
} else {
snapshot.appendItems(olderIDs)
}
await dataSource.apply(snapshot, animatingDifferences: false)
guard let (id, distance) = anchor, let ip = dataSource.indexPath(for: id) else { return }
collectionView.layoutIfNeeded()
guard let a = collectionView.layoutAttributesForItem(at: ip) else { return }
collectionView.setContentOffset(
CGPoint(x: 0, y: a.frame.minY - distance - collectionView.adjustedContentInset.top),
animated: false)
}
setContentOffset stops a drag or deceleration in progress: wait until the scroll ends before prepending.viewWillTransition(to:with:)), a Dynamic Type change, and relaunch. Save an item identifier plus its distance from the top, never a raw contentOffset.Keep natural order; never flip the list with a transform (it breaks accessibility, menus and scroll indicators). Read "pinned" before the update, because the content size has already changed after it:
var isPinnedToBottom: Bool {
let bottom = collectionView.contentOffset.y + collectionView.bounds.height
- collectionView.adjustedContentInset.bottom
return bottom >= collectionView.contentSize.height - 24
}
await apply, then scrollToItem(at:at:.bottom, animated:) only if it was pinned. Not pinned: show a "new messages" button.layoutIfNeeded(), scroll to the last item without animation, in viewIsAppearing(_:).scrollToItem with estimated sizes lands off target. For an exact jump: scroll without animation, layoutIfNeeded(), scroll to the same item again.scrollToItem in the same turn as an animated apply; await the apply first..estimated; constraints pinned to all four edges of contentView; no fixed height on text.invalidateIntrinsicContentSize() in the cell. This only works with collectionView.selfSizingInvalidation at .enabled (default since iOS 16), or .enabledIncludingConstraints when constraint changes should also resize it. Otherwise reconfigure the item. Re-pin to the bottom afterwards if the list was pinned.systemLayoutSizeFitting.Hashable and Sendable (an ID, not the model). Look the model up when configuring the cell. Duplicate identifiers crash.snapshot.reconfigureItems(ids). It reuses the visible cell and keeps its state. reloadItems replaces the cell (selection, selected text and in-flight animations are lost) and is for when the cell type changes. Never delete and reinsert to refresh.performBatchUpdates with a diffable data source, and never call reloadData() for a small change.CellRegistration objects once, not inside the cell provider.byPreparingThumbnail(ofSize:)), cache, and check the cell still shows the same item before assigning. Reset cell state in prepareForReuse() or the registration handler.UIFont.preferredFont(forTextStyle:) or UIFontMetrics.scaledFont(for:), plus adjustsFontForContentSizeCategory = true. Attributed strings do not always update live: rebuild them in a trait registration for UITraitPreferredContentSizeCategory.preferredContentSizeCategory.isAccessibilityCategory) switch horizontal rows to vertical stacks. Test at the largest size.CGColor does not follow dark mode: set layer.borderColor and shadowColor with color.resolvedColor(with: traitCollection).cgColor inside a trait-tracked method.@MainActor. A Task {} created in a view controller inherits the main actor, and a plain async method on a main-actor class also runs on main. async does not mean background. Move CPU work into an actor, a nonisolated type, or a @concurrent function (Swift 6.2; check the project's Default Actor Isolation setting first).Task, cancel it in viewDidDisappear or deinit, check Task.isCancelled after each await that precedes UI work. Use [weak self] for tasks that outlive the screen (network, streams).Sendable values across actors (IDs, structs, Data, UIImage); never views or mutable model classes.AsyncSequence streams in a stored task and apply UI changes in batches.Data(contentsOf:), DispatchQueue.main.sync, semaphores, Thread.sleep. Timers on the default run loop mode stop while scrolling: use .common or Task.sleep(for:).layoutSubviews() (can loop). Do not call layoutIfNeeded() in loops.masksToBounds on scrolling cells needs a shadowPath.UIHostingConfiguration or any SwiftUI to fix a UIKit layout problem.layoutSubviews or scrollViewDidScroll.accessibilityLabel.git grep -l 'import SwiftUI' finds nothing, unless the project mixes them on purpose.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
uikit, ios-18, uicollectionview, diffable-datasource, trait-changes, edit-menu
npx claudepluginhub notolivaresf/uikit-skill --plugin uikit-specialist7 skills in this plugin
/uikit-chat-listBuild or fix a long chat or feed list in a UIKit app (iOS 18 and later, Swift or Objective-C) - live messages pinned to the bottom, older messages loading above without the view moving, jumping to a message, Dynamic Type and rotation without losing the reader's place, selectable text with your own edit menu actions. Use for UICollectionView or UITableView screens that grow at both ends (chat rooms, comment threads, logs, timelines) and when such a list stutters, jumps, drifts or loses its pin./uikit-listBuild or fix a long, fast-scrolling list screen in a UIKit app (iOS 18 and later, Swift or Objective-C) - feeds, inboxes, catalogs, logs, timelines, comment threads, chats. Live items arriving, older or newer pages loading without the view moving, jumping to an item, variable row heights, Dynamic Type and rotation without losing the reader's place, selectable text with your own edit menu actions. Use for UICollectionView or UITableView screens that grow at one or both ends, and when such a list stutters, jumps, drifts or loses its position./uikit-specialistBest practices and performance for UIKit apps on iOS 18 and later. Use whenever writing, reviewing, refactoring or debugging UIKit code - UIViewController, UIView, UICollectionView, UITableView, compositional layout, diffable data sources, cell registrations, content and background configurations, self-sizing cells, scroll position and prepending, image loading and prefetching, Auto Layout, safe area, keyboardLayoutGuide, size classes and resizable windows, UINavigationController, UITabBarController and UITab, UISplitViewController, sheets, zoom transitions, scenes and windows, traits and custom traits, Observation and updateProperties, Dynamic Type, UITextView and TextKit 2, edit menus, context menus, swipe actions, drag and drop, keyboard shortcuts, animations and springs, Liquid Glass, accessibility, localization, Swift concurrency in UIKit, hitches and Instruments, and replacing deprecated UIKit APIs./uikit-specialist-objcBest practices and performance for Objective-C UIKit apps on iOS 18 and later. Use whenever writing, reviewing, refactoring or debugging Objective-C UIKit code in .m and .h files - UIViewController, UIView, UICollectionView, UITableView, compositional layout, NSDiffableDataSourceSnapshot and diffable data sources, UICollectionViewCellRegistration, content and background configurations, self-sizing cells, scroll position and prepending, image loading and prefetching, Auto Layout, safe area, keyboardLayoutGuide, size classes and resizable windows, UINavigationController, UITabBarController and UITab, UISplitViewController, sheets, zoom transitions, scenes and windows, traits and custom traits, updateProperties, Dynamic Type, UITextView and TextKit 2, edit menus, context menus, swipe actions, drag and drop, keyboard shortcuts, animations and springs, Liquid Glass, accessibility, localization, blocks and retain cycles with weak and strong self, GCD and main-thread rules, nullability and lightweight generics, hitches and Instruments, and replacing deprecated UIKit APIs./uikit-whats-new-27What is new, changed or deprecated in UIKit in the iOS 27 SDK (iOS 27.0 and 27.1). Use when building with Xcode 27 or the iOS 27 SDK, raising a deployment target to iOS 27, fixing new warnings or launch failures after an SDK update, or asked about iOS 27 UIKit - the required scene life cycle, the required launch screen, state restoration on foreground, resizable iPhone apps in iPhone Mirroring and on iPad, UIScreen.main and displayScale, effectiveGeometry, user interface idiom and orientation checks, UIRequiresFullScreen discrete resizing, presented view controller traits, tab bar prominentTabIdentifier, iPhone sidebars with sidebar.preferredPlacement and isAvailable, navigationBarMinimization, scroll edge effect changes, centered search scope bars, menu image visibility with preferredImageVisibility, Ask Siri and drag sessions without a gesture, allowsPointerDragBeforeLiftDelay, scene accessories with registerSceneAccessory, external display content, TextKit viewport rendering surfaces, text tables, attachment view reuse, observation in section providers, the UIView motion and heading body, Mac Catalyst refresh controls and steppers, canOpenURL deprecation, and the iOS 27.1 foldable APIs - UIArrangementViewController, split and overlay arrangements, UIHingeInteraction, reserved regions and vertical bars./uikit-whats-new-27-objcWhat is new, changed or deprecated in UIKit in the iOS 27 SDK (iOS 27.0 and 27.1), from Objective-C. Use when building Objective-C (.m and .h) code with Xcode 27 or the iOS 27 SDK, raising a deployment target to iOS 27, fixing new warnings or launch failures after an SDK update, or asked about iOS 27 UIKit in Objective-C - the required scene life cycle, the required launch screen, state restoration on foreground, resizable iPhone apps in iPhone Mirroring and on iPad, +[UIScreen mainScreen] and displayScale, effectiveGeometry, user interface idiom and orientation checks, UIRequiresFullScreen discrete resizing, presented view controller traits, tab bar prominentTabIdentifier, iPhone sidebars with sidebar.preferredPlacement and isAvailable, navigationBarMinimization (Swift only), scroll edge effect changes, centered search scope bars, menu image visibility with preferredImageVisibility, Ask Siri and drag sessions without a gesture, allowsPointerDragBeforeLiftDelay, scene accessories with registerSceneAccessory:, external display content, TextKit viewport rendering surfaces, text tables, attachment view reuse, observation in section providers (Swift only), the UIView motion and heading body, Mac Catalyst refresh controls and steppers, canOpenURL: deprecation, and the iOS 27.1 foldable APIs - UIArrangementViewController (mostly Swift only), UIHingeInteraction, reserved regions (Swift only) and vertical bars.Other plugins' skills for the same job