Skip to content

Commit 4300d01

Browse files
committed
Fixed CGImages build error with watchOS
1 parent 9a5df1b commit 4300d01

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Sources/GoogleAI/PartsRepresentable+Image.swift

+8-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ import UniformTypeIdentifiers
1919
import AppKit // For NSImage extensions.
2020
#endif
2121

22+
#if os(watchOS)
23+
import ImageIO
24+
import CoreGraphics
25+
#endif
26+
2227
private let imageCompressionQuality: CGFloat = 0.8
2328

2429
/// An enum describing failures that can occur when converting image types to model content data.
@@ -38,7 +43,7 @@ public enum ImageConversionError: Error {
3843

3944
#if canImport(UIKit)
4045
/// Enables images to be representable as ``ThrowingPartsRepresentable``.
41-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
46+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 8.0, *)
4247
extension UIImage: ThrowingPartsRepresentable {
4348
public func tryPartsValue() throws -> [ModelContent.Part] {
4449
guard let data = jpegData(compressionQuality: imageCompressionQuality) else {
@@ -50,7 +55,7 @@ public enum ImageConversionError: Error {
5055

5156
#elseif canImport(AppKit)
5257
/// Enables images to be representable as ``ThrowingPartsRepresentable``.
53-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
58+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 8.0, *)
5459
extension NSImage: ThrowingPartsRepresentable {
5560
public func tryPartsValue() throws -> [ModelContent.Part] {
5661
guard let cgImage = cgImage(forProposedRect: nil, context: nil, hints: nil) else {
@@ -67,7 +72,7 @@ public enum ImageConversionError: Error {
6772
#endif
6873

6974
/// Enables `CGImages` to be representable as model content.
70-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
75+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 9.0, *)
7176
extension CGImage: ThrowingPartsRepresentable {
7277
public func tryPartsValue() throws -> [ModelContent.Part] {
7378
let output = NSMutableData()

0 commit comments

Comments
 (0)