Skip to content

Commit 03a6272

Browse files
committed
Use a dedicated SWT_NO_ condition that DocC doesn't set
1 parent 2ee28ee commit 03a6272

File tree

6 files changed

+18
-9
lines changed

6 files changed

+18
-9
lines changed

Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ extension Array where Element == PackageDescription.SwiftSetting {
383383
.define("SWT_NO_DYNAMIC_LINKING", .whenEmbedded(or: .when(platforms: [.wasi]))),
384384
.define("SWT_NO_PIPES", .whenEmbedded(or: .when(platforms: [.wasi]))),
385385
.define("SWT_NO_FOUNDATION_FILE_COORDINATION", .whenEmbedded(or: .whenApple(false))),
386+
.define("SWT_NO_IMAGE_ATTACHMENTS", .whenEmbedded(or: .when(platforms: [.linux, .custom("freebsd"), .openbsd, .wasi, .android]))),
386387

387388
.define("SWT_NO_LEGACY_TEST_DISCOVERY", .whenEmbedded()),
388389
.define("SWT_NO_LIBDISPATCH", .whenEmbedded()),

Sources/Testing/Attachments/Images/AttachableImageFormat.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
/// @Metadata {
3232
/// @Available(Swift, introduced: 6.3)
3333
/// }
34-
#if !(SWT_TARGET_OS_APPLE || os(Windows))
34+
#if SWT_NO_IMAGE_ATTACHMENTS
3535
@available(*, unavailable, message: "Image attachments are not available on this platform.")
3636
#endif
3737
@available(_uttypesAPI, *)
@@ -80,7 +80,7 @@ public struct AttachableImageFormat: Sendable {
8080

8181
// MARK: -
8282

83-
#if !(SWT_TARGET_OS_APPLE || os(Windows))
83+
#if SWT_NO_IMAGE_ATTACHMENTS
8484
@available(*, unavailable, message: "Image attachments are not available on this platform.")
8585
#endif
8686
@available(_uttypesAPI, *)

Sources/Testing/Attachments/Images/Attachment+_AttachableAsImage.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11-
#if !(SWT_TARGET_OS_APPLE || os(Windows))
11+
#if SWT_NO_IMAGE_ATTACHMENTS
1212
@available(*, unavailable, message: "Image attachments are not available on this platform.")
1313
#endif
1414
@available(_uttypesAPI, *)
@@ -104,7 +104,7 @@ extension Attachment {
104104
// MARK: -
105105

106106
@_spi(Experimental) // STOP: not part of ST-0014
107-
#if !(SWT_TARGET_OS_APPLE || os(Windows))
107+
#if SWT_NO_IMAGE_ATTACHMENTS
108108
@available(*, unavailable, message: "Image attachments are not available on this platform.")
109109
#endif
110110
@available(_uttypesAPI, *)

Sources/Testing/Attachments/Images/ImageAttachmentError.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
private import _TestingInternals
1212

1313
/// A type representing an error that can occur when attaching an image.
14-
#if !(SWT_TARGET_OS_APPLE || os(Windows))
14+
#if SWT_NO_IMAGE_ATTACHMENTS
1515
@available(*, unavailable, message: "Image attachments are not available on this platform.")
1616
#endif
1717
package enum ImageAttachmentError: Error {
@@ -42,7 +42,7 @@ package enum ImageAttachmentError: Error {
4242
#endif
4343
}
4444

45-
#if !(SWT_TARGET_OS_APPLE || os(Windows))
45+
#if SWT_NO_IMAGE_ATTACHMENTS
4646
@available(*, unavailable, message: "Image attachments are not available on this platform.")
4747
#endif
4848
extension ImageAttachmentError: CustomStringConvertible {

Sources/Testing/Attachments/Images/_AttachableAsImage.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11+
#if SWT_TARGET_OS_APPLE
12+
// Image attachments on Apple platforms conform to AttachableAsCGImage.
13+
#elseif os(Windows)
14+
// Image attachments on Windows platforms conform to AttachableAsIWICBitmapSource.
15+
#elseif !SWT_NO_IMAGE_ATTACHMENTS
16+
#error("Platform-specific misconfiguration: support for image attachments requires a platform-specific implementation")
17+
#endif
18+
1119
/// A protocol describing images that can be converted to instances of
1220
/// [`Attachment`](https://developer.apple.com/documentation/testing/attachment).
1321
///
@@ -18,7 +26,7 @@
1826
/// A future Swift Evolution proposal will promote this protocol to API so
1927
/// that we don't need to underscore its name.
2028
/// }
21-
#if !(SWT_TARGET_OS_APPLE || os(Windows))
29+
#if SWT_NO_IMAGE_ATTACHMENTS
2230
@available(*, unavailable, message: "Image attachments are not available on this platform.")
2331
#endif
2432
@available(_uttypesAPI, *)

Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/// @Comment {
2121
/// | 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) |
2222
/// }
23-
#if !(SWT_TARGET_OS_APPLE || os(Windows))
23+
#if SWT_NO_IMAGE_ATTACHMENTS
2424
@available(*, unavailable, message: "Image attachments are not available on this platform.")
2525
#endif
2626
@available(_uttypesAPI, *)
@@ -41,7 +41,7 @@ public final class _AttachableImageWrapper<Image>: Sendable where Image: _Attach
4141
}
4242
}
4343

44-
#if !(SWT_TARGET_OS_APPLE || os(Windows))
44+
#if SWT_NO_IMAGE_ATTACHMENTS
4545
@available(*, unavailable, message: "Image attachments are not available on this platform.")
4646
#endif
4747
@available(_uttypesAPI, *)

0 commit comments

Comments
 (0)