nuke-migrate
它能做什么
这项技能指导把使用 Nuke 图片加载库的 Apple 应用升级到 14 版本。适合升级后遇到编译错误,或需要更新该库的开发者。
适用场景
- ✓当你在 Apple 应用中提升 Nuke 图片库版本的时候。
- ✓当 Nuke 升级后编译失败,需要替换步骤的时候。
- ✓当你想从应用中移除 NukeExtensions 或旧的 Combine 代码时。
技能链接
https://github.com/kean/Nuke/blob/main/skills/nuke-migrate/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请把我的 iPhone 应用从 Nuke 13 升级到 Nuke 14,并检查那些能编译但已经无法正常工作的代码。”
每周 5 个新技能,1 分钟读完。
工作原理
它检查应用的版本和平台目标,列出编译器不会标记的风险代码,然后逐步更新每一处。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Migrating to Nuke 14
The compiler finds most of this migration, and its errors name the replacements. What it can't find is the dangerous part: code that keeps compiling and stops working. A green build doesn't mean the migration is done. Follow the steps in order.
1. Check that the app can move
grep -A6 '"identity" : "nuke"' Package.resolved *.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
grep -rnE 'IPHONEOS_DEPLOYMENT_TARGET|\.iOS\(' --include='*.pbxproj' --include='Package.swift' .
git ls-remote --tags https://github.com/kean/Nuke 'refs/tags/14.*'
If there's no Package.resolved, read the version from Package.swift. Nuke 14 needs iOS 16, tvOS 16, macOS 13, watchOS 9, or visionOS 1, and Xcode 26.0 with Swift 6.2. If the app deploys to something lower, stop and ask. The choice is between raising the target and staying on 13.x, which still gets fixes, and it isn't yours to make.
If the app is on 12.x or earlier, read From Nuke 12 or earlier as well.
2. List what the compiler won't report
Do this before you touch the dependency, and keep the list. Every hit gets resolved in step 5, whatever the build says.
# Every conformance to the pipeline delegate
grep -rnE 'ImagePipeline\.Delegate|ImagePipelineDelegate' --include='*.swift' .
# `nil` passed to a LazyImage modifier, and modifiers that take an optional
grep -rnE '\.(processors|priority)\(' --include='*.swift' .
# Error text that reaches people, and errors matched by type in NukeUI callbacks
grep -rn 'localizedDescription' --include='*.swift' .
grep -rnE 'onCompletion|onFailure|\.result|state\.error' --include='*.swift' .
# Views that start playing animations, and repeated loads that used to restart the task
grep -rnE 'LazyImage\(|LazyImageView|FetchImage|onStart' --include='*.swift' .
# Anything that plays, parses, or inspects the encoded data of an image
grep -rnE 'container\.data|imageContainer\?*\.data|\.type == \.gif|Gifu|FLAnimatedImage|SwiftyGif|SDAnimatedImage|makeImageView' --include='*.swift' .
# Queues and prefetchers set by hand, and decoders of your own
grep -rnE 'maxConcurrentRequestCount|ImageDecoding\b|isAsynchronous' --include='*.swift' .
The search can't see through a typealias, or a signature split over lines. Open each file and read it.
3. Update the dependency
from: "14.0.0" doesn't match a prerelease. If the tags from step 1 only have betas, pin one:
.package(url: "https://github.com/kean/Nuke", exact: "14.0.0-beta.1")
In an Xcode project, change the version rule of the package, and remove the Package.resolved entry if it won't update. The product names are the same.
4. Fix what the compiler reports
Widely used removed APIs have a stub, and the compiler error says what to do: follow it. @available(*, unavailable) stubs can't cover a removed enum case or a property of a removed type, and those are in this table.
| Nuke 13 | Nuke 14 |
|---|---|
Nuke_ImageDisplaying, nuke_display(image:data:) |
ImageDisplaying, nuke_display(_ container: ImageContainer?) |
ImagePipelineDelegate |
ImagePipeline.Delegate |
imageId, .imageIdKey |
imageID |
.scaleKey, .thumbnailKey |
request.scale, request.thumbnail |
A userInfo dictionary with those keys |
A var request with the properties set. It no longer needs userInfo |
maximumDecodedImageSize |
ImageRequest.ThumbnailOptions, per request |
ImageRequest(url:, userInfo:) |
request.userInfo = … on a var |
imagePublisher(with:) |
image(for:), or imageTask(with:) and task.previews |
FetchImage.load(publisher) |
load { try await … } |
case .started in a delegate |
imageTaskDidStart(_:pipeline:) |
Float(displayScale) for scale or maxPixelSize |
Remove the conversion, they're CGFloat |
@ObservedObject var progress: FetchImage.Progress |
let progress: ImageTask.Progress, or read state.progress in place |
state.error as? ImagePipeline.Error |
state.error, which is typed |
lazyImageView.imageTask = … |
Read-only. Call cancel() or reset() |
dataCache.flush(for: key) |
await dataCache.flush(), which writes everything |
dataCache.queue |
Removed. Use await dataCache.flush() to wait for writes |
dataCache.flush(), dataCache.sweep() |
await them, so the caller becomes async, and so do its callers |
[String: Any] for coreImageFilter(name:parameters:identifier:) |
`[Stri |
常见问题
编译通过就代表升级完成了吗?
不代表。这项技能说明编译通过并不能证明迁移已经完成。
Nuke 14 需要哪些平台版本?
这项技能列出 iOS 16、tvOS 16、macOS 13、watchOS 9 或 visionOS 1,并需要 Xcode 26。
如果我的应用使用的是较旧的版本呢?
这项技能为从 Nuke 12 或更早版本升级提供了单独的一节。
详情
作者的原始描述
Upgrade an app to Nuke 14 from Nuke 13 or earlier. Use when bumping the Nuke, NukeUI, or NukeExtensions dependency, when a Nuke upgrade doesn't compile, or when asked to replace NukeExtensions, Combine publishers, or a hand-written GIF view with current Nuke APIs. Finds what the compiler can't report, such as pipeline delegate methods that compile and are never called.
repo: kean/Nuke
热度
- GitHub 星标
- 8.7k
- 排名
- #12332
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …