From b59e4b2127e377edacd54d312f3944be75606927 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Mon, 18 Aug 2025 11:12:41 -0400 Subject: [PATCH 01/13] Promote Darwin image attachments to API. This PR promotes image attachments on Apple platforms to API (pending approval of ST-0014). --- .../NSImage+AttachableAsCGImage.swift | 11 +++++--- .../_Testing_AppKit/ReexportTesting.swift | 6 ++--- .../Attachments/AttachableAsCGImage.swift | 21 +++++++++++----- .../AttachableImageFormat+UTType.swift | 10 +++++++- .../Attachment+AttachableAsCGImage.swift | 19 +++++++++++--- .../CGImage+AttachableAsCGImage.swift | 9 +++++-- ...chableImageWrapper+AttachableWrapper.swift | 4 +-- .../ReexportTesting.swift | 4 +-- .../CIImage+AttachableAsCGImage.swift | 11 +++++--- .../_Testing_CoreImage/ReexportTesting.swift | 6 ++--- .../UIImage+AttachableAsCGImage.swift | 12 ++++++--- .../_Testing_UIKit/ReexportTesting.swift | 6 ++--- .../AttachableAsIWICBitmapSource.swift | 4 +++ ...achment+AttachableAsIWICBitmapSource.swift | 4 +++ .../Images/AttachableImageFormat.swift | 25 +++++++++++++++++-- .../Images/ImageAttachmentError.swift | 2 +- .../Images/_AttachableImageWrapper.swift | 3 ++- Sources/Testing/Testing.docc/Attachments.md | 14 +++++++++-- Tests/TestingTests/AttachmentTests.swift | 8 +++--- 19 files changed, 133 insertions(+), 46 deletions(-) diff --git a/Sources/Overlays/_Testing_AppKit/Attachments/NSImage+AttachableAsCGImage.swift b/Sources/Overlays/_Testing_AppKit/Attachments/NSImage+AttachableAsCGImage.swift index d62ef71cc..ef601f46f 100644 --- a/Sources/Overlays/_Testing_AppKit/Attachments/NSImage+AttachableAsCGImage.swift +++ b/Sources/Overlays/_Testing_AppKit/Attachments/NSImage+AttachableAsCGImage.swift @@ -1,7 +1,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -10,7 +10,7 @@ #if SWT_TARGET_OS_APPLE && canImport(AppKit) public import AppKit -@_spi(Experimental) public import _Testing_CoreGraphics +public import _Testing_CoreGraphics extension NSImageRep { /// AppKit's bundle. @@ -33,8 +33,13 @@ extension NSImageRep { // MARK: - -@_spi(Experimental) +/// @Metadata { +/// @Available(Swift, introduced: 6.3) +/// } extension NSImage: AttachableAsCGImage { + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public var attachableCGImage: CGImage { get throws { let ctm = AffineTransform(scale: _attachmentScaleFactor) as NSAffineTransform diff --git a/Sources/Overlays/_Testing_AppKit/ReexportTesting.swift b/Sources/Overlays/_Testing_AppKit/ReexportTesting.swift index ce80a70d9..2e76ecd44 100644 --- a/Sources/Overlays/_Testing_AppKit/ReexportTesting.swift +++ b/Sources/Overlays/_Testing_AppKit/ReexportTesting.swift @@ -1,12 +1,12 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -@_exported @_spi(Experimental) @_spi(ForToolsIntegrationOnly) public import Testing -@_exported @_spi(Experimental) @_spi(ForToolsIntegrationOnly) public import _Testing_CoreGraphics +@_exported public import Testing +@_exported public import _Testing_CoreGraphics diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift index e51742dc3..31427c9d7 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift @@ -1,7 +1,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -13,12 +13,12 @@ public import CoreGraphics private import ImageIO /// A protocol describing images that can be converted to instances of -/// ``Testing/Attachment``. +/// [`Attachment`](https://developer.apple.com/documentation/testing/attachment). /// /// Instances of types conforming to this protocol do not themselves conform to -/// ``Testing/Attachable``. Instead, the testing library provides additional -/// initializers on ``Testing/Attachment`` that take instances of such types and -/// handle converting them to image data when needed. +/// [`Attachable`](https://developer.apple.com/documentation/testing/attachable). +/// Instead, the testing library provides additional initializers on [`Attachment`](https://developer.apple.com/documentation/testing/attachment) +/// that take instances of such types and handle converting them to image data when needed. /// /// You can attach instances of the following system-provided image types to a /// test: @@ -27,17 +27,26 @@ private import ImageIO /// |-|-| /// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | /// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | +/// @Comment { /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | +/// } /// /// You do not generally need to add your own conformances to this protocol. If /// you have an image in another format that needs to be attached to a test, /// first convert it to an instance of one of the types above. -@_spi(Experimental) +/// +/// @Metadata { +/// @Available(Swift, introduced: 6.3) +/// } @available(_uttypesAPI, *) public protocol AttachableAsCGImage: SendableMetatype { /// An instance of `CGImage` representing this image. /// /// - Throws: Any error that prevents the creation of an image. + /// + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } var attachableCGImage: CGImage { get throws } /// The orientation of the image. diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableImageFormat+UTType.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableImageFormat+UTType.swift index 173265807..4a0146c72 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableImageFormat+UTType.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableImageFormat+UTType.swift @@ -9,7 +9,7 @@ // #if SWT_TARGET_OS_APPLE && canImport(CoreGraphics) -@_spi(Experimental) public import Testing +public import Testing public import UniformTypeIdentifiers @@ -64,6 +64,10 @@ extension AttachableImageFormat { /// The content type corresponding to this image format. /// /// The value of this property always conforms to [`UTType.image`](https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/image). + /// + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public var contentType: UTType { switch kind { case .png: @@ -89,6 +93,10 @@ extension AttachableImageFormat { /// /// If `contentType` does not conform to [`UTType.image`](https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/image), /// the result is undefined. + /// + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public init(_ contentType: UTType, encodingQuality: Float = 1.0) { precondition( contentType.conforms(to: .image), diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift index b3349915b..65d90b11a 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift @@ -1,7 +1,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -9,9 +9,8 @@ // #if SWT_TARGET_OS_APPLE && canImport(CoreGraphics) -@_spi(Experimental) public import Testing +public import Testing -@_spi(Experimental) @available(_uttypesAPI, *) extension Attachment { /// Initialize an instance of this type that encloses the given image. @@ -33,7 +32,9 @@ extension Attachment { /// |-|-| /// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | /// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | + /// @Comment { /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | + /// } /// /// The testing library uses the image format specified by `imageFormat`. Pass /// `nil` to let the testing library decide which image format to use. If you @@ -42,6 +43,10 @@ extension Attachment { /// specify a path extension, or if the path extension you specify doesn't /// correspond to an image format the operating system knows how to write, the /// testing library selects an appropriate image format for you. + /// + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public init( _ image: T, named preferredName: String? = nil, @@ -74,7 +79,9 @@ extension Attachment { /// |-|-| /// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | /// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | + /// @Comment { /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | + /// } /// /// The testing library uses the image format specified by `imageFormat`. Pass /// `nil` to let the testing library decide which image format to use. If you @@ -83,8 +90,12 @@ extension Attachment { /// specify a path extension, or if the path extension you specify doesn't /// correspond to an image format the operating system knows how to write, the /// testing library selects an appropriate image format for you. + /// + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public static func record( - _ image: consuming T, + _ image: T, named preferredName: String? = nil, as imageFormat: AttachableImageFormat? = nil, sourceLocation: SourceLocation = #_sourceLocation diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/CGImage+AttachableAsCGImage.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/CGImage+AttachableAsCGImage.swift index 944798d39..c4a4fd630 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/CGImage+AttachableAsCGImage.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/CGImage+AttachableAsCGImage.swift @@ -1,7 +1,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -11,8 +11,13 @@ #if SWT_TARGET_OS_APPLE && canImport(CoreGraphics) public import CoreGraphics -@_spi(Experimental) +/// @Metadata { +/// @Available(Swift, introduced: 6.3) +/// } extension CGImage: AttachableAsCGImage { + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public var attachableCGImage: CGImage { self } diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper+AttachableWrapper.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper+AttachableWrapper.swift index bb0d42b23..3281de11a 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper+AttachableWrapper.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper+AttachableWrapper.swift @@ -1,7 +1,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -9,7 +9,7 @@ // #if SWT_TARGET_OS_APPLE && canImport(CoreGraphics) -@_spi(Experimental) public import Testing +public import Testing private import CoreGraphics private import ImageIO diff --git a/Sources/Overlays/_Testing_CoreGraphics/ReexportTesting.swift b/Sources/Overlays/_Testing_CoreGraphics/ReexportTesting.swift index 5b28faa77..be2275d11 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/ReexportTesting.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/ReexportTesting.swift @@ -1,11 +1,11 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -@_exported @_spi(Experimental) @_spi(ForToolsIntegrationOnly) public import Testing +@_exported public import Testing diff --git a/Sources/Overlays/_Testing_CoreImage/Attachments/CIImage+AttachableAsCGImage.swift b/Sources/Overlays/_Testing_CoreImage/Attachments/CIImage+AttachableAsCGImage.swift index 7614dc633..581de2c7c 100644 --- a/Sources/Overlays/_Testing_CoreImage/Attachments/CIImage+AttachableAsCGImage.swift +++ b/Sources/Overlays/_Testing_CoreImage/Attachments/CIImage+AttachableAsCGImage.swift @@ -1,7 +1,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -10,10 +10,15 @@ #if SWT_TARGET_OS_APPLE && canImport(CoreImage) public import CoreImage -@_spi(Experimental) public import _Testing_CoreGraphics +public import _Testing_CoreGraphics -@_spi(Experimental) +/// @Metadata { +/// @Available(Swift, introduced: 6.3) +/// } extension CIImage: AttachableAsCGImage { + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public var attachableCGImage: CGImage { get throws { guard let result = CIContext().createCGImage(self, from: extent) else { diff --git a/Sources/Overlays/_Testing_CoreImage/ReexportTesting.swift b/Sources/Overlays/_Testing_CoreImage/ReexportTesting.swift index ce80a70d9..2e76ecd44 100644 --- a/Sources/Overlays/_Testing_CoreImage/ReexportTesting.swift +++ b/Sources/Overlays/_Testing_CoreImage/ReexportTesting.swift @@ -1,12 +1,12 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -@_exported @_spi(Experimental) @_spi(ForToolsIntegrationOnly) public import Testing -@_exported @_spi(Experimental) @_spi(ForToolsIntegrationOnly) public import _Testing_CoreGraphics +@_exported public import Testing +@_exported public import _Testing_CoreGraphics diff --git a/Sources/Overlays/_Testing_UIKit/Attachments/UIImage+AttachableAsCGImage.swift b/Sources/Overlays/_Testing_UIKit/Attachments/UIImage+AttachableAsCGImage.swift index 233f737a4..3766b3095 100644 --- a/Sources/Overlays/_Testing_UIKit/Attachments/UIImage+AttachableAsCGImage.swift +++ b/Sources/Overlays/_Testing_UIKit/Attachments/UIImage+AttachableAsCGImage.swift @@ -1,7 +1,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -10,16 +10,20 @@ #if SWT_TARGET_OS_APPLE && canImport(UIKit) public import UIKit -@_spi(Experimental) public import _Testing_CoreGraphics -@_spi(Experimental) private import _Testing_CoreImage +public import _Testing_CoreGraphics private import ImageIO #if canImport(UIKitCore_Private) private import UIKitCore_Private #endif -@_spi(Experimental) +/// @Metadata { +/// @Available(Swift, introduced: 6.3) +/// } extension UIImage: AttachableAsCGImage { + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public var attachableCGImage: CGImage { get throws { #if canImport(UIKitCore_Private) diff --git a/Sources/Overlays/_Testing_UIKit/ReexportTesting.swift b/Sources/Overlays/_Testing_UIKit/ReexportTesting.swift index ce80a70d9..2e76ecd44 100644 --- a/Sources/Overlays/_Testing_UIKit/ReexportTesting.swift +++ b/Sources/Overlays/_Testing_UIKit/ReexportTesting.swift @@ -1,12 +1,12 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -@_exported @_spi(Experimental) @_spi(ForToolsIntegrationOnly) public import Testing -@_exported @_spi(Experimental) @_spi(ForToolsIntegrationOnly) public import _Testing_CoreGraphics +@_exported public import Testing +@_exported public import _Testing_CoreGraphics diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift index fdcad1809..19625d0be 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift @@ -27,7 +27,9 @@ public import WinSDK /// |-|-| /// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | /// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | +/// @Comment { /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | +/// } /// /// You do not generally need to add your own conformances to this protocol. If /// you have an image in another format that needs to be attached to a test, @@ -107,7 +109,9 @@ public protocol _AttachableByAddressAsIWICBitmapSource { /// |-|-| /// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | /// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | +/// @Comment { /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | +/// } /// /// You do not generally need to add your own conformances to this protocol. If /// you have an image in another format that needs to be attached to a test, diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift index 8068e7a8e..b7540072a 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift @@ -33,7 +33,9 @@ extension Attachment { /// |-|-| /// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | /// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | + /// @Comment { /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | + /// } /// /// The testing library uses the image format specified by `imageFormat`. Pass /// `nil` to let the testing library decide which image format to use. If you @@ -76,7 +78,9 @@ extension Attachment { /// |-|-| /// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | /// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | + /// @Comment { /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | + /// } /// /// The testing library uses the image format specified by `imageFormat`. Pass /// `nil` to let the testing library decide which image format to use. If you diff --git a/Sources/Testing/Attachments/Images/AttachableImageFormat.swift b/Sources/Testing/Attachments/Images/AttachableImageFormat.swift index 4798e42b1..9bf6b50f8 100644 --- a/Sources/Testing/Attachments/Images/AttachableImageFormat.swift +++ b/Sources/Testing/Attachments/Images/AttachableImageFormat.swift @@ -12,7 +12,7 @@ /// when attaching an image to a test. /// /// When you attach an image to a test, you can pass an instance of this type to -/// ``Attachment/record(_:named:as:sourceLocation:)`` so that the testing +/// `Attachment.record(_:named:as:sourceLocation:)` so that the testing /// library knows the image format you'd like to use. If you don't pass an /// instance of this type, the testing library infers which format to use based /// on the attachment's preferred name. @@ -23,9 +23,14 @@ /// - On Apple platforms, you can use [`CGImageDestinationCopyTypeIdentifiers()`](https://developer.apple.com/documentation/imageio/cgimagedestinationcopytypeidentifiers()) /// from the [Image I/O framework](https://developer.apple.com/documentation/imageio) /// to determine which formats are supported. +/// @Comment { /// - On Windows, you can use [`IWICImagingFactory.CreateComponentEnumerator()`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicimagingfactory-createcomponentenumerator) /// to enumerate the available image encoders. -@_spi(Experimental) +/// } +/// +/// @Metadata { +/// @Available(Swift, introduced: 6.3) +/// } @available(_uttypesAPI, *) public struct AttachableImageFormat: Sendable { /// An enumeration describing the various kinds of image format that can be @@ -58,6 +63,10 @@ public struct AttachableImageFormat: Sendable { /// supported encoding quality and `1.0` being the highest supported encoding /// quality. The value of this property is ignored for image formats that do /// not support variable encoding quality. + /// + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public internal(set) var encodingQuality: Float = 1.0 package init(kind: Kind, encodingQuality: Float) { @@ -71,11 +80,19 @@ public struct AttachableImageFormat: Sendable { @available(_uttypesAPI, *) extension AttachableImageFormat { /// The PNG image format. + /// + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public static var png: Self { Self(kind: .png, encodingQuality: 1.0) } /// The JPEG image format with maximum encoding quality. + /// + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public static var jpeg: Self { Self(kind: .jpeg, encodingQuality: 1.0) } @@ -90,6 +107,10 @@ extension AttachableImageFormat { /// /// - Returns: An instance of this type representing the JPEG image format /// with the specified encoding quality. + /// + /// @Metadata { + /// @Available(Swift, introduced: 6.3) + /// } public static func jpeg(withEncodingQuality encodingQuality: Float) -> Self { Self(kind: .jpeg, encodingQuality: encodingQuality) } diff --git a/Sources/Testing/Attachments/Images/ImageAttachmentError.swift b/Sources/Testing/Attachments/Images/ImageAttachmentError.swift index 7cd6f8180..de421bfd9 100644 --- a/Sources/Testing/Attachments/Images/ImageAttachmentError.swift +++ b/Sources/Testing/Attachments/Images/ImageAttachmentError.swift @@ -1,7 +1,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information diff --git a/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift b/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift index 71623538a..25e102677 100644 --- a/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift +++ b/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift @@ -17,8 +17,9 @@ /// |-|-| /// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | /// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | +/// @Comment { /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | -@_spi(Experimental) +/// } @available(_uttypesAPI, *) public final class _AttachableImageWrapper: Sendable { /// The underlying image. diff --git a/Sources/Testing/Testing.docc/Attachments.md b/Sources/Testing/Testing.docc/Attachments.md index 0da40c201..e05fc0270 100644 --- a/Sources/Testing/Testing.docc/Attachments.md +++ b/Sources/Testing/Testing.docc/Attachments.md @@ -14,7 +14,7 @@ Attach values to tests to help diagnose issues and gather feedback. ## Overview -Attach values such as strings and files to tests. Implement the ``Attachable`` +Attach values such as strings and files to tests. Implement the ``Attachable`` protocol to create your own attachable types. ## Topics @@ -25,8 +25,18 @@ protocol to create your own attachable types. - ``Attachable`` - ``AttachableWrapper`` + + +### Attaching images to tests + +- ``AttachableImageFormat`` + diff --git a/Tests/TestingTests/AttachmentTests.swift b/Tests/TestingTests/AttachmentTests.swift index 84db8fe38..69793d215 100644 --- a/Tests/TestingTests/AttachmentTests.swift +++ b/Tests/TestingTests/AttachmentTests.swift @@ -1,7 +1,7 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2023 Apple Inc. and the Swift project authors +// Copyright (c) 2023–2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -12,7 +12,7 @@ private import _TestingInternals #if canImport(AppKit) && canImport(_Testing_AppKit) import AppKit -@_spi(Experimental) import _Testing_AppKit +import _Testing_AppKit #endif #if canImport(Foundation) && canImport(_Testing_Foundation) import Foundation @@ -24,11 +24,11 @@ import CoreGraphics #endif #if canImport(CoreImage) && canImport(_Testing_CoreImage) import CoreImage -@_spi(Experimental) import _Testing_CoreImage +import _Testing_CoreImage #endif #if canImport(UIKit) && canImport(_Testing_UIKit) import UIKit -@_spi(Experimental) import _Testing_UIKit +import _Testing_UIKit #endif #if canImport(UniformTypeIdentifiers) import UniformTypeIdentifiers From 67715737cec4e448af999f3543da2f50f18f8c82 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Tue, 19 Aug 2025 10:41:56 -0400 Subject: [PATCH 02/13] Don't comment out Windows support in the experimental Windows overlay bits --- .../Attachments/AttachableAsIWICBitmapSource.swift | 4 ---- .../Attachments/Attachment+AttachableAsIWICBitmapSource.swift | 4 ---- 2 files changed, 8 deletions(-) diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift index 19625d0be..fdcad1809 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift @@ -27,9 +27,7 @@ public import WinSDK /// |-|-| /// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | /// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | -/// @Comment { /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | -/// } /// /// You do not generally need to add your own conformances to this protocol. If /// you have an image in another format that needs to be attached to a test, @@ -109,9 +107,7 @@ public protocol _AttachableByAddressAsIWICBitmapSource { /// |-|-| /// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | /// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | -/// @Comment { /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | -/// } /// /// You do not generally need to add your own conformances to this protocol. If /// you have an image in another format that needs to be attached to a test, diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift index b7540072a..8068e7a8e 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift @@ -33,9 +33,7 @@ extension Attachment { /// |-|-| /// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | /// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | - /// @Comment { /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | - /// } /// /// The testing library uses the image format specified by `imageFormat`. Pass /// `nil` to let the testing library decide which image format to use. If you @@ -78,9 +76,7 @@ extension Attachment { /// |-|-| /// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | /// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | - /// @Comment { /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | - /// } /// /// The testing library uses the image format specified by `imageFormat`. Pass /// `nil` to let the testing library decide which image format to use. If you From 00ca2453ef1a52139be3a1d6b17b883792665157 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Tue, 19 Aug 2025 10:49:48 -0400 Subject: [PATCH 03/13] Remove another @_spi --- .../Attachments/_AttachableImageWrapper+AttachableWrapper.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper+AttachableWrapper.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper+AttachableWrapper.swift index 89d010899..3281de11a 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper+AttachableWrapper.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper+AttachableWrapper.swift @@ -39,7 +39,6 @@ private import UniformTypeIdentifiers /// useful.) @available(_uttypesAPI, *) -@_spi(Experimental) extension _AttachableImageWrapper: Attachable, AttachableWrapper where Image: AttachableAsCGImage { public func withUnsafeBytes(for attachment: borrowing Attachment<_AttachableImageWrapper>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R { let data = NSMutableData() From 9b4887f4c82fb742bce9bea2e52dce07229f197d Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Tue, 19 Aug 2025 11:49:43 -0400 Subject: [PATCH 04/13] Update CMake --- Sources/Overlays/CMakeLists.txt | 6 +++++- .../Overlays/_Testing_AppKit/CMakeLists.txt | 21 +++++++++++++++++++ .../_Testing_CoreGraphics/CMakeLists.txt | 21 +++++++++++++++++++ .../_Testing_CoreImage/CMakeLists.txt | 21 +++++++++++++++++++ .../Overlays/_Testing_UIKit/CMakeLists.txt | 21 +++++++++++++++++++ 5 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 Sources/Overlays/_Testing_AppKit/CMakeLists.txt create mode 100644 Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt create mode 100644 Sources/Overlays/_Testing_CoreImage/CMakeLists.txt create mode 100644 Sources/Overlays/_Testing_UIKit/CMakeLists.txt diff --git a/Sources/Overlays/CMakeLists.txt b/Sources/Overlays/CMakeLists.txt index 2120d680f..5629e8229 100644 --- a/Sources/Overlays/CMakeLists.txt +++ b/Sources/Overlays/CMakeLists.txt @@ -1,9 +1,13 @@ # This source file is part of the Swift.org open source project # -# Copyright (c) 2024 Apple Inc. and the Swift project authors +# Copyright (c) 2024–2025 Apple Inc. and the Swift project authors # Licensed under Apache License v2.0 with Runtime Library Exception # # See http://swift.org/LICENSE.txt for license information # See http://swift.org/CONTRIBUTORS.txt for Swift project authors +add_subdirectory(_Testing_AppKit) +add_subdirectory(_Testing_CoreGraphics) +add_subdirectory(_Testing_CoreImage) add_subdirectory(_Testing_Foundation) +add_subdirectory(_Testing_UIKit) diff --git a/Sources/Overlays/_Testing_AppKit/CMakeLists.txt b/Sources/Overlays/_Testing_AppKit/CMakeLists.txt new file mode 100644 index 000000000..954136683 --- /dev/null +++ b/Sources/Overlays/_Testing_AppKit/CMakeLists.txt @@ -0,0 +1,21 @@ +# This source file is part of the Swift.org open source project +# +# Copyright (c) 2024–2025 Apple Inc. and the Swift project authors +# Licensed under Apache License v2.0 with Runtime Library Exception +# +# See http://swift.org/LICENSE.txt for license information +# See http://swift.org/CONTRIBUTORS.txt for Swift project authors + +if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") + add_library(_Testing_AppKit + Attachments/NSImage+AttachableAsCGImage.swift + ReexportTesting.swift) + + target_link_libraries(_Testing_AppKit PUBLIC + Testing) + + target_compile_options(_Testing_AppKit PRIVATE + -emit-module-interface -emit-module-interface-path $/_Testing_AppKit.swiftinterface) + + _swift_testing_install_target(_Testing_AppKit) +endif() diff --git a/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt b/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt new file mode 100644 index 000000000..0f53991d6 --- /dev/null +++ b/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt @@ -0,0 +1,21 @@ +# This source file is part of the Swift.org open source project +# +# Copyright (c) 2024–2025 Apple Inc. and the Swift project authors +# Licensed under Apache License v2.0 with Runtime Library Exception +# +# See http://swift.org/LICENSE.txt for license information +# See http://swift.org/CONTRIBUTORS.txt for Swift project authors + +if(APPLE) + add_library(_Testing_CoreGraphics + Attachments/NSImage+AttachableAsCGImage.swift + ReexportTesting.swift) + + target_link_libraries(_Testing_CoreGraphics PUBLIC + Testing) + + target_compile_options(_Testing_CoreGraphics PRIVATE + -emit-module-interface -emit-module-interface-path $/_Testing_CoreGraphics.swiftinterface) + + _swift_testing_install_target(_Testing_CoreGraphics) +endif() diff --git a/Sources/Overlays/_Testing_CoreImage/CMakeLists.txt b/Sources/Overlays/_Testing_CoreImage/CMakeLists.txt new file mode 100644 index 000000000..f7cd33821 --- /dev/null +++ b/Sources/Overlays/_Testing_CoreImage/CMakeLists.txt @@ -0,0 +1,21 @@ +# This source file is part of the Swift.org open source project +# +# Copyright (c) 2024–2025 Apple Inc. and the Swift project authors +# Licensed under Apache License v2.0 with Runtime Library Exception +# +# See http://swift.org/LICENSE.txt for license information +# See http://swift.org/CONTRIBUTORS.txt for Swift project authors + +if(APPLE) + add_library(_Testing_CoreImage + Attachments/CIImage+AttachableAsCGImage.swift + ReexportTesting.swift) + + target_link_libraries(_Testing_CoreImage PUBLIC + Testing) + + target_compile_options(_Testing_CoreImage PRIVATE + -emit-module-interface -emit-module-interface-path $/_Testing_CoreImage.swiftinterface) + + _swift_testing_install_target(_Testing_CoreImage) +endif() diff --git a/Sources/Overlays/_Testing_UIKit/CMakeLists.txt b/Sources/Overlays/_Testing_UIKit/CMakeLists.txt new file mode 100644 index 000000000..931e5f063 --- /dev/null +++ b/Sources/Overlays/_Testing_UIKit/CMakeLists.txt @@ -0,0 +1,21 @@ +# This source file is part of the Swift.org open source project +# +# Copyright (c) 2024–2025 Apple Inc. and the Swift project authors +# Licensed under Apache License v2.0 with Runtime Library Exception +# +# See http://swift.org/LICENSE.txt for license information +# See http://swift.org/CONTRIBUTORS.txt for Swift project authors + +if(APPLE) // iOS (etc.) and Mac Catalyst + add_library(_Testing_UIKit + Attachments/UIImage+AttachableAsCGImage.swift + ReexportTesting.swift) + + target_link_libraries(_Testing_UIKit PUBLIC + Testing) + + target_compile_options(_Testing_UIKit PRIVATE + -emit-module-interface -emit-module-interface-path $/_Testing_UIKit.swiftinterface) + + _swift_testing_install_target(_Testing_UIKit) +endif() From 387878f050013ab2bbc6006976b09a99908cbdec Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Tue, 19 Aug 2025 11:51:57 -0400 Subject: [PATCH 05/13] Enable library evolution --- Sources/Overlays/_Testing_AppKit/CMakeLists.txt | 1 + Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt | 1 + Sources/Overlays/_Testing_CoreImage/CMakeLists.txt | 1 + Sources/Overlays/_Testing_UIKit/CMakeLists.txt | 1 + 4 files changed, 4 insertions(+) diff --git a/Sources/Overlays/_Testing_AppKit/CMakeLists.txt b/Sources/Overlays/_Testing_AppKit/CMakeLists.txt index 954136683..9d5639515 100644 --- a/Sources/Overlays/_Testing_AppKit/CMakeLists.txt +++ b/Sources/Overlays/_Testing_AppKit/CMakeLists.txt @@ -15,6 +15,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") Testing) target_compile_options(_Testing_AppKit PRIVATE + -enable-library-evolution -emit-module-interface -emit-module-interface-path $/_Testing_AppKit.swiftinterface) _swift_testing_install_target(_Testing_AppKit) diff --git a/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt b/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt index 0f53991d6..801444d45 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt +++ b/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt @@ -15,6 +15,7 @@ if(APPLE) Testing) target_compile_options(_Testing_CoreGraphics PRIVATE + -enable-library-evolution -emit-module-interface -emit-module-interface-path $/_Testing_CoreGraphics.swiftinterface) _swift_testing_install_target(_Testing_CoreGraphics) diff --git a/Sources/Overlays/_Testing_CoreImage/CMakeLists.txt b/Sources/Overlays/_Testing_CoreImage/CMakeLists.txt index f7cd33821..abe1de0c8 100644 --- a/Sources/Overlays/_Testing_CoreImage/CMakeLists.txt +++ b/Sources/Overlays/_Testing_CoreImage/CMakeLists.txt @@ -15,6 +15,7 @@ if(APPLE) Testing) target_compile_options(_Testing_CoreImage PRIVATE + -enable-library-evolution -emit-module-interface -emit-module-interface-path $/_Testing_CoreImage.swiftinterface) _swift_testing_install_target(_Testing_CoreImage) diff --git a/Sources/Overlays/_Testing_UIKit/CMakeLists.txt b/Sources/Overlays/_Testing_UIKit/CMakeLists.txt index 931e5f063..e4b4286a8 100644 --- a/Sources/Overlays/_Testing_UIKit/CMakeLists.txt +++ b/Sources/Overlays/_Testing_UIKit/CMakeLists.txt @@ -15,6 +15,7 @@ if(APPLE) // iOS (etc.) and Mac Catalyst Testing) target_compile_options(_Testing_UIKit PRIVATE + -enable-library-evolution -emit-module-interface -emit-module-interface-path $/_Testing_UIKit.swiftinterface) _swift_testing_install_target(_Testing_UIKit) From b87a69f0639848b2a1d9ef767f0ae455dbb4a939 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Tue, 19 Aug 2025 11:56:59 -0400 Subject: [PATCH 06/13] Add more linked libraries to CMake --- Sources/Overlays/_Testing_AppKit/CMakeLists.txt | 4 +++- Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt | 8 +++++++- Sources/Overlays/_Testing_CoreImage/CMakeLists.txt | 4 +++- Sources/Overlays/_Testing_UIKit/CMakeLists.txt | 4 +++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Sources/Overlays/_Testing_AppKit/CMakeLists.txt b/Sources/Overlays/_Testing_AppKit/CMakeLists.txt index 9d5639515..0c3843493 100644 --- a/Sources/Overlays/_Testing_AppKit/CMakeLists.txt +++ b/Sources/Overlays/_Testing_AppKit/CMakeLists.txt @@ -12,7 +12,9 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") ReexportTesting.swift) target_link_libraries(_Testing_AppKit PUBLIC - Testing) + Testing + _Testing_CoreGraphics + AppKit) target_compile_options(_Testing_AppKit PRIVATE -enable-library-evolution diff --git a/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt b/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt index 801444d45..065f20396 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt +++ b/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt @@ -12,7 +12,13 @@ if(APPLE) ReexportTesting.swift) target_link_libraries(_Testing_CoreGraphics PUBLIC - Testing) + Testing + CoreGraphics + UniformTypeIdentifiers) + + target_link_libraries(_Testing_CoreGraphics PRIVATE + Foundation + ImageIO) target_compile_options(_Testing_CoreGraphics PRIVATE -enable-library-evolution diff --git a/Sources/Overlays/_Testing_CoreImage/CMakeLists.txt b/Sources/Overlays/_Testing_CoreImage/CMakeLists.txt index abe1de0c8..6a315b001 100644 --- a/Sources/Overlays/_Testing_CoreImage/CMakeLists.txt +++ b/Sources/Overlays/_Testing_CoreImage/CMakeLists.txt @@ -12,7 +12,9 @@ if(APPLE) ReexportTesting.swift) target_link_libraries(_Testing_CoreImage PUBLIC - Testing) + Testing + _Testing_CoreGraphics + CoreImage) target_compile_options(_Testing_CoreImage PRIVATE -enable-library-evolution diff --git a/Sources/Overlays/_Testing_UIKit/CMakeLists.txt b/Sources/Overlays/_Testing_UIKit/CMakeLists.txt index e4b4286a8..f6293b0de 100644 --- a/Sources/Overlays/_Testing_UIKit/CMakeLists.txt +++ b/Sources/Overlays/_Testing_UIKit/CMakeLists.txt @@ -12,7 +12,9 @@ if(APPLE) // iOS (etc.) and Mac Catalyst ReexportTesting.swift) target_link_libraries(_Testing_UIKit PUBLIC - Testing) + Testing + _Testing_CoreGraphics + UIKit) target_compile_options(_Testing_UIKit PRIVATE -enable-library-evolution From 641d6796a3a5538ae0dbe46e7e536f954f20239f Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Tue, 19 Aug 2025 13:11:54 -0400 Subject: [PATCH 07/13] Update .swiftcrossimport folder --- Sources/Testing/Testing.swiftcrossimport/AppKit.swiftoverlay | 3 +++ .../Testing/Testing.swiftcrossimport/CoreGraphics.swiftoverlay | 3 +++ .../Testing/Testing.swiftcrossimport/CoreImage.swiftoverlay | 3 +++ Sources/Testing/Testing.swiftcrossimport/UIKit.swiftoverlay | 3 +++ 4 files changed, 12 insertions(+) create mode 100644 Sources/Testing/Testing.swiftcrossimport/AppKit.swiftoverlay create mode 100644 Sources/Testing/Testing.swiftcrossimport/CoreGraphics.swiftoverlay create mode 100644 Sources/Testing/Testing.swiftcrossimport/CoreImage.swiftoverlay create mode 100644 Sources/Testing/Testing.swiftcrossimport/UIKit.swiftoverlay diff --git a/Sources/Testing/Testing.swiftcrossimport/AppKit.swiftoverlay b/Sources/Testing/Testing.swiftcrossimport/AppKit.swiftoverlay new file mode 100644 index 000000000..cc9998ba3 --- /dev/null +++ b/Sources/Testing/Testing.swiftcrossimport/AppKit.swiftoverlay @@ -0,0 +1,3 @@ +version: 1 +modules: +- name: _Testing_AppKit diff --git a/Sources/Testing/Testing.swiftcrossimport/CoreGraphics.swiftoverlay b/Sources/Testing/Testing.swiftcrossimport/CoreGraphics.swiftoverlay new file mode 100644 index 000000000..656012089 --- /dev/null +++ b/Sources/Testing/Testing.swiftcrossimport/CoreGraphics.swiftoverlay @@ -0,0 +1,3 @@ +version: 1 +modules: +- name: _Testing_CoreGraphics diff --git a/Sources/Testing/Testing.swiftcrossimport/CoreImage.swiftoverlay b/Sources/Testing/Testing.swiftcrossimport/CoreImage.swiftoverlay new file mode 100644 index 000000000..cdea5109b --- /dev/null +++ b/Sources/Testing/Testing.swiftcrossimport/CoreImage.swiftoverlay @@ -0,0 +1,3 @@ +version: 1 +modules: +- name: _Testing_CoreImage diff --git a/Sources/Testing/Testing.swiftcrossimport/UIKit.swiftoverlay b/Sources/Testing/Testing.swiftcrossimport/UIKit.swiftoverlay new file mode 100644 index 000000000..b3c35caed --- /dev/null +++ b/Sources/Testing/Testing.swiftcrossimport/UIKit.swiftoverlay @@ -0,0 +1,3 @@ +version: 1 +modules: +- name: _Testing_UIKit From 16708c2c919194bef5d088c7dc94c498db45d22d Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Tue, 19 Aug 2025 13:32:32 -0400 Subject: [PATCH 08/13] CMake doesn't like comments there --- Sources/Overlays/_Testing_UIKit/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Overlays/_Testing_UIKit/CMakeLists.txt b/Sources/Overlays/_Testing_UIKit/CMakeLists.txt index f6293b0de..d9a0b7c7e 100644 --- a/Sources/Overlays/_Testing_UIKit/CMakeLists.txt +++ b/Sources/Overlays/_Testing_UIKit/CMakeLists.txt @@ -6,7 +6,7 @@ # See http://swift.org/LICENSE.txt for license information # See http://swift.org/CONTRIBUTORS.txt for Swift project authors -if(APPLE) // iOS (etc.) and Mac Catalyst +if(APPLE) add_library(_Testing_UIKit Attachments/UIImage+AttachableAsCGImage.swift ReexportTesting.swift) From 7d8f804908982174a8d1870b90a727d84c7a606d Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Tue, 19 Aug 2025 17:44:38 -0400 Subject: [PATCH 09/13] Fix typo --- Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt b/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt index 065f20396..400118920 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt +++ b/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt @@ -8,7 +8,7 @@ if(APPLE) add_library(_Testing_CoreGraphics - Attachments/NSImage+AttachableAsCGImage.swift + Attachments/CGImage+AttachableAsCGImage.swift ReexportTesting.swift) target_link_libraries(_Testing_CoreGraphics PUBLIC From e21c8bd6983b5548c904d1e2ab2898fcf18443d2 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Thu, 21 Aug 2025 09:50:04 -0400 Subject: [PATCH 10/13] CG cmake fixes --- Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt b/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt index 400118920..e48887582 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt +++ b/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt @@ -8,13 +8,17 @@ if(APPLE) add_library(_Testing_CoreGraphics + Attachments/_AttachableImageWrapper+AttachableWrapper.swift + Attachments/AttachableAsCGImage.swift + Attachments/AttachableImageFormat+UTType.swift + Attachment+AttachableAsCGImage.swift Attachments/CGImage+AttachableAsCGImage.swift ReexportTesting.swift) target_link_libraries(_Testing_CoreGraphics PUBLIC Testing CoreGraphics - UniformTypeIdentifiers) + "-weak_framework UniformTypeIdentifiers") target_link_libraries(_Testing_CoreGraphics PRIVATE Foundation From 9df7af3b95047c6204a1cc2fa075bea619ec2ab3 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Thu, 21 Aug 2025 13:33:47 -0400 Subject: [PATCH 11/13] Fix CMake typo --- Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt b/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt index e48887582..a843b37d2 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt +++ b/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt @@ -11,7 +11,7 @@ if(APPLE) Attachments/_AttachableImageWrapper+AttachableWrapper.swift Attachments/AttachableAsCGImage.swift Attachments/AttachableImageFormat+UTType.swift - Attachment+AttachableAsCGImage.swift + Attachments/Attachment+AttachableAsCGImage.swift Attachments/CGImage+AttachableAsCGImage.swift ReexportTesting.swift) From 790d22a4deb1a32a50a1aeb89b0e13d28030d28d Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Thu, 21 Aug 2025 21:45:30 -0400 Subject: [PATCH 12/13] Specify weak framework the CMake way --- Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt b/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt index a843b37d2..764014b40 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt +++ b/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt @@ -18,7 +18,7 @@ if(APPLE) target_link_libraries(_Testing_CoreGraphics PUBLIC Testing CoreGraphics - "-weak_framework UniformTypeIdentifiers") + "$") target_link_libraries(_Testing_CoreGraphics PRIVATE Foundation From ee2ffe08331254eb16a4c0429ebf1d91d4556afd Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Mon, 25 Aug 2025 15:19:38 -0400 Subject: [PATCH 13/13] Rely on autolinking for framework dependencies --- Sources/Overlays/_Testing_AppKit/CMakeLists.txt | 3 +-- Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt | 8 +------- Sources/Overlays/_Testing_CoreImage/CMakeLists.txt | 3 +-- Sources/Overlays/_Testing_UIKit/CMakeLists.txt | 3 +-- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/Sources/Overlays/_Testing_AppKit/CMakeLists.txt b/Sources/Overlays/_Testing_AppKit/CMakeLists.txt index 0c3843493..75a463433 100644 --- a/Sources/Overlays/_Testing_AppKit/CMakeLists.txt +++ b/Sources/Overlays/_Testing_AppKit/CMakeLists.txt @@ -13,8 +13,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") target_link_libraries(_Testing_AppKit PUBLIC Testing - _Testing_CoreGraphics - AppKit) + _Testing_CoreGraphics) target_compile_options(_Testing_AppKit PRIVATE -enable-library-evolution diff --git a/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt b/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt index 764014b40..335068a0b 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt +++ b/Sources/Overlays/_Testing_CoreGraphics/CMakeLists.txt @@ -16,13 +16,7 @@ if(APPLE) ReexportTesting.swift) target_link_libraries(_Testing_CoreGraphics PUBLIC - Testing - CoreGraphics - "$") - - target_link_libraries(_Testing_CoreGraphics PRIVATE - Foundation - ImageIO) + Testing) target_compile_options(_Testing_CoreGraphics PRIVATE -enable-library-evolution diff --git a/Sources/Overlays/_Testing_CoreImage/CMakeLists.txt b/Sources/Overlays/_Testing_CoreImage/CMakeLists.txt index 6a315b001..baa50537e 100644 --- a/Sources/Overlays/_Testing_CoreImage/CMakeLists.txt +++ b/Sources/Overlays/_Testing_CoreImage/CMakeLists.txt @@ -13,8 +13,7 @@ if(APPLE) target_link_libraries(_Testing_CoreImage PUBLIC Testing - _Testing_CoreGraphics - CoreImage) + _Testing_CoreGraphics) target_compile_options(_Testing_CoreImage PRIVATE -enable-library-evolution diff --git a/Sources/Overlays/_Testing_UIKit/CMakeLists.txt b/Sources/Overlays/_Testing_UIKit/CMakeLists.txt index d9a0b7c7e..5976e2e86 100644 --- a/Sources/Overlays/_Testing_UIKit/CMakeLists.txt +++ b/Sources/Overlays/_Testing_UIKit/CMakeLists.txt @@ -13,8 +13,7 @@ if(APPLE) target_link_libraries(_Testing_UIKit PUBLIC Testing - _Testing_CoreGraphics - UIKit) + _Testing_CoreGraphics) target_compile_options(_Testing_UIKit PRIVATE -enable-library-evolution