Skip to content

Conversation

@stmontgomery
Copy link
Contributor

This is a workaround meant to avoid Objective-C runtime warnings about duplicate classes stemming from our internal Serializer type which was added in #1390.

Motivation:

In some usage scenarios there can be two or more copies of the testing library loaded into a runner process. When this happens on platforms such as Darwin which use the Objective-C runtime, this can cause duplicate class definition warnings logged to the console because class types and (non-generic) actor types are implemented within the Objective-C runtime as classes. This can look something like the following:

objc[44611]: Class _TtC7Testing10Serializer is implemented in both ../path/to/libTesting.dylib (0x1011ac050) and path/to/swift-testing/.build/arm64-apple-macosx/debug/swift-testingPackageTests.xctest/Contents/MacOS/swift-testingPackageTests (0x10cc3ab88). This may cause spurious casting failures and mysterious crashes. One of the duplicates must be removed or renamed.

Modifications:

I considered several potential fixes, but decided the simplest and most likely to work in all usage scenarios is to make the Serializer type generic by adding an unused generic type parameter T.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

@stmontgomery stmontgomery added this to the Swift 6.3.0 milestone Dec 10, 2025
@stmontgomery stmontgomery self-assigned this Dec 10, 2025
@stmontgomery stmontgomery added bug 🪲 Something isn't working darwin 🍎 macOS, iOS, watchOS, tvOS, and visionOS support workaround Workaround for an issue in another component (may need to revert later) labels Dec 10, 2025
@stmontgomery stmontgomery merged commit af7a094 into swiftlang:main Dec 10, 2025
29 checks passed
@stmontgomery stmontgomery deleted the serializer-objc-runtime-warning branch December 10, 2025 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🪲 Something isn't working darwin 🍎 macOS, iOS, watchOS, tvOS, and visionOS support workaround Workaround for an issue in another component (may need to revert later)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants