From a8b6fae20417e86daee79eeb3fad545ee6b478c5 Mon Sep 17 00:00:00 2001 From: Charles Maria Tor <charles.tor@icloud.com> Date: Fri, 18 Feb 2022 13:58:13 +1100 Subject: [PATCH] Lower minimum OS requirements --- .../xcschemes/xcschememanagement.plist | 8 +++---- Package.swift | 4 ++-- Sources/MonadicJSON/JSON.swift | 10 +++++++-- Tests/Info.plist | 22 ------------------- 4 files changed, 14 insertions(+), 30 deletions(-) delete mode 100644 Tests/Info.plist diff --git a/.swiftpm/xcode/xcuserdata/charlie.xcuserdatad/xcschemes/xcschememanagement.plist b/.swiftpm/xcode/xcuserdata/charlie.xcuserdatad/xcschemes/xcschememanagement.plist index dfb602d..d84c2f5 100644 --- a/.swiftpm/xcode/xcuserdata/charlie.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/.swiftpm/xcode/xcuserdata/charlie.xcuserdatad/xcschemes/xcschememanagement.plist @@ -14,21 +14,21 @@ <key>isShown</key> <false/> <key>orderHint</key> - <integer>3</integer> + <integer>2</integer> </dict> <key>Tutorial (Playground) 2.xcscheme</key> <dict> <key>isShown</key> <false/> <key>orderHint</key> - <integer>4</integer> + <integer>3</integer> </dict> <key>Tutorial (Playground) 3.xcscheme</key> <dict> <key>isShown</key> <false/> <key>orderHint</key> - <integer>1</integer> + <integer>4</integer> </dict> <key>Tutorial (Playground) 4.xcscheme</key> <dict> @@ -49,7 +49,7 @@ <key>isShown</key> <false/> <key>orderHint</key> - <integer>2</integer> + <integer>1</integer> </dict> </dict> <key>SuppressBuildableAutocreation</key> diff --git a/Package.swift b/Package.swift index eba20b2..4278bf8 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.5 +// swift-tools-version:5.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription @@ -6,7 +6,7 @@ import PackageDescription let package = Package( name: "MonadicJSON", platforms: [ - .macOS(.v12), .iOS(.v15), .watchOS(.v8), .tvOS(.v15), + .macOS(.v10_10), .iOS(.v8), .watchOS(.v2), .tvOS(.v9), ], products: [ // Products define the executables and libraries produced by a package, and make them visible to other packages. diff --git a/Sources/MonadicJSON/JSON.swift b/Sources/MonadicJSON/JSON.swift index efad7b5..fd6451d 100644 --- a/Sources/MonadicJSON/JSON.swift +++ b/Sources/MonadicJSON/JSON.swift @@ -35,6 +35,9 @@ extension Null: Codable { } } +public struct JSONDecimalError: Error { +} + public indirect enum JSON: Hashable, Codable { case null case string(String) @@ -43,7 +46,7 @@ public indirect enum JSON: Hashable, Codable { case object([String: JSON]) case array([JSON]) - public func encodable() throws -> some Encodable { + public func encodable() throws -> Encodable { func recurse(json: JSON) throws -> AnyEncodable { switch json { case let .object(value): @@ -51,7 +54,10 @@ public indirect enum JSON: Hashable, Codable { case let .array(value): return try .init(value.map(recurse)) case let .number(value): - return try .init(Decimal(value, format: .number)) + guard let decimal = Decimal(string: value) else { + throw JSONDecimalError() + } + return .init(decimal) case let .string(value): return .init(value) case let .bool(value): diff --git a/Tests/Info.plist b/Tests/Info.plist deleted file mode 100644 index 6c40a6c..0000000 --- a/Tests/Info.plist +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> -<plist version="1.0"> -<dict> - <key>CFBundleDevelopmentRegion</key> - <string>$(DEVELOPMENT_LANGUAGE)</string> - <key>CFBundleExecutable</key> - <string>$(EXECUTABLE_NAME)</string> - <key>CFBundleIdentifier</key> - <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> - <key>CFBundleInfoDictionaryVersion</key> - <string>6.0</string> - <key>CFBundleName</key> - <string>$(PRODUCT_NAME)</string> - <key>CFBundlePackageType</key> - <string>BNDL</string> - <key>CFBundleShortVersionString</key> - <string>1.0</string> - <key>CFBundleVersion</key> - <string>1</string> -</dict> -</plist>