@@ -27,7 +27,7 @@ let buildingForDevelopment = (git?.currentTag == nil)
2727/// to change in the future.
2828///
2929/// - Bug: There is currently no way for us to tell if we are being asked to
30- /// build for an Embedded Swift target at the package manifest level.
30+ /// build for an Embedded Swift target at the package manifest level.
3131/// ([swift-syntax-#8431](https://github.com/swiftlang/swift-package-manager/issues/8431))
3232let buildingForEmbedded : Bool = {
3333 guard let envvar = Context . environment [ " SWT_EMBEDDED " ] else {
@@ -208,7 +208,7 @@ let package = Package(
208208 // The Foundation module only has Library Evolution enabled on Apple
209209 // platforms, and since this target's module publicly imports Foundation,
210210 // it can only enable Library Evolution itself on those platforms.
211- swiftSettings: . packageSettings + . enableLibraryEvolution( applePlatformsOnly : true )
211+ swiftSettings: . packageSettings + . enableLibraryEvolution( . whenApple ( ) )
212212 ) ,
213213
214214 // Utility targets: These are utilities intended for use when developing
@@ -244,11 +244,11 @@ extension BuildSettingCondition {
244244 /// Swift.
245245 ///
246246 /// - Parameters:
247- /// - nonEmbeddedCondition: The value to return if the target is not
248- /// Embedded Swift. If `nil`, the build condition evaluates to `false`.
247+ /// - nonEmbeddedCondition: The value to return if the target is not
248+ /// Embedded Swift. If `nil`, the build condition evaluates to `false`.
249249 ///
250250 /// - Returns: A build setting condition that evaluates to `true` for Embedded
251- /// Swift or is equal to `nonEmbeddedCondition` for non-Embedded Swift.
251+ /// Swift or is equal to `nonEmbeddedCondition` for non-Embedded Swift.
252252 static func whenEmbedded( or nonEmbeddedCondition: @autoclosure ( ) -> Self ? = nil ) -> Self ? {
253253 if !buildingForEmbedded {
254254 if let nonEmbeddedCondition = nonEmbeddedCondition ( ) {
@@ -263,6 +263,21 @@ extension BuildSettingCondition {
263263 nil
264264 }
265265 }
266+
267+ /// A build setting condition representing all Apple or non-Apple platforms.
268+ ///
269+ /// - Parameters:
270+ /// - isApple: Whether or not the result represents Apple platforms.
271+ ///
272+ /// - Returns: A build setting condition that evaluates to `isApple` for Apple
273+ /// platforms.
274+ static func whenApple( _ isApple: Bool = true ) -> Self {
275+ if isApple {
276+ . when( platforms: [ . macOS, . iOS, . macCatalyst, . watchOS, . tvOS, . visionOS] )
277+ } else {
278+ . when( platforms: [ . linux, . custom( " freebsd " ) , . openbsd, . windows, . wasi, . android] )
279+ }
280+ }
266281}
267282
268283extension Array where Element == PackageDescription . SwiftSetting {
@@ -312,13 +327,14 @@ extension Array where Element == PackageDescription.SwiftSetting {
312327 // executable rather than a library.
313328 . define( " SWT_NO_LIBRARY_MACRO_PLUGINS " ) ,
314329
315- . define( " SWT_TARGET_OS_APPLE " , . when ( platforms : [ . macOS , . iOS , . macCatalyst , . watchOS , . tvOS , . visionOS ] ) ) ,
330+ . define( " SWT_TARGET_OS_APPLE " , . whenApple ( ) ) ,
316331
317332 . define( " SWT_NO_EXIT_TESTS " , . whenEmbedded( or: . when( platforms: [ . iOS, . watchOS, . tvOS, . visionOS, . wasi, . android] ) ) ) ,
318333 . define( " SWT_NO_PROCESS_SPAWNING " , . whenEmbedded( or: . when( platforms: [ . iOS, . watchOS, . tvOS, . visionOS, . wasi, . android] ) ) ) ,
319- . define( " SWT_NO_SNAPSHOT_TYPES " , . whenEmbedded( or: . when ( platforms : [ . linux , . custom ( " freebsd " ) , . openbsd , . windows , . wasi , . android ] ) ) ) ,
334+ . define( " SWT_NO_SNAPSHOT_TYPES " , . whenEmbedded( or: . whenApple ( false ) ) ) ,
320335 . define( " SWT_NO_DYNAMIC_LINKING " , . whenEmbedded( or: . when( platforms: [ . wasi] ) ) ) ,
321336 . define( " SWT_NO_PIPES " , . whenEmbedded( or: . when( platforms: [ . wasi] ) ) ) ,
337+ . define( " SWT_NO_FOUNDATION_FILE_COORDINATION " , . whenEmbedded( or: . whenApple( false ) ) ) ,
322338
323339 . define( " SWT_NO_LEGACY_TEST_DISCOVERY " , . whenEmbedded( ) ) ,
324340 . define( " SWT_NO_LIBDISPATCH " , . whenEmbedded( ) ) ,
@@ -354,20 +370,16 @@ extension Array where Element == PackageDescription.SwiftSetting {
354370 ]
355371 }
356372
357- /// Create a Swift setting which enables Library Evolution, optionally
358- /// constraining it to only Apple platforms.
373+ /// Create a Swift setting which enables Library Evolution.
359374 ///
360375 /// - Parameters:
361- /// - applePlatformsOnly: Whether to constrain this setting to only Apple
362- /// platforms.
363- static func enableLibraryEvolution( applePlatformsOnly: Bool = false ) -> Self {
376+ /// - condition: A build setting condition to apply to this setting.
377+ ///
378+ /// - Returns: A Swift setting that enables Library Evolution.
379+ static func enableLibraryEvolution( _ condition: BuildSettingCondition ? = nil ) -> Self {
364380 var result = [ PackageDescription . SwiftSetting] ( )
365381
366382 if buildingForDevelopment {
367- var condition : BuildSettingCondition ?
368- if applePlatformsOnly {
369- condition = . when( platforms: [ . macOS, . iOS, . macCatalyst, . watchOS, . tvOS, . visionOS] )
370- }
371383 result. append ( . unsafeFlags( [ " -enable-library-evolution " ] , condition) )
372384 }
373385
@@ -410,9 +422,10 @@ extension Array where Element == PackageDescription.CXXSetting {
410422 result += [
411423 . define( " SWT_NO_EXIT_TESTS " , . whenEmbedded( or: . when( platforms: [ . iOS, . watchOS, . tvOS, . visionOS, . wasi, . android] ) ) ) ,
412424 . define( " SWT_NO_PROCESS_SPAWNING " , . whenEmbedded( or: . when( platforms: [ . iOS, . watchOS, . tvOS, . visionOS, . wasi, . android] ) ) ) ,
413- . define( " SWT_NO_SNAPSHOT_TYPES " , . whenEmbedded( or: . when ( platforms : [ . linux , . custom ( " freebsd " ) , . openbsd , . windows , . wasi , . android ] ) ) ) ,
425+ . define( " SWT_NO_SNAPSHOT_TYPES " , . whenEmbedded( or: . whenApple ( false ) ) ) ,
414426 . define( " SWT_NO_DYNAMIC_LINKING " , . whenEmbedded( or: . when( platforms: [ . wasi] ) ) ) ,
415427 . define( " SWT_NO_PIPES " , . whenEmbedded( or: . when( platforms: [ . wasi] ) ) ) ,
428+ . define( " SWT_NO_FOUNDATION_FILE_COORDINATION " , . whenEmbedded( or: . whenApple( false ) ) ) ,
416429
417430 . define( " SWT_NO_LEGACY_TEST_DISCOVERY " , . whenEmbedded( ) ) ,
418431 . define( " SWT_NO_LIBDISPATCH " , . whenEmbedded( ) ) ,
0 commit comments