Skip to content

Commit 4559d27

Browse files
authored
Clean up manifest APIs (#6175)
- add missing availability annotations - remove use of get/set pattern that doesn't seem to useful anymore - fix visibility issues - update use of enums This change is technically source breaking, however there are no ABI concerns here and any removed symbols were clearly SPI.
1 parent 73c2a92 commit 4559d27

File tree

6 files changed

+128
-176
lines changed

6 files changed

+128
-176
lines changed

Sources/PackageDescription/BuildSettings.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public struct CSetting {
132132
/// - Parameters:
133133
/// - path: The path of the directory that contains the headers. The path is relative to the target's directory.
134134
/// - condition: A condition that restricts the application of the build setting.
135+
@available(_PackageDescription, introduced: 5.0)
135136
public static func headerSearchPath(_ path: String, _ condition: BuildSettingCondition? = nil) -> CSetting {
136137
return CSetting(name: "headerSearchPath", value: [path], condition: condition)
137138
}
@@ -147,6 +148,7 @@ public struct CSetting {
147148
/// - value: The value of the macro.
148149
/// - condition: A condition that restricts the application of the build
149150
/// setting.
151+
@available(_PackageDescription, introduced: 5.0)
150152
public static func define(_ name: String, to value: String? = nil, _ condition: BuildSettingCondition? = nil) -> CSetting {
151153
var settingValue = name
152154
if let value = value {
@@ -172,6 +174,7 @@ public struct CSetting {
172174
/// - flags: The unsafe flags to set.
173175
/// - condition: A condition that restricts the application of the build
174176
/// setting.
177+
@available(_PackageDescription, introduced: 5.0)
175178
public static func unsafeFlags(_ flags: [String], _ condition: BuildSettingCondition? = nil) -> CSetting {
176179
return CSetting(name: "unsafeFlags", value: flags, condition: condition)
177180
}
@@ -198,6 +201,7 @@ public struct CXXSetting {
198201
/// - Parameters:
199202
/// - path: The path of the directory that contains the headers. The path is
200203
/// - condition: A condition that restricts the application of the build setting.
204+
@available(_PackageDescription, introduced: 5.0)
201205
public static func headerSearchPath(_ path: String, _ condition: BuildSettingCondition? = nil) -> CXXSetting {
202206
return CXXSetting(name: "headerSearchPath", value: [path], condition: condition)
203207
}
@@ -213,6 +217,7 @@ public struct CXXSetting {
213217
/// - value: The value of the macro.
214218
/// - condition: A condition that restricts the application of the build
215219
/// setting.
220+
@available(_PackageDescription, introduced: 5.0)
216221
public static func define(_ name: String, to value: String? = nil, _ condition: BuildSettingCondition? = nil) -> CXXSetting {
217222
var settingValue = name
218223
if let value = value {
@@ -237,6 +242,7 @@ public struct CXXSetting {
237242
/// - flags: The unsafe flags to set.
238243
/// - condition: A condition that restricts the application of the build
239244
/// setting.
245+
@available(_PackageDescription, introduced: 5.0)
240246
public static func unsafeFlags(_ flags: [String], _ condition: BuildSettingCondition? = nil) -> CXXSetting {
241247
return CXXSetting(name: "unsafeFlags", value: flags, condition: condition)
242248
}
@@ -271,6 +277,7 @@ public struct SwiftSetting {
271277
/// - name: The name of the macro.
272278
/// - condition: A condition that restricts the application of the build
273279
/// setting.
280+
@available(_PackageDescription, introduced: 5.0)
274281
public static func define(_ name: String, _ condition: BuildSettingCondition? = nil) -> SwiftSetting {
275282
return SwiftSetting(name: "define", value: [name], condition: condition)
276283
}
@@ -292,6 +299,7 @@ public struct SwiftSetting {
292299
/// - flags: The unsafe flags to set.
293300
/// - condition: A condition that restricts the application of the build
294301
/// setting.
302+
@available(_PackageDescription, introduced: 5.0)
295303
public static func unsafeFlags(_ flags: [String], _ condition: BuildSettingCondition? = nil) -> SwiftSetting {
296304
return SwiftSetting(name: "unsafeFlags", value: flags, condition: condition)
297305
}
@@ -365,6 +373,7 @@ public struct LinkerSetting {
365373
/// - library: The library name.
366374
/// - condition: A condition that restricts the application of the build
367375
/// setting.
376+
@available(_PackageDescription, introduced: 5.0)
368377
public static func linkedLibrary(_ library: String, _ condition: BuildSettingCondition? = nil) -> LinkerSetting {
369378
return LinkerSetting(name: "linkedLibrary", value: [library], condition: condition)
370379
}
@@ -380,6 +389,7 @@ public struct LinkerSetting {
380389
/// - framework: The framework name.
381390
/// - condition: A condition that restricts the application of the build
382391
/// setting.
392+
@available(_PackageDescription, introduced: 5.0)
383393
public static func linkedFramework(_ framework: String, _ condition: BuildSettingCondition? = nil) -> LinkerSetting {
384394
return LinkerSetting(name: "linkedFramework", value: [framework], condition: condition)
385395
}
@@ -401,6 +411,7 @@ public struct LinkerSetting {
401411
/// - flags: The unsafe flags to set.
402412
/// - condition: A condition that restricts the application of the build
403413
/// setting.
414+
@available(_PackageDescription, introduced: 5.0)
404415
public static func unsafeFlags(_ flags: [String], _ condition: BuildSettingCondition? = nil) -> LinkerSetting {
405416
return LinkerSetting(name: "unsafeFlags", value: flags, condition: condition)
406417
}

Sources/PackageDescription/PackageDescription.swift

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,11 @@ public final class Package {
8383

8484
/// The list of minimum versions for platforms supported by the package.
8585
@available(_PackageDescription, introduced: 5)
86-
public var platforms: [SupportedPlatform]? {
87-
get { return _platforms }
88-
set { _platforms = newValue }
89-
}
90-
private var _platforms: [SupportedPlatform]?
86+
public var platforms: [SupportedPlatform]?
9187

9288
/// The default localization for resources.
9389
@available(_PackageDescription, introduced: 5.3)
94-
public var defaultLocalization: LanguageTag? {
95-
get { return _defaultLocalization }
96-
set { _defaultLocalization = newValue }
97-
}
98-
private var _defaultLocalization: LanguageTag?
90+
public var defaultLocalization: LanguageTag?
9991

10092
/// The name to use for C modules.
10193
///
@@ -230,7 +222,7 @@ public final class Package {
230222
cxxLanguageStandard: CXXLanguageStandard? = nil
231223
) {
232224
self.name = name
233-
self._platforms = platforms
225+
self.platforms = platforms
234226
self.pkgConfig = pkgConfig
235227
self.providers = providers
236228
self.products = products
@@ -272,8 +264,8 @@ public final class Package {
272264
cxxLanguageStandard: CXXLanguageStandard? = nil
273265
) {
274266
self.name = name
275-
self._defaultLocalization = defaultLocalization
276-
self._platforms = platforms
267+
self.defaultLocalization = defaultLocalization
268+
self.platforms = platforms
277269
self.pkgConfig = pkgConfig
278270
self.providers = providers
279271
self.products = products
@@ -324,12 +316,12 @@ public final class Package {
324316
public struct LanguageTag: Hashable {
325317

326318
/// An IETF language tag.
327-
public let tag: String
319+
let tag: String
328320

329321
/// Creates a language tag from its IETF string representation.
330322
///
331323
/// - Parameter tag: The string representation of an IETF language tag.
332-
public init(_ tag: String) {
324+
private init(_ tag: String) {
333325
self.tag = tag
334326
}
335327
}
@@ -437,7 +429,7 @@ public enum SystemPackageProvider {
437429

438430
// MARK: - Package Dumping
439431

440-
func manifestToJSON(_ package: Package) -> String {
432+
private func manifestToJSON(_ package: Package) -> String {
441433
struct Output: Codable {
442434
let package: Serialization.Package
443435
let errors: [String]

Sources/PackageDescription/PackageDescriptionSerializationConversion.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,27 +222,27 @@ extension Serialization.TargetType {
222222
extension Serialization.PluginCapability {
223223
init(_ capability: PackageDescription.Target.PluginCapability) {
224224
switch capability {
225-
case ._buildTool: self = .buildTool
226-
case ._command(let intent, let permissions): self = .command(intent: .init(intent), permissions: permissions.map { .init($0) })
225+
case .buildTool: self = .buildTool
226+
case .command(let intent, let permissions): self = .command(intent: .init(intent), permissions: permissions.map { .init($0) })
227227
}
228228
}
229229
}
230230

231231
extension Serialization.PluginCommandIntent {
232232
init(_ intent: PackageDescription.PluginCommandIntent) {
233233
switch intent {
234-
case ._custom(let verb, let description): self = .custom(verb: verb, description: description)
235-
case ._sourceCodeFormatting: self = .sourceCodeFormatting
236-
case ._documentationGeneration: self = .documentationGeneration
234+
case .custom(let verb, let description): self = .custom(verb: verb, description: description)
235+
case .sourceCodeFormatting: self = .sourceCodeFormatting
236+
case .documentationGeneration: self = .documentationGeneration
237237
}
238238
}
239239
}
240240

241241
extension Serialization.PluginPermission {
242242
init(_ permission: PackageDescription.PluginPermission) {
243243
switch permission {
244-
case ._allowNetworkConnections(let scope, let reason): self = .allowNetworkConnections(scope: .init(scope), reason: reason)
245-
case ._writeToPackageDirectory(let reason): self = .writeToPackageDirectory(reason: reason)
244+
case .allowNetworkConnections(let scope, let reason): self = .allowNetworkConnections(scope: .init(scope), reason: reason)
245+
case .writeToPackageDirectory(let reason): self = .writeToPackageDirectory(reason: reason)
246246
}
247247
}
248248
}
@@ -262,7 +262,7 @@ extension Serialization.PluginNetworkPermissionScope {
262262
extension Serialization.PluginUsage {
263263
init(_ usage: PackageDescription.Target.PluginUsage) {
264264
switch usage {
265-
case ._pluginItem(let name, let package): self = .plugin(name: name, package: package)
265+
case .plugin(let name, let package): self = .plugin(name: name, package: package)
266266
}
267267
}
268268
}

Sources/PackageDescription/Product.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public class Product {
8282
/// The library product of a Swift package.
8383
public final class Library: Product {
8484
/// The different types of a library product.
85-
public enum LibraryType: String, Encodable {
85+
public enum LibraryType: String {
8686
/// A statically linked library.
8787
case `static`
8888
/// A dynamically linked library.

Sources/PackageDescription/Resource.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
///
3333
/// To learn more about package resources, see
3434
/// <doc:bundling-resources-with-a-swift-package>.
35+
@available(_PackageDescription, introduced: 5.3)
3536
public struct Resource {
3637

3738
/// Defines the explicit type of localization for resources.

0 commit comments

Comments
 (0)