Skip to content

Commit c5a5905

Browse files
authored
Remove JSON writing from non macos apple platforms (#151)
1 parent d4c6a5f commit c5a5905

1 file changed

Lines changed: 26 additions & 4 deletions

File tree

Sources/JBirdCore/Models/JSON.swift

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,8 @@ public enum JSON: Equatable, Hashable, Sendable, ExpressibleByBooleanLiteral, Ex
861861
try .array(arrayValue.filter(isIncluded))
862862
}
863863

864+
/// Remove `null` values from a JSON array
865+
/// - Returns: A JSON array with no null values
864866
public func filterNils() throws -> JSON {
865867
switch self {
866868
case .array:
@@ -903,6 +905,10 @@ public enum JSON: Equatable, Hashable, Sendable, ExpressibleByBooleanLiteral, Ex
903905
/// - options: Serialization options to use when writing the JSON model to disk
904906
/// - shouldOverwrite: Whether or not existing content should be overwritten
905907
@available(macOS 13.0, macCatalyst 16.0, *)
908+
@available(iOS, unavailable)
909+
@available(watchOS, unavailable)
910+
@available(tvOS, unavailable)
911+
@available(visionOS, unavailable)
906912
@discardableResult
907913
@concurrent
908914
public func write(
@@ -919,8 +925,14 @@ public enum JSON: Equatable, Hashable, Sendable, ExpressibleByBooleanLiteral, Ex
919925
}
920926
}
921927

922-
let data = try await JSON.serialize(self, options: options)
923-
try data.write(to: fileURL, options: .withoutOverwriting)
928+
let data = try await JSON.serialize(
929+
self,
930+
options: options
931+
)
932+
try data.write(
933+
to: fileURL,
934+
options: .withoutOverwriting
935+
)
924936
try Task.checkCancellation()
925937
return data
926938
}
@@ -931,6 +943,10 @@ public enum JSON: Equatable, Hashable, Sendable, ExpressibleByBooleanLiteral, Ex
931943
/// - options: Serialization options to use when writing the JSON model to disk
932944
/// - shouldOverwrite: Whether or not existing content should be overwritten
933945
@available(macOS 13.0, macCatalyst 16.0, *)
946+
@available(iOS, unavailable)
947+
@available(watchOS, unavailable)
948+
@available(tvOS, unavailable)
949+
@available(visionOS, unavailable)
934950
@discardableResult
935951
public func write(
936952
fileURL: URL,
@@ -946,8 +962,14 @@ public enum JSON: Equatable, Hashable, Sendable, ExpressibleByBooleanLiteral, Ex
946962
}
947963
}
948964

949-
let data = try await JSON.serialize(self, options: options)
950-
try data.write(to: fileURL, options: .withoutOverwriting)
965+
let data = try await JSON.serialize(
966+
self,
967+
options: options
968+
)
969+
try data.write(
970+
to: fileURL,
971+
options: .withoutOverwriting
972+
)
951973
try Task.checkCancellation()
952974
return data
953975
}

0 commit comments

Comments
 (0)