From ca5ad9bf1438828e536ffa57ee2a14b900489d46 Mon Sep 17 00:00:00 2001 From: Yonas Kolb Date: Sat, 3 Nov 2018 19:29:52 +1100 Subject: [PATCH] use json for serialization --- Sources/XcodeGen/main.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Sources/XcodeGen/main.swift b/Sources/XcodeGen/main.swift index f2f40185..86399942 100644 --- a/Sources/XcodeGen/main.swift +++ b/Sources/XcodeGen/main.swift @@ -44,7 +44,8 @@ func generate(spec: String, project: String, lockfile: String, isQuiet: Bool, ju // Lock file var lockFileContent: String = "" let lockFilePath = lockfile.isEmpty ? nil : Path(lockfile) - if let lockFilePath = lockFilePath { + if #available(OSX 10.13, *), let lockFilePath = lockFilePath { + // JSONSerialization.WritingOptions.sortedKeys is only available on 10.13 let files = Array(Set(project.allFiles)) .map { $0.byRemovingBase(path: project.basePath).string } @@ -53,10 +54,10 @@ func generate(spec: String, project: String, lockfile: String, isQuiet: Bool, ju let spec: String do { - let node = try Node(projectDictionary) - spec = try Yams.serialize(node: node) + let data = try JSONSerialization.data(withJSONObject: projectDictionary, options: [.sortedKeys, .prettyPrinted]) + spec = String(data: data, encoding: .utf8)! } catch { - fatalError("Couldn't serialize spec for lockfile") + fatalError("Couldn't serialize spec for lockfile\n\(error)") } lockFileContent = """