only write plists if file has changed

This commit is contained in:
Yonas Kolb 2018-10-30 22:18:30 +11:00
parent 3d87c61342
commit 0cf2ca9fa0

View File

@ -43,6 +43,11 @@ public class ProjectWriter {
private func writePlist(_ plist: [String: Any], path: String) throws {
let path = project.basePath + path
if path.exists, let data: Data = try? path.read(),
let existingPlist = (try? PropertyListSerialization.propertyList(from: data, format: nil)) as? [String: Any], NSDictionary(dictionary: plist).isEqual(to: existingPlist) {
// file is the same
return
}
let data = try PropertyListSerialization.data(fromPropertyList: plist, format: .xml, options: 0)
try? path.delete()
try path.parent().mkpath()