Skip to content

Commit b634949

Browse files
committed
Make Codable conformance + tests conditional on Foundation import
1 parent d1ef00b commit b634949

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

Sources/SemanticVersion/SemanticVersion+Codable.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#if canImport(Foundation)
16+
1517
import Foundation
1618

1719
public enum SemanticVersionStrategy {
@@ -100,3 +102,5 @@ extension SemanticVersion: Codable {
100102
}
101103
}
102104
}
105+
106+
#endif

Tests/SemanticVersionTests/SemanticVersionCodingTests.swift renamed to Tests/SemanticVersionTests/SemanticVersionCodableTests.swift

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
1+
// Copyright Dave Verwer, Sven A. Schmidt, and other contributors.
12
//
2-
// SemanticVersionCodingTests.swift
3-
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
46
//
5-
// Created by Chris Eplett on 11/3/23.
7+
// http://www.apache.org/licenses/LICENSE-2.0
68
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#if canImport(Foundation)
716

817
import XCTest
918

1019
import SemanticVersion
1120

12-
final class SemanticVersionCodingTests: XCTestCase {
21+
final class SemanticVersionCodableTests: XCTestCase {
1322
func test_defaultCodable_is_default() throws {
1423
XCTAssertEqual(.defaultCodable, JSONEncoder().semanticVersionEncodingStrategy)
1524
XCTAssertEqual(.defaultCodable, JSONDecoder().semanticVersionDecodingStrategy)
@@ -191,3 +200,5 @@ final class SemanticVersionCodingTests: XCTestCase {
191200
}
192201
}
193202
}
203+
204+
#endif

0 commit comments

Comments
 (0)