Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Sources/TOMLDecoder/DateTime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,12 @@ extension String {
}
}

#if canImport(Foundation)
#if canImport(FoundationEssentials) || canImport(Foundation)
#if canImport(FoundationEssentials)
public import FoundationEssentials
#else
public import Foundation
#endif

extension DateComponents {
/// Create a new `Foundation.DateComponents` from an offset date-time.
Expand Down
4 changes: 4 additions & 0 deletions Sources/TOMLDecoder/Parsing/TOMLDocument.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

struct TOMLDocument: Equatable, @unchecked Sendable {
let tables: [InternalTOMLTable]
Expand Down
4 changes: 4 additions & 0 deletions Sources/TOMLDecoder/TOMLDecoder.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#if canImport(FoundationEssentials)
public import FoundationEssentials
#else
public import Foundation
#endif

/// Convert data for a TOML document into `Codable` types.
///
Expand Down
8 changes: 6 additions & 2 deletions Sources/TOMLDecoder/TOMLKeyedDecodingContainer.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#if canImport(Foundation)
#if canImport(FoundationEssentials) || canImport(Foundation)
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif
struct TOMLKeyedDecodingContainer<Key: CodingKey>: KeyedDecodingContainerProtocol {
private let decoder: _TOMLDecoder
private let table: TOMLTable
Expand Down Expand Up @@ -74,7 +78,7 @@ struct TOMLKeyedDecodingContainer<Key: CodingKey>: KeyedDecodingContainerProtoco
decoder.codingPath.removeLast()
}
decoder.token = token
#if canImport(Foundation)
#if canImport(FoundationEssentials) || canImport(Foundation)
// have to intercept these here otherwise Foundation will try to decode it as a float
if type == Date.self {
return try decoder.decode(Date.self) as! T
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// WARNING: This file is generated from TOMLSingleValueDecodingContainer.swift.gyb
// Do not edit TOMLSingleValueDecodingContainer.swift directly.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

extension _TOMLDecoder: SingleValueDecodingContainer {
var context: TOMLKey {
Expand Down
8 changes: 6 additions & 2 deletions Sources/TOMLDecoder/TOMLUnkeyedDecodingContainer.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#if canImport(Foundation)
#if canImport(FoundationEssentials) || canImport(Foundation)
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif

struct TOMLUnkeyedDecodingContainer: UnkeyedDecodingContainer {
private let decoder: _TOMLDecoder
Expand Down Expand Up @@ -89,7 +93,7 @@ struct TOMLUnkeyedDecodingContainer: UnkeyedDecodingContainer {
decoder.token = token

// have to intercept these here otherwise Foundation will try to decode it as a float
#if canImport(Foundation)
#if canImport(FoundationEssentials) || canImport(Foundation)
if type == Date.self {
return try decoder.decode(Date.self) as! T
} else if type == DateComponents.self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ native_types = [
// WARNING: This file is generated from ${template_name}
// Do not edit ${generated_file} directly.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

extension _TOMLDecoder: SingleValueDecodingContainer {
var context: TOMLKey {
Expand Down
Loading