From 49fab9903c809dab299ba6bc5f896fa0428c23cf Mon Sep 17 00:00:00 2001 From: Daniil Subbotin Date: Wed, 24 Jan 2024 23:17:54 +0300 Subject: [PATCH] Fixed Contents.json formatting (#230) Closes #225 --- .github/workflows/release.yml | 4 ++-- .github/workflows/tests.yml | 4 ++-- .../Model/XcodeExportExtensions.swift | 2 +- Sources/XcodeExport/XcodeColorExporter.swift | 2 +- .../XcodeIconsExporterTests.swift | 24 +++++++++---------- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c9d7787..8766009 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,13 +8,13 @@ on: jobs: release: name: Publish GitHub and Cocoapods release - runs-on: macos-12 + runs-on: macos-13 steps: - name: Checkout uses: actions/checkout@v2 - name: Select Xcode version - run: sudo xcode-select --switch /Applications/Xcode_14.1.app + run: sudo xcode-select --switch /Applications/Xcode_15.2.app - name: Build run: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ac1ea6b..b6eec04 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,12 +14,12 @@ on: jobs: test: name: Run tests on macOS - runs-on: macos-12 + runs-on: macos-13 steps: - name: Checkout uses: actions/checkout@v2 - name: Select Xcode version - run: sudo xcode-select --switch /Applications/Xcode_14.1.app + run: sudo xcode-select --switch /Applications/Xcode_15.2.app - name: Build and test run: swift test --enable-code-coverage --disable-automatic-resolution shell: bash diff --git a/Sources/XcodeExport/Model/XcodeExportExtensions.swift b/Sources/XcodeExport/Model/XcodeExportExtensions.swift index 24142c0..1ab3d95 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 f8d2b80..b9da303 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 c32be6a..64ba144 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" } } """