Files
XcodeGen/Sources/ProjectSpec/ProjectExtensions.swift
T
2017-09-14 21:28:09 +02:00

61 lines
1.4 KiB
Swift

//
// ProjectExtensions.swift
// XcodeGen
//
// Created by Yonas Kolb on 19/7/17.
//
//
import Foundation
import xcodeproj
import PathKit
extension Dictionary where Key == String, Value: Any {
public func merged(_ dictionary: [Key: Value]) -> [Key: Value] {
var mergedDictionary = self
mergedDictionary.merge(dictionary)
return mergedDictionary
}
public mutating func merge(_ dictionary: [Key: Value]) {
for (key, value) in dictionary {
self[key] = value
}
}
public func equals(_ dictionary: BuildSettings) -> Bool {
return NSDictionary(dictionary: self).isEqual(to: dictionary)
}
}
public func +=(lhs: inout BuildSettings, rhs: BuildSettings?) {
guard let rhs = rhs else { return }
lhs.merge(rhs)
}
extension PBXProductType {
init?(string: String) {
if let type = PBXProductType(rawValue: string) {
self = type
} else if let type = PBXProductType(rawValue: "com.apple.product-type.\(string)") {
self = type
} else {
return nil
}
}
public var isExtension: Bool {
return fileExtension == "appex"
}
public var isApp: Bool {
return fileExtension == "app"
}
public var name: String {
return rawValue.replacingOccurrences(of: "com.apple.product-type.", with: "")
}
}