From ae8ba18c16acc9414c79e3ec69c3d238d8491988 Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Tue, 25 Nov 2025 18:19:15 +0000 Subject: [PATCH 1/4] Use binary parsing fork --- Package.resolved | 4 ++-- Package.swift | 4 ++-- README.md | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Package.resolved b/Package.resolved index 4e7fc7c..1a436e4 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,10 +1,10 @@ { - "originHash" : "9238a5eff43ac33dc7a148b7c3163fffc867bb0cb4bc7d811ac286cc2c3118d4", + "originHash" : "c6efe50626096d7a88b43a6407659792896790a0139e87f92ae1600957fb541f", "pins" : [ { "identity" : "swift-binary-parsing", "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-binary-parsing", + "location" : "https://github.com/FlickerSoul/swift-binary-parsing", "state" : { "branch" : "main", "revision" : "13532cf777cbd2e112954ccc9ada37edb06fe84a" diff --git a/Package.swift b/Package.swift index 51ec824..ec242ae 100644 --- a/Package.swift +++ b/Package.swift @@ -6,7 +6,7 @@ import PackageDescription let package = Package( name: "BinaryParseKit", - platforms: [.macOS(.v15), .iOS(.v18), .watchOS(.v11), .tvOS(.v18), .visionOS(.v2)], + platforms: [.macOS(.v13), .iOS(.v16), .watchOS(.v9), .tvOS(.v16), .visionOS(.v1)], products: [ // Products define the executables and libraries a package produces, making them visible to other packages. .library( @@ -20,7 +20,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/swiftlang/swift-syntax.git", .upToNextMajor(from: "602.0.0")), - .package(url: "https://github.com/apple/swift-binary-parsing", branch: "main"), + .package(url: "https://github.com/FlickerSoul/swift-binary-parsing", branch: "main"), .package( url: "https://github.com/apple/swift-collections.git", .upToNextMinor(from: "1.1.0"), diff --git a/README.md b/README.md index 853bc49..b4f2242 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FFlickerSoul%2FBinaryParseKit%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/FlickerSoul/BinaryParseKit) [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FFlickerSoul%2FBinaryParseKit%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/FlickerSoul/BinaryParseKit) -A declarative Swift package for parsing binary data using macros, built on top of Apple's [`swift-binary-parsing`](https://github.com/apple/swift-binary-parsing) framework. +A declarative Swift package for parsing binary data using macros, built on top of Apple's [`swift-binary-parsing`](https://github.com/apple/swift-binary-parsing) framework (a [fork](https://github.com/FlickerSoul/swift-binary-parsing), actually, that lowers the platform version so parsing can be brought to lower platform OS). > [!IMPORTANT] > Warning: This package is currently under active development and its APIs are subjected to drastic changes. From 5692f19f21da0791a114ed137ae915716f960567 Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Tue, 25 Nov 2025 18:33:28 +0000 Subject: [PATCH 2/4] Fix version guard --- Sources/BinaryParseKit/Printer/PrintableExtensions.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/BinaryParseKit/Printer/PrintableExtensions.swift b/Sources/BinaryParseKit/Printer/PrintableExtensions.swift index ddd7cfe..7314951 100644 --- a/Sources/BinaryParseKit/Printer/PrintableExtensions.swift +++ b/Sources/BinaryParseKit/Printer/PrintableExtensions.swift @@ -29,6 +29,7 @@ extension UInt16: Printable {} extension UInt32: Printable {} extension UInt: Printable {} extension UInt64: Printable {} +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) extension UInt128: Printable {} extension Int8: Printable {} @@ -36,6 +37,7 @@ extension Int16: Printable {} extension Int32: Printable {} extension Int: Printable {} extension Int64: Printable {} +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) extension Int128: Printable {} // MARK: - Floating Point From 44aff9dc0bacf9ce0ee17dd8a571c7c6334683e5 Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Tue, 25 Nov 2025 19:08:11 +0000 Subject: [PATCH 3/4] Fix dep lock --- Package.resolved | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.resolved b/Package.resolved index 1a436e4..fc60154 100644 --- a/Package.resolved +++ b/Package.resolved @@ -7,7 +7,7 @@ "location" : "https://github.com/FlickerSoul/swift-binary-parsing", "state" : { "branch" : "main", - "revision" : "13532cf777cbd2e112954ccc9ada37edb06fe84a" + "revision" : "ca80b3e940cb0cbcadf13ddc2f7a2a3aaef33a82" } }, { From 2455f16f8c45775f0f0c9827b655f35b92505e9a Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Tue, 25 Nov 2025 19:13:43 +0000 Subject: [PATCH 4/4] Fix tests --- .../TestPrinterIntel.swift | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/Tests/BinaryParseKitTests/TestPrinterIntel.swift b/Tests/BinaryParseKitTests/TestPrinterIntel.swift index 6530777..87a5421 100644 --- a/Tests/BinaryParseKitTests/TestPrinterIntel.swift +++ b/Tests/BinaryParseKitTests/TestPrinterIntel.swift @@ -72,22 +72,24 @@ struct PrinterIntelTest { ) // Int128/UInt128 - #expect( - Int128(bitPattern: 0xDEAD_BEEF_CAFE_BABE_1234_5678_9ABC_DEF0).toBytes(useBigEndian: true) - == [0xDE, 0xAD, 0xBE, 0xEF, 0xCA, 0xFE, 0xBA, 0xBE, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0], - ) - #expect( - Int128(bitPattern: 0xDEAD_BEEF_CAFE_BABE_1234_5678_9ABC_DEF0).toBytes(useBigEndian: false) - == [0xF0, 0xDE, 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, 0xBE, 0xBA, 0xFE, 0xCA, 0xEF, 0xBE, 0xAD, 0xDE], - ) - #expect( - UInt128(0xABAD_CAFE_AAC0_FFEE_1122_3344_5566_7788).toBytes(useBigEndian: true) - == [0xAB, 0xAD, 0xCA, 0xFE, 0xAA, 0xC0, 0xFF, 0xEE, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88], - ) - #expect( - UInt128(0xABAD_CAFE_AAC0_FFEE_1122_3344_5566_7788).toBytes(useBigEndian: false) - == [0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0xEE, 0xFF, 0xC0, 0xAA, 0xFE, 0xCA, 0xAD, 0xAB], - ) + if #available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) { + #expect( + Int128(bitPattern: 0xDEAD_BEEF_CAFE_BABE_1234_5678_9ABC_DEF0).toBytes(useBigEndian: true) + == [0xDE, 0xAD, 0xBE, 0xEF, 0xCA, 0xFE, 0xBA, 0xBE, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0], + ) + #expect( + Int128(bitPattern: 0xDEAD_BEEF_CAFE_BABE_1234_5678_9ABC_DEF0).toBytes(useBigEndian: false) + == [0xF0, 0xDE, 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, 0xBE, 0xBA, 0xFE, 0xCA, 0xEF, 0xBE, 0xAD, 0xDE], + ) + #expect( + UInt128(0xABAD_CAFE_AAC0_FFEE_1122_3344_5566_7788).toBytes(useBigEndian: true) + == [0xAB, 0xAD, 0xCA, 0xFE, 0xAA, 0xC0, 0xFF, 0xEE, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88], + ) + #expect( + UInt128(0xABAD_CAFE_AAC0_FFEE_1122_3344_5566_7788).toBytes(useBigEndian: false) + == [0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0xEE, 0xFF, 0xC0, 0xAA, 0xFE, 0xCA, 0xAD, 0xAB], + ) + } } // MARK: - ParseEnum PrinterIntel Tests