@@ -141,7 +141,7 @@ let package = Package(
141141 ] ,
142142 exclude: [ " CMakeLists.txt " , " Testing.swiftcrossimport " ] ,
143143 cxxSettings: . packageSettings,
144- swiftSettings: . packageSettings + . enableLibraryEvolution( ) ,
144+ swiftSettings: . packageSettings + . enableLibraryEvolution( ) + . moduleABIName ( " Testing " ) ,
145145 linkerSettings: [
146146 . linkedLibrary( " execinfo " , . when( platforms: [ . custom( " freebsd " ) , . openbsd] ) )
147147 ]
@@ -189,21 +189,15 @@ let package = Package(
189189 . product( name: " SwiftCompilerPlugin " , package : " swift-syntax " ) ,
190190 ] ,
191191 exclude: [ " CMakeLists.txt " ] ,
192- swiftSettings: . packageSettings + {
193- var result = [ PackageDescription . SwiftSetting] ( )
194-
192+ swiftSettings: . packageSettings + [
195193 // The only target which needs the ability to import this macro
196194 // implementation target's module is its unit test target. Users of the
197195 // macros this target implements use them via their declarations in the
198196 // Testing module. This target's module is never distributed to users,
199197 // but as an additional guard against accidental misuse, this specifies
200198 // the unit test target as the only allowable client.
201- if buildingForDevelopment {
202- result. append ( . unsafeFlags( [ " -Xfrontend " , " -allowable-client " , " -Xfrontend " , " TestingMacrosTests " ] ) )
203- }
204-
205- return result
206- } ( )
199+ . unsafeFlags( [ " -Xfrontend " , " -allowable-client " , " -Xfrontend " , " TestingMacrosTests " ] ) ,
200+ ]
207201 ) ,
208202
209203 // "Support" targets: These targets are not meant to be used directly by
@@ -218,7 +212,7 @@ let package = Package(
218212 dependencies: [ " _TestingInternals " , ] ,
219213 exclude: [ " CMakeLists.txt " ] ,
220214 cxxSettings: . packageSettings,
221- swiftSettings: . packageSettings + . enableLibraryEvolution( )
215+ swiftSettings: . packageSettings + . enableLibraryEvolution( ) + . moduleABIName ( " _TestDiscovery " )
222216 ) ,
223217 . target(
224218 // Build _TestingInterop for debugging/testing purposes only. It is
@@ -228,7 +222,7 @@ let package = Package(
228222 path: " Sources/_TestingInterop " ,
229223 exclude: [ " CMakeLists.txt " ] ,
230224 cxxSettings: . packageSettings,
231- swiftSettings: . packageSettings
225+ swiftSettings: . packageSettings + . moduleABIName ( " _TestingInterop " )
232226 ) ,
233227
234228 // Cross-import overlays (not supported by Swift Package Manager)
@@ -240,7 +234,7 @@ let package = Package(
240234 ] ,
241235 path: " Sources/Overlays/_Testing_AppKit " ,
242236 exclude: [ " CMakeLists.txt " ] ,
243- swiftSettings: . packageSettings + . enableLibraryEvolution( )
237+ swiftSettings: . packageSettings + . enableLibraryEvolution( ) + . moduleABIName ( " Testing " )
244238 ) ,
245239 . target(
246240 name: " _Testing_CoreGraphics " ,
@@ -249,7 +243,7 @@ let package = Package(
249243 ] ,
250244 path: " Sources/Overlays/_Testing_CoreGraphics " ,
251245 exclude: [ " CMakeLists.txt " ] ,
252- swiftSettings: . packageSettings + . enableLibraryEvolution( )
246+ swiftSettings: . packageSettings + . enableLibraryEvolution( ) + . moduleABIName ( " _Testing_CoreGraphics " )
253247 ) ,
254248 . target(
255249 name: " _Testing_CoreImage " ,
@@ -259,7 +253,7 @@ let package = Package(
259253 ] ,
260254 path: " Sources/Overlays/_Testing_CoreImage " ,
261255 exclude: [ " CMakeLists.txt " ] ,
262- swiftSettings: . packageSettings + . enableLibraryEvolution( )
256+ swiftSettings: . packageSettings + . enableLibraryEvolution( ) + . moduleABIName ( " _Testing_CoreImage " )
263257 ) ,
264258 . target(
265259 name: " _Testing_Foundation " ,
@@ -271,7 +265,7 @@ let package = Package(
271265 // The Foundation module only has Library Evolution enabled on Apple
272266 // platforms, and since this target's module publicly imports Foundation,
273267 // it can only enable Library Evolution itself on those platforms.
274- swiftSettings: . packageSettings + . enableLibraryEvolution( . whenApple( ) )
268+ swiftSettings: . packageSettings + . enableLibraryEvolution( . whenApple( ) ) + . moduleABIName ( " _Testing_Foundation " )
275269 ) ,
276270 . target(
277271 name: " _Testing_UIKit " ,
@@ -282,7 +276,7 @@ let package = Package(
282276 ] ,
283277 path: " Sources/Overlays/_Testing_UIKit " ,
284278 exclude: [ " CMakeLists.txt " ] ,
285- swiftSettings: . packageSettings + . enableLibraryEvolution( )
279+ swiftSettings: . packageSettings + . enableLibraryEvolution( ) + . moduleABIName ( " _Testing_UIKit " )
286280 ) ,
287281 . target(
288282 name: " _Testing_WinSDK " ,
@@ -291,7 +285,7 @@ let package = Package(
291285 ] ,
292286 path: " Sources/Overlays/_Testing_WinSDK " ,
293287 exclude: [ " CMakeLists.txt " ] ,
294- swiftSettings: . packageSettings + . enableLibraryEvolution( )
288+ swiftSettings: . packageSettings + . enableLibraryEvolution( ) + . moduleABIName ( " _Testing_WinSDK " )
295289 ) ,
296290
297291 // Utility targets: These are utilities intended for use when developing
@@ -369,9 +363,9 @@ extension Array where Element == PackageDescription.SwiftSetting {
369363 static var packageSettings : Self {
370364 var result = availabilityMacroSettings
371365
372- if buildingForDevelopment {
373- result. append ( . unsafeFlags ( [ " -require-explicit-sendable " ] ) )
374- }
366+ # if compiler(>=6.3)
367+ result. append ( . treatWarning ( " ExplicitSendable " , as : . warning ) )
368+ #endif
375369
376370 if buildingForEmbedded {
377371 result. append ( . enableExperimentalFeature( " Embedded " ) )
@@ -385,10 +379,8 @@ extension Array where Element == PackageDescription.SwiftSetting {
385379
386380 . enableUpcomingFeature( " MemberImportVisibility " ) ,
387381
388- // This setting is enabled in the package, but not in the toolchain build
389- // (via CMake). Enabling it is dependent on acceptance of the @section
390- // proposal via Swift Evolution.
391- . enableExperimentalFeature( " SymbolLinkageMarkers " ) ,
382+ // Enabled to allow tests to be added to ~Escapable suites.
383+ . enableExperimentalFeature( " Lifetimes " ) ,
392384
393385 . enableUpcomingFeature( " InferIsolatedConformances " ) ,
394386
@@ -448,6 +440,30 @@ extension Array where Element == PackageDescription.SwiftSetting {
448440
449441 return result
450442 }
443+
444+ /// Create a Swift setting which specifies the module ABI name to use when
445+ /// building the target with the specified name.
446+ ///
447+ /// - Parameters:
448+ /// - targetName The name of the target for which an ABI name should be
449+ /// specified.
450+ ///
451+ /// - Returns: A Swift setting that specifies the ABI name of the module of
452+ /// the target named `targetName`.
453+ ///
454+ /// This function simplifies the process of specifying a custom module ABI
455+ /// name for various targets in this package. The module ABI name is given a
456+ /// suffix for all targets in this package which emit a module that is also
457+ /// included in the built-in copy of Swift Testing in Swift toolchains and
458+ /// vendor distributions. Without this, there can be runtime collisions; for
459+ /// example, on Darwin platforms (where Swift uses the Objective-C runtime),
460+ /// a non-generic Swift class type causes a warning from the runtime about
461+ /// duplicate class definitions. Specifying a distinct ABI name for each
462+ /// module related to Swift Testing loaded into a runner process avoids this
463+ /// issue.
464+ static func moduleABIName( _ targetName: String ) -> Self {
465+ [ . unsafeFlags( [ " -module-abi-name " , " \( targetName) _package " ] ) ]
466+ }
451467}
452468
453469extension Array where Element == PackageDescription . CXXSetting {
0 commit comments