Skip to content

Commit f12f9aa

Browse files
Apply standard Swift package configuration (#19)
* Apply standard Swift package configuration * Use key path in Swift 6 and above * Apply standard Swift package configuration
1 parent d42387e commit f12f9aa

File tree

4 files changed

+39
-18
lines changed

4 files changed

+39
-18
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ docs:
6060
-destination "$(destination)" \
6161
-derivedDataPath "$(DERIVED_DATA_PATH)" \
6262
-skipPackagePluginValidation \
63-
OTHER_DOCC_FLAGS="--warnings-as-errors"
63+
$(if $(filter $(open),OPEN),OTHER_DOCC_FLAGS="--warnings-as-errors",)
6464
@find "$(DERIVED_DATA_PATH)" \
6565
-type d \
6666
-name "$(target).doccarchive" \
6767
-exec cp -R {} "$(ARCHIVE_PATH)/" \;
68-
$(if $(filter $(open),OPEN),@open "$(ARCHIVE_PATH)/$(target).doccarchive",)
68+
@$(if $(filter $(open),OPEN),open "$(ARCHIVE_PATH)/$(target).doccarchive",:)

Package.resolved

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,28 @@ let package = Package(
4141

4242
package.targets.forEach { target in
4343

44-
// TODO: Remove upon enabling Swift 6 language mode:
44+
let types: [Target.TargetType] = [
45+
.regular,
46+
.test,
47+
.executable,
48+
.plugin,
49+
.macro,
50+
]
51+
52+
guard types.contains(target.type)
53+
else { return }
54+
4555
target.swiftSettings = (target.swiftSettings ?? []) + [.enableExperimentalFeature("StrictConcurrency")]
4656

47-
if treatWarningsAsErrors {
48-
target.swiftSettings = (target.swiftSettings ?? []) + [
49-
// TODO: Remove unsafe flag upon upgrading to Swift tools v6.2 and uncomment subsequent settings:
50-
.unsafeFlags(["-warnings-as-errors"]),
57+
// if treatWarningsAsErrors {
58+
// target.swiftSettings = (target.swiftSettings ?? []) + [
5159
// .treatAllWarnings(as: .error),
5260
// .treatWarning("DeprecatedDeclaration", as: .warning),
53-
]
54-
}
61+
// ]
62+
// }
63+
64+
guard target.type != .macro
65+
else { return }
5566

5667
if enableSwiftLintBuildToolPlugin {
5768
target.plugins = (target.plugins ?? []) + [

Sources/CollectionBuilders/Array.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ extension Array {
3434
}
3535

3636
public static func buildBlock(_ components: Component...) -> Component {
37+
#if swift(>=6.0)
3738
components.flatMap(\.self)
39+
#else
40+
// swiftlint:disable:next prefer_key_path
41+
components.flatMap { $0 }
42+
#endif
3843
}
3944

4045
public static func buildOptional(_ component: Component?) -> Component {
@@ -50,7 +55,12 @@ extension Array {
5055
}
5156

5257
public static func buildArray(_ components: [Component]) -> Component {
58+
#if swift(>=6.0)
5359
components.flatMap(\.self)
60+
#else
61+
// swiftlint:disable:next prefer_key_path
62+
components.flatMap { $0 }
63+
#endif
5464
}
5565

5666
public static func buildLimitedAvailability(_ component: Component) -> Component {

0 commit comments

Comments
 (0)