@@ -54,7 +54,8 @@ let package = Package(
5454 . target( name: " Subprocess " )
5555 ]
5656 )
57- ]
57+ ] ,
58+ swiftLanguageVersions: [ . v5, . version( " 6 " ) ]
5859)
5960
6061for target in package . targets {
@@ -65,60 +66,24 @@ for target in package.targets {
6566 // as upcoming features will result in a compiler error. Currently in the
6667 // latest 5.10 compiler this doesn't happen, the compiler ignores it.
6768 //
68- // If the situation does change and enabling default language features
69- // does result in an error in future versions we attempt to guard against
70- // this by using the hasFeature(x) compiler directive to see if we have a
71- // feature already, or if we can enable it. It's safe to enable features
72- // that don't exist in older compiler versions as the compiler will ignore
73- // features it doesn't have implemented.
74-
75- // swift 6
76- #if !hasFeature(ConciseMagicFile)
77- swiftSettings. append ( . enableUpcomingFeature( " ConciseMagicFile " ) )
78- #endif
79-
80- #if !hasFeature(ForwardTrailingClosures)
81- swiftSettings. append ( . enableUpcomingFeature( " ForwardTrailingClosures " ) )
82- #endif
83-
84- #if !hasFeature(StrictConcurrency)
85- swiftSettings. append ( . enableUpcomingFeature( " StrictConcurrency " ) )
86- // StrictConcurrency is under experimental features in Swift <=5.10 contrary to some posts and documentation
87- swiftSettings. append ( . enableExperimentalFeature( " StrictConcurrency " ) )
88- #endif
89-
90- #if !hasFeature(BareSlashRegexLiterals)
91- swiftSettings. append ( . enableUpcomingFeature( " BareSlashRegexLiterals " ) )
92- #endif
93-
94- #if !hasFeature(ImplicitOpenExistentials)
95- swiftSettings. append ( . enableUpcomingFeature( " ImplicitOpenExistentials " ) )
96- #endif
97-
98- #if !hasFeature(ImportObjcForwardDeclarations)
99- swiftSettings. append ( . enableUpcomingFeature( " ImportObjcForwardDeclarations " ) )
100- #endif
101-
102- #if !hasFeature(DisableOutwardActorInference)
103- swiftSettings. append ( . enableUpcomingFeature( " DisableOutwardActorInference " ) )
104- #endif
105-
106- #if !hasFeature(InternalImportsByDefault)
107- swiftSettings. append ( . enableUpcomingFeature( " InternalImportsByDefault " ) )
108- #endif
109-
110- #if !hasFeature(IsolatedDefaultValues)
111- swiftSettings. append ( . enableUpcomingFeature( " IsolatedDefaultValues " ) )
112- #endif
113-
114- #if !hasFeature(GlobalConcurrency)
115- swiftSettings. append ( . enableUpcomingFeature( " GlobalConcurrency " ) )
116- #endif
69+ // The Swift 6 compiler on the other hand does emit errors when features
70+ // are enabled. Unfortunately it appears that the preprocessor
71+ // !hasFeature(xxx) cannot be used to test for this situation nor does
72+ // #if swift(<6) guard against this. There must be some sort of magic
73+ // used that is special for compiling the Package.swift manifest.
74+ // Instead a versioned Package.swift can be used (e.g.
[email protected] )
75+ // and the implemented now default features can be removed in Package.swift.
76+ //
77+ // Or you can just delete the Swift 6 features that are enabled instead of
78+ // creating another manifest file and test to see if building under Swift 5
79+ // still works (it should almost always work).
80+ //
81+ // It's still safe to enable features that don't exist in older compiler
82+ // versions as the compiler will ignore features it doesn't have implemented.
11783
11884 // swift 7
119- #if !hasFeature(ExistentialAny)
12085 swiftSettings. append ( . enableUpcomingFeature( " ExistentialAny " ) )
121- #endif
86+ swiftSettings . append ( . enableUpcomingFeature ( " InternalImportsByDefault " ) )
12287
12388 target. swiftSettings = swiftSettings
12489}
0 commit comments