Skip to content

Commit 1cf8c83

Browse files
authored
Declare a package name for CMake builds and remove @_spi(ForSwiftTestingOnly) (#954)
This removes usage of `@_spi(ForSwiftTestingOnly)` throughout the codebase and adjusts the CMake build rules to allow adoption of Swift's `package` access level. The technical constraints which prevented adopting that feature have been resolved. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent a4070bc commit 1cf8c83

File tree

7 files changed

+7
-21
lines changed

7 files changed

+7
-21
lines changed

Documentation/SPI.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ external tools, _both_ groups are specified. Such SPI is not generally meant to
3939
be promoted to public API, but is still experimental until tools authors have a
4040
chance to evaluate it.
4141

42-
For interfaces internal to Swift Testing that must be available across targets,
43-
the SPI group `@_spi(ForSwiftTestingOnly)` is used. They _should_ be marked
44-
`package` and may be in the future, but are currently exported due to technical
45-
constraints when Swift Testing is built using CMake.
46-
47-
> [!WARNING]
48-
> Never use symbols marked `@_spi(ForSwiftTestingOnly)`.
49-
5042
## SPI stability
5143

5244
The testing library does **not** guarantee SPI stability for either group of
@@ -59,12 +51,6 @@ to newer interfaces.
5951
SPI marked `@_spi(Experimental)` should be assumed to be unstable. It may be
6052
modified or removed at any time.
6153

62-
SPI marked `@_spi(ForSwiftTestingOnly)` is unstable and subject to change at any
63-
time.
64-
65-
> [!WARNING]
66-
> Never use symbols marked `@_spi(ForSwiftTestingOnly)`.
67-
6854
## API and ABI stability
6955

7056
When Swift Testing reaches its 1.0 release, API changes will follow the same

Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//
1010

1111
#if SWT_TARGET_OS_APPLE && canImport(CoreGraphics)
12-
@_spi(ForSwiftTestingOnly) @_spi(Experimental) public import Testing
12+
@_spi(Experimental) public import Testing
1313

1414
public import UniformTypeIdentifiers
1515

Sources/Overlays/_Testing_CoreGraphics/Attachments/ImageAttachmentError.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
#if SWT_TARGET_OS_APPLE && canImport(CoreGraphics)
1212
/// A type representing an error that can occur when attaching an image.
13-
@_spi(ForSwiftTestingOnly)
14-
public enum ImageAttachmentError: Error, CustomStringConvertible {
13+
package enum ImageAttachmentError: Error, CustomStringConvertible {
1514
/// The image could not be converted to an instance of `CGImage`.
1615
case couldNotCreateCGImage
1716

Sources/Overlays/_Testing_Foundation/Attachments/Attachment+URL.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//
1010

1111
#if canImport(Foundation)
12-
@_spi(Experimental) @_spi(ForSwiftTestingOnly) public import Testing
12+
@_spi(Experimental) public import Testing
1313
public import Foundation
1414

1515
#if !SWT_NO_PROCESS_SPAWNING && os(Windows)

Sources/Testing/Attachments/Attachment.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ public struct Attachment<AttachableValue>: ~Copyable where AttachableValue: Atta
3737
public var fileSystemPath: String?
3838

3939
/// The default preferred name to use if the developer does not supply one.
40-
@_spi(ForSwiftTestingOnly)
41-
public static var defaultPreferredName: String {
40+
package static var defaultPreferredName: String {
4241
"untitled"
4342
}
4443

Tests/TestingTests/AttachmentTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Foundation
1616
#endif
1717
#if canImport(CoreGraphics)
1818
import CoreGraphics
19-
@_spi(Experimental) @_spi(ForSwiftTestingOnly) import _Testing_CoreGraphics
19+
@_spi(Experimental) import _Testing_CoreGraphics
2020
#endif
2121
#if canImport(UniformTypeIdentifiers)
2222
import UniformTypeIdentifiers

cmake/modules/shared/CompilerSettings.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
# Settings intended to be applied to every Swift target in this project.
1010
# Analogous to project-level build settings in an Xcode project.
11+
add_compile_options(
12+
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-package-name org.swift.testing>")
1113
add_compile_options(
1214
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -require-explicit-sendable>")
1315
add_compile_options(

0 commit comments

Comments
 (0)