← 所有文章

ImageCreator 已弃用:iOS 27 中将失效的部分

苹果今天发布了一则弃用通知,需在今秋之前引起重视:ImageCreator 类——即 Image Playground 用于在无 UI 情况下以编程方式生成图像的 API——“正在被停用,将不再在 iOS 27、iPadOS 27、macOS 27 和 visionOS 27 及更高版本中工作。”1 这则通知对失效过程的描述异常具体。在 beta 系统版本期间,使用 ImageCreator 的代码仍能编译,但会出现 Xcode 警告,而应用”将无法在 TestFlight 构建中运行,并会引发运行时错误。”1 到正式系统版本发布时,代码将完全无法编译。1 一个在 iOS 18.4 中推出的 API,仅过了一个大版本便被移除,而解释其缘由的 WWDC 会议也一并给出了迁移路径。

Watch on Apple Developer ↗

弃用公告出现在会议 375 的 4:34 处。

摘要

  • 苹果正在停用 ImageCreator,即 Image Playground 框架中以编程方式生成图像的 API。它将在 iOS 27、iPadOS 27、macOS 27 和 visionOS 27 中停止工作。1 苹果的文档在五个平台上将其弃用标记为 27.0,其中包括 Mac Catalyst。2
  • 失效过程是分阶段的:beta 版本可带警告编译,但在 TestFlight 中会于运行时失败;正式版本则拒绝编译。1 苹果的指示是要在”正式版发布之前”完成迁移。1
  • 原因是架构层面的。Image Playground 的模型今年迁移到了 Private Cloud Compute,正如会议所言,”将模型迁移到 Private Cloud Compute 也意味着要重新思考这套 API。”3
  • 替代方案是系统 UI:SwiftUI 中的 imagePlaygroundSheet 修饰符,或面向 UIKit 和 AppKit 应用的 ImagePlaygroundViewController3 苹果给出的另一项替代建议直截了当:接入”您自行选择的另一种图像生成服务。”1
  • 新的 sheet 比旧版本能力更强:支持照片级真实风格、以概念/绘图/源图像作为种子、尺寸与风格配置,以及一种可选启用的 externalProvider 风格,能够呈现如 ChatGPT 这样的第三方提供方。3

苹果具体宣布了什么

6 月 11 日发布在苹果开发者新闻动态上的通知,给出了一条两阶段的时间线。1 在 beta 系统版本中,您的代码仍可继续编译,Xcode 开始发出警告,而调用 ImageCreator 的应用会在 TestFlight 构建中触发运行时错误。在正式系统版本中,引用该类的代码将不再编译,任何基于它构建的功能都会对用户停止工作。苹果的行动项明确了截止时间:要在”iOS 27、iPadOS 27、macOS 27 和 visionOS 27 正式版发布之前”更新您的实现。1

文档以 API 参考的形式讲述了同样的故事。ImageCreator 在 iOS 与 iPadOS 18.4、macOS 15.4 和 visionOS 2.4 中登场,如今每一个平台条目都带有 27.0 的弃用标记,并且 Mac Catalyst 也加入了新闻帖所列的四个平台之列。2 该类的摘要恰好描述了正在失去的东西:它”根据您指定的描述和风格信息以编程方式生成图像。”2 没有可替代的编程式方案。那些在不呈现 UI 的情况下无界面生成图像的应用,在框架中找不到直接的对应物。

对于已经弃用该类的开发者,通知给出了收尾结论:”无需采取进一步行动。”1

缘由:模型迁移到了 Private Cloud Compute

会议 375,”使用 Image Playground 创建高质量图像”,公开陈述了原因。Image Playground 今年围绕更强大的图像模型进行了重建,这些模型能生成”几乎任何风格的高质量图像,甚至包括照片级真实的图像”,而它们运行在 Private Cloud Compute——苹果的隐私保护云基础设施——之上,而非在设备端。3 随后会议把脉络串了起来:”将模型迁移到 Private Cloud Compute 也意味着要重新思考这套 API。ImageCreator,这个用于在您代码中直接生成图像的非 UI API,已被弃用。”3

经济账可以解释这一设计抉择。Image Playground 如今设有使用额度限制,”因为它依赖于强大的服务器模型”,而大多数 iCloud+ 订阅套餐都可获得更高的使用额度。3 系统会代表用户管理这些额度,会议也明确指出开发者永远无需构建与使用额度相关的 UI。3 一个应用可以循环调用的无界面 API,在这套模式里显得格格不入;而由用户驱动、系统呈现的 sheet 则不然。无论内部考量如何,最终交付的结果是:框架中的图像生成如今都要经由系统体验完成。

有一处副作用值得指明:ImageCreator 在设备端运行生成,而新体验则运行在 Private Cloud Compute 上,会议保证”您的数据绝不会被存储或共享,即便对苹果也是如此。”3 那些对图像生成有严格设备端要求的应用,正是框架不再服务的对象。

迁移:一个视图修饰符

对于 SwiftUI 应用,采用替代方案的工作量很小。会议的演示应用为一个按钮附加了 .imagePlaygroundSheet,并绑定到一个 @State 布尔值;当绑定翻转为 true 时,sheet 便会出现,完成闭包会收到指向所生成文件的 URL。3 该 URL 指向应用容器内的一个临时位置,因此会议提醒要在 session 结束前将其保存到别处。3 UIKit 和 AppKit 应用通过 ImagePlaygroundViewController 获得相同的体验:将概念与选项设为属性,并通过委托方法接收结果。3

sheet 在可编程性上失去的,部分在种子机制上得到了弥补。ImagePlaygroundConcept 把应用上下文带入 sheet:text 封装一段直接描述,extracted 接收较长的文本并让系统从中提取相关创意,drawing 则接受来自 PencilKit 的 PKDrawing 作为视觉建议。3 sourceImage 参数可用任意 SwiftUI Image 作为灵感为 sheet 注入种子。3 ImagePlaygroundOptionsImagePlaygroundStyle 负责配置其余部分:closest(to:) 尺寸请求会把任意 CGSize 映射到最接近的受支持分辨率与宽高比,生成风格则接收一个默认值外加一份允许列表——当列表只有一项时,便将选择器锁定为单一风格。3

两项较新的能力让这一取舍更具吸引力。externalProvider 风格是一个可选启用的入口,能呈现用户在”设置”中配置的任意第三方提供方(例如 ChatGPT);当不存在任何提供方时,系统会负责完成设置。3 而 emoji 风格会触发一个独立的完成回调,交还一个 NSAdaptiveImageGlyph,可像 emoji 一样内嵌在文本中。3

可用性处理依旧简单:supportsImageGeneration 环境值仅在设备具备相应能力、语言与地区受支持、且用户已启用图像生成时才返回 true,因此一个条件判断即可覆盖回退路径。3

受影响应用的抉择

通知给出了两种迁移选项,会议则提供了判断所需的材料。那些将图像生成作为面向用户的创意功能的应用,应当选择 sheet:新模型比 ImageCreator 所调用的更强,种子 API 能把应用上下文带入,而系统则免费承担了使用额度、风格选择器与人物个性化等工作。3 那些依赖无界面生成、在后台流程中无用户交互地产出图像的应用,在框架内没有可走的路径;对它们而言,苹果的第二个选项——接入”您自行选择的另一种图像生成服务”——才是诚实的答案。1

这次弃用也契合本周期的一种模式。苹果在 27.0 将 MXMetricManager 标记为弃用,就在同一周交付了替代的上报 API,相关内容见 MetricKit 在 iOS 27 中的状态上报。该平台正在替代方案落地一个周期之后修剪 API,而 beta 阶段就是迁移窗口。

常见问题

ImageCreator 究竟何时停止工作?

分阶段进行。1 在 iOS 27、iPadOS 27、macOS 27 和 visionOS 27 的 beta 期间,代码可带 Xcode 警告编译,但 TestFlight 构建会触发运行时错误。到今秋的正式版本发布时,代码将不再编译,相关功能也会对用户停止工作。苹果的文档在 iOS、iPadOS、macOS、Mac Catalyst 和 visionOS 上将其弃用标记为 27.0。2

苹果为何移除以编程方式生成图像的能力?

会议将其归因于架构变更:Image Playground 的模型迁移到了 Private Cloud Compute,而”将模型迁移到 Private Cloud Compute 也意味着要重新思考这套 API。”3 新系统会代表用户管理服务器模型的使用额度,并通过 iCloud+ 套餐提供更高额度——这种模式比无界面的 API 更契合由用户驱动的 sheet。3

由什么取而代之?

系统 UI:SwiftUI 中的 imagePlaygroundSheet 修饰符,或 UIKit 和 AppKit 中的 ImagePlaygroundViewController3 您可以用文本概念、提取出的文本、PencilKit 绘图和源图像为它注入种子,并配置尺寸、风格与个性化。至于无界面生成,苹果给出的替代方案是第三方图像生成服务。1

还有任何内容是在设备端生成的吗?

会议描述新的图像生成运行在 Private Cloud Compute 上,并保证数据”绝不会被存储或共享,即便对苹果也是如此。”3 那些严格要求在设备端生成图像的应用,在框架中已不再有对应的路径。


驱动此次变更的 Private Cloud Compute 转向,与正在重塑 Apple Intelligence 文本侧的转向如出一辙,相关内容见 Foundation Models 与 Private Cloud Compute。关于苹果本周期内连同替代方案一并交付的另一项弃用,见 MetricKit 在 iOS 27 中的状态上报。完整系列入口为 Apple 生态系统系列

参考资料


  1. Apple, Deprecation of the ImageCreator class, Apple Developer News, June 11, 2026. Source for the discontinuation (“the ImageCreator class is being discontinued and will no longer work in iOS 27, iPadOS 27, macOS 27, and visionOS 27 or later”), the staged timeline (beta releases: code compiles with Xcode warnings, apps “will not function in TestFlight builds and will cause a runtime error”; public releases: code won’t compile and features stop working), the instruction to update before the public release, the two migration options (the Image Playground sheet, or “another image generation service of your choice”), and the note that already-migrated apps need no further action. 

  2. Apple, ImageCreator documentation, Apple Developer Documentation. Source for the platform availability matrix (introduced in iOS 18.4, iPadOS 18.4, macOS 15.4, visionOS 2.4; deprecated at 27.0 on iOS, iPadOS, macOS, Mac Catalyst, and visionOS) and the class abstract (“Generates images programmatically from the description and style information you specify”). 

  3. Apple, WWDC 2026 session 375, Create high quality images using Image Playground. Official transcript. Source for the deprecation statement and rationale (“Moving the models to Private Cloud Compute also meant rethinking the API. ImageCreator, the non-UI API for generating images directly in your code, is deprecated”), the new model capabilities (“high quality images in virtually any style, even photorealistic ones”), Private Cloud Compute execution with the privacy assurance (“your data is never stored or shared, even with Apple”), the usage limits and iCloud+ access with system-managed limit UI, the imagePlaygroundSheet adoption flow (binding-driven presentation, completion URL in a temporary app-container location), ImagePlaygroundViewController for UIKit and AppKit with delegate-based results, ImagePlaygroundConcept seeding (text, extracted, drawing with PencilKit), the sourceImage parameter, ImagePlaygroundOptions with closest(to:) size mapping, style defaults and allowed lists including single-style locking, the opt-in externalProvider style with ChatGPT as the example and system-handled setup, the emoji style’s NSAdaptiveImageGlyph completion, and the supportsImageGeneration environment value covering capability, language and region, and the user setting. 

相关文章

Container machine:在 Mac 上运行持久化的 Linux 环境

Apple 的 container 工具迎来 1.0,带来 container machine:一个快速、持久的 macOS 上 Linux 环境,并挂载了您的用户、主目录和 dotfiles。

4 分钟阅读

iOS 27 中的 SwiftUI 性能与互操作

iOS 27 的 SwiftUI 如何处理惰性栈滚动、GPU 着色器效果以及 AppKit/UIKit 互操作,内容取自三场官方 WWDC26 UI Frameworks 讲座。

5 分钟阅读