Skip to content

Commit 2ebfc75

Browse files
Apply standard Swift package configuration (#389)
1 parent 8894f14 commit 2ebfc75

File tree

5 files changed

+49
-18
lines changed

5 files changed

+49
-18
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ 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",:)
6969

7070
.PHONY: site
7171
site: target ?= Layout

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
@@ -58,17 +58,28 @@ let package = Package(
5858

5959
package.targets.forEach { target in
6060

61-
// TODO: Remove upon enabling Swift 6 language mode:
61+
let types: [Target.TargetType] = [
62+
.regular,
63+
.test,
64+
.executable,
65+
.plugin,
66+
.macro,
67+
]
68+
69+
guard types.contains(target.type)
70+
else { return }
71+
6272
target.swiftSettings = (target.swiftSettings ?? []) + [.enableExperimentalFeature("StrictConcurrency")]
6373

64-
if treatWarningsAsErrors {
65-
target.swiftSettings = (target.swiftSettings ?? []) + [
66-
// TODO: Remove unsafe flag upon upgrading to Swift tools v6.2 and uncomment subsequent settings:
67-
.unsafeFlags(["-warnings-as-errors"]),
74+
// if treatWarningsAsErrors {
75+
// target.swiftSettings = (target.swiftSettings ?? []) + [
6876
// .treatAllWarnings(as: .error),
6977
// .treatWarning("DeprecatedDeclaration", as: .warning),
70-
]
71-
}
78+
// ]
79+
// }
80+
81+
guard target.type != .macro
82+
else { return }
7283

7384
if enableSwiftLintBuildToolPlugin {
7485
target.plugins = (target.plugins ?? []) + [

Sources/Layout/Builders/ConstraintsBuilder.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ public enum ConstraintsBuilder {
5656
/// https://docs.swift.org/swift-book/documentation/the-swift-programming-language/attributes/#resultBuilder
5757
/// ) for more information.
5858
public static func buildBlock(_ components: Component...) -> Component {
59+
#if swift(>=6.0)
5960
components.flatMap(\.self)
61+
#else
62+
// swiftlint:disable:next prefer_key_path
63+
components.flatMap { $0 }
64+
#endif
6065
}
6166

6267
/// See result builder [documentation](
@@ -84,7 +89,12 @@ public enum ConstraintsBuilder {
8489
/// https://docs.swift.org/swift-book/documentation/the-swift-programming-language/attributes/#resultBuilder
8590
/// ) for more information.
8691
public static func buildArray(_ components: [Component]) -> Component {
92+
#if swift(>=6.0)
8793
components.flatMap(\.self)
94+
#else
95+
// swiftlint:disable:next prefer_key_path
96+
components.flatMap { $0 }
97+
#endif
8898
}
8999

90100
/// See result builder [documentation](

Sources/Layout/Builders/LayoutBuilder.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ public enum LayoutBuilder {
5454
/// https://docs.swift.org/swift-book/documentation/the-swift-programming-language/attributes/#resultBuilder
5555
/// ) for more information.
5656
public static func buildBlock(_ components: Component...) -> Component {
57+
#if swift(>=6.0)
5758
components.flatMap(\.self)
59+
#else
60+
// swiftlint:disable:next prefer_key_path
61+
components.flatMap { $0 }
62+
#endif
5863
}
5964

6065
/// See result builder [documentation](
@@ -82,7 +87,12 @@ public enum LayoutBuilder {
8287
/// https://docs.swift.org/swift-book/documentation/the-swift-programming-language/attributes/#resultBuilder
8388
/// ) for more information.
8489
public static func buildArray(_ components: [Component]) -> Component {
90+
#if swift(>=6.0)
8591
components.flatMap(\.self)
92+
#else
93+
// swiftlint:disable:next prefer_key_path
94+
components.flatMap { $0 }
95+
#endif
8696
}
8797

8898
/// See result builder [documentation](

0 commit comments

Comments
 (0)