From 6c566c3de402663d3f783289582a13b9360bd36a Mon Sep 17 00:00:00 2001 From: Daniil Subbotin Date: Fri, 9 Feb 2024 20:43:54 +0300 Subject: [PATCH] Fixed Contents.json formatting (#231) Closes #225 --- .../Model/XcodeExportExtensions.swift | 2 +- Sources/XcodeExport/XcodeColorExporter.swift | 2 +- .../XcodeIconsExporterTests.swift | 24 +++++++++---------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Sources/XcodeExport/Model/XcodeExportExtensions.swift b/Sources/XcodeExport/Model/XcodeExportExtensions.swift index 24142c0b..1ab3d95b 100644 --- a/Sources/XcodeExport/Model/XcodeExportExtensions.swift +++ b/Sources/XcodeExport/Model/XcodeExportExtensions.swift @@ -49,7 +49,7 @@ extension XcodeAssetContents { func makeFileContents(to directory: URL) throws -> FileContents { let encoder = JSONEncoder() - encoder.outputFormatting = .prettyPrinted + encoder.outputFormatting = [.prettyPrinted, .sortedKeys] let data = try encoder.encode(self) let fileURL = URL(string: "Contents.json")! diff --git a/Sources/XcodeExport/XcodeColorExporter.swift b/Sources/XcodeExport/XcodeColorExporter.swift index f8d2b80c..b9da3038 100644 --- a/Sources/XcodeExport/XcodeColorExporter.swift +++ b/Sources/XcodeExport/XcodeColorExporter.swift @@ -219,7 +219,7 @@ final public class XcodeColorExporter: XcodeExporterBase { private func makeXcodeAssetFileContents(contents: XcodeAssetContents, directory: URL) throws -> FileContents { let encoder = JSONEncoder() - encoder.outputFormatting = .prettyPrinted + encoder.outputFormatting = [.prettyPrinted, .sortedKeys] let data = try encoder.encode(contents) let fileURL = URL(string: "Contents.json")! return FileContents( diff --git a/Tests/XcodeExportTests/XcodeIconsExporterTests.swift b/Tests/XcodeExportTests/XcodeIconsExporterTests.swift index c32be6a4..64ba1440 100644 --- a/Tests/XcodeExportTests/XcodeIconsExporterTests.swift +++ b/Tests/XcodeExportTests/XcodeIconsExporterTests.swift @@ -667,17 +667,17 @@ final class XcodeIconsExporterTests: XCTestCase { { "images" : [ { - "idiom" : "universal", - "filename" : "ic24TabBarHome.pdf" + "filename" : "ic24TabBarHome.pdf", + "idiom" : "universal" } ], "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 }, "properties" : { - "template-rendering-intent" : "template", - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } """ @@ -711,17 +711,17 @@ final class XcodeIconsExporterTests: XCTestCase { { "images" : [ { - "idiom" : "universal", - "filename" : "ic24TabBarHome.pdf" + "filename" : "ic24TabBarHome.pdf", + "idiom" : "universal" } ], "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 }, "properties" : { - "template-rendering-intent" : "template", - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } """