Files
XcodeGen/Sources/ProjectSpec/BuildToolPlugin.swift
T
BarredEwe d8d5457f48 Add support for adding build tool plugins to targets (#1374)
* Add support for adding build tool plugins to targets

* Added Plugin validation

* Added some tests

* Limited the minimum version to 5.7 Swift

* Update .gitignore

Co-authored-by: freddi(Yuki Aki) <freddi-kit@users.noreply.github.com>

* Update CHANGELOG.md

Co-authored-by: freddi(Yuki Aki) <freddi-kit@users.noreply.github.com>

* Update CHANGELOG.md

Co-authored-by: freddi(Yuki Aki) <freddi-kit@users.noreply.github.com>

* Update Docs/ProjectSpec.md

Co-authored-by: freddi(Yuki Aki) <freddi-kit@users.noreply.github.com>

* Added a fixture for testing plugins

* Update CHANGELOG.md

* Installed the release version of XcodeProj

---------

Co-authored-by: freddi(Yuki Aki) <freddi-kit@users.noreply.github.com>
2023-08-16 22:22:16 +10:00

59 lines
1.4 KiB
Swift

import Foundation
import JSONUtilities
/// Specifies the use of a plug-in product in a target.
public struct BuildToolPlugin: Equatable {
/// The name of the plug-in target.
public var plugin: String
/// The name of the package that defines the plug-in target.
public var package: String
public init(
plugin: String,
package: String
) {
self.plugin = plugin
self.package = package
}
}
extension BuildToolPlugin: JSONObjectConvertible {
public init(jsonDictionary: JSONDictionary) throws {
if let plugin: String = jsonDictionary.json(atKeyPath: "plugin") {
self.plugin = plugin
} else {
throw SpecParsingError.invalidDependency(jsonDictionary)
}
if let package: String = jsonDictionary.json(atKeyPath: "package") {
self.package = package
} else {
throw SpecParsingError.invalidDependency(jsonDictionary)
}
}
}
extension BuildToolPlugin {
public var uniqueID: String {
return "\(plugin)/\(package)"
}
}
extension BuildToolPlugin: Hashable {
public func hash(into hasher: inout Hasher) {
hasher.combine(plugin)
hasher.combine(package)
}
}
extension BuildToolPlugin: JSONEncodable {
public func toJSONValue() -> Any {
[
"plugin": plugin,
"package": package
]
}
}