// // ProjectExtensions.swift // XcodeGen // // Created by Yonas Kolb on 19/7/17. // // import Foundation import xcproj 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: "") } } extension Platform { public var emoji: String { switch self { case .iOS: return "📱" case .watchOS: return "⌚️" case .tvOS: return "📺" case .macOS: return "🖥" } } }