From 53d8b3b730635b68a0b2fc720643e8cea4f6b6e2 Mon Sep 17 00:00:00 2001 From: JP Simard Date: Wed, 10 Jul 2024 10:43:59 -0400 Subject: [PATCH] Require Swift 5.7 or later (#424) --- .github/workflows/bazel.yml | 2 +- .github/workflows/cmake.yml | 2 +- .github/workflows/swiftpm.yml | 14 ----------- .github/workflows/xcodebuild.yml | 33 ------------------------- CHANGELOG.md | 3 ++- Package.swift | 2 +- README.md | 2 +- Sources/Yams/Encoder.swift | 12 --------- Tests/YamsTests/ConstructorTests.swift | 20 --------------- Tests/YamsTests/EncoderTests.swift | 33 ------------------------- Tests/YamsTests/NodeTests.swift | 18 -------------- Tests/YamsTests/SpecTests.swift | 34 -------------------------- Yams.podspec | 2 +- 13 files changed, 7 insertions(+), 170 deletions(-) diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index 8a609aed..8bc4d7d1 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -41,7 +41,7 @@ jobs: Linux: strategy: matrix: - tag: ['5.4', '5.5', '5.6', '5.7', '5.8', '5.9', '5.10'] + tag: ['5.7', '5.8', '5.9', '5.10'] runs-on: ubuntu-latest container: image: swift:${{ matrix.tag }}-focal diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 699ee81f..1a25c742 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -30,7 +30,7 @@ jobs: name: macOS with Xcode ${{ matrix.xcode_version }} strategy: matrix: - xcode_version: ['15.0', '15.1', '15.2', '15.3', '15.4'] + xcode_version: ['15.0', '15.4'] runs-on: macos-14 env: DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app diff --git a/.github/workflows/swiftpm.yml b/.github/workflows/swiftpm.yml index c1af5bc7..0ac1d23c 100644 --- a/.github/workflows/swiftpm.yml +++ b/.github/workflows/swiftpm.yml @@ -28,20 +28,6 @@ concurrency: cancel-in-progress: true jobs: - Xcode_Monterey: - name: macOS 12 with Xcode ${{ matrix.xcode_version }} - strategy: - matrix: - xcode_version: ['13.3.1', '13.4', '14.0.1', '14.1', '14.2'] - runs-on: macos-12 - env: - DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app - steps: - - uses: actions/checkout@v4 - - run: swift -version - - run: YAMS_DEFAULT_ENCODING=UTF16 swift test --parallel - - run: YAMS_DEFAULT_ENCODING=UTF8 swift test --parallel - Xcode_Ventura: name: macOS 13 with Xcode ${{ matrix.xcode_version }} strategy: diff --git a/.github/workflows/xcodebuild.yml b/.github/workflows/xcodebuild.yml index c23eb8b2..dae2365e 100644 --- a/.github/workflows/xcodebuild.yml +++ b/.github/workflows/xcodebuild.yml @@ -26,39 +26,6 @@ concurrency: cancel-in-progress: true jobs: - xcodebuild_Monterey: - name: macOS 12 with Xcode ${{ matrix.xcode_version }} - strategy: - matrix: - xcode_version: ['13.3.1', '13.4', '14.0.1', '14.2'] - xcode_flags: ['-scheme Yams -project Yams.xcodeproj'] - runs-on: macos-12 - env: - DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app - steps: - - uses: actions/checkout@v4 - - run: xcodebuild -version - - name: macOS with UTF16 - if: always() - run: set -o pipefail && YAMS_DEFAULT_ENCODING=UTF16 xcodebuild ${{ matrix.xcode_flags }} test | xcbeautify --renderer github-actions - shell: bash - - name: macOS with UTF8 - if: always() - run: set -o pipefail && YAMS_DEFAULT_ENCODING=UTF8 xcodebuild ${{ matrix.xcode_flags }} test | xcbeautify --renderer github-actions - shell: bash - - name: iPhone Simulator - if: always() - run: set -o pipefail && xcodebuild ${{ matrix.xcode_flags }} test -sdk iphonesimulator -destination "name=iPhone 8" | xcbeautify --renderer github-actions - shell: bash - - name: Apple TV Simulator - if: always() - run: set -o pipefail && xcodebuild ${{ matrix.xcode_flags }} test -sdk appletvsimulator -destination "name=Apple TV 4K (2nd generation)" | xcbeautify --renderer github-actions - shell: bash - - name: watchOS Simulator - if: always() - run: set -o pipefail && xcodebuild ${{ matrix.xcode_flags }} build -sdk watchsimulator | xcbeautify --renderer github-actions - shell: bash - xcodebuild_Ventura: name: macOS 13 with Xcode ${{ matrix.xcode_version }} strategy: diff --git a/CHANGELOG.md b/CHANGELOG.md index ab257062..82045a5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ ##### Breaking -* None. +* Swift 5.7 or later is now required to build Yams. + [JP Simard](https://github.com/jpsim) ##### Enhancements diff --git a/Package.swift b/Package.swift index 5b302c18..3daf286f 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.4 +// swift-tools-version:5.7 import PackageDescription let package = Package( diff --git a/README.md b/README.md index 199ca3ee..484c53bb 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ A sweet and swifty [YAML](http://yaml.org/) parser built on ## Installation -Building Yams requires Xcode 12.5+ or a Swift 5.4+ toolchain with the +Building Yams requires Xcode 14.0+ or a Swift 5.7+ toolchain with the Swift Package Manager or CMake and Ninja. ### CMake diff --git a/Sources/Yams/Encoder.swift b/Sources/Yams/Encoder.swift index a17711ee..fd17bac3 100644 --- a/Sources/Yams/Encoder.swift +++ b/Sources/Yams/Encoder.swift @@ -226,30 +226,18 @@ extension _Encoder: SingleValueEncodingContainer { func encode(_ value: T) throws where T: YAMLEncodable { assertCanEncodeNewValue() node = value.box() -#if swift(>=5.7) if let stringValue = value as? (any StringProtocol), stringValue.contains("\n") { node.scalar?.style = newlineScalarStyle } -#else - if let stringValue = value as? String, stringValue.contains("\n") { - node.scalar?.style = newlineScalarStyle - } -#endif } func encode(_ value: T) throws where T: Encodable { assertCanEncodeNewValue() if let encodable = value as? YAMLEncodable { node = encodable.box() -#if swift(>=5.7) if let stringValue = value as? (any StringProtocol), stringValue.contains("\n") { node.scalar?.style = newlineScalarStyle } -#else - if let stringValue = value as? String, stringValue.contains("\n") { - node.scalar?.style = newlineScalarStyle - } -#endif } else { try value.encode(to: self) } diff --git a/Tests/YamsTests/ConstructorTests.swift b/Tests/YamsTests/ConstructorTests.swift index 53b76d3b..b9124b99 100644 --- a/Tests/YamsTests/ConstructorTests.swift +++ b/Tests/YamsTests/ConstructorTests.swift @@ -526,25 +526,6 @@ class ConstructorTests: XCTestCase { // swiftlint:disable:this type_body_length extension ConstructorTests { static var allTests: [(String, (ConstructorTests) -> () throws -> Void)] { -#if os(Windows) && swift(<5.6) - return [ - ("testBinary", testBinary), - ("testBool", testBool), - // ("testFloat", testFloat), - // ("testInt", testInt), - ("testMap", testMap), - // ("testMerge", testMerge), - ("testNull", testNull), - // ("testOmap", testOmap), - ("testPairs", testPairs), - ("testQuotationMark", testQuotationMark), - ("testSet", testSet), - ("testSeq", testSeq), - ("testTimestamp", testTimestamp), - ("testTimestampWithNanosecond", testTimestampWithNanosecond) - // ("testValue", testValue) - ] -#else return [ ("testBinary", testBinary), ("testBool", testBool), @@ -562,6 +543,5 @@ extension ConstructorTests { ("testTimestampWithNanosecond", testTimestampWithNanosecond), ("testValue", testValue) ] -#endif } } // swiftlint:disable:this file_length diff --git a/Tests/YamsTests/EncoderTests.swift b/Tests/YamsTests/EncoderTests.swift index f51106f7..e5a06dd2 100644 --- a/Tests/YamsTests/EncoderTests.swift +++ b/Tests/YamsTests/EncoderTests.swift @@ -1149,38 +1149,6 @@ private struct Unkeyed: Codable, Equatable { extension EncoderTests { static var allTests: [(String, (EncoderTests) -> () throws -> Void)] { -#if os(Windows) && swift(<5.6) - return [ - ("testEncodingTopLevelEmptyStruct", testEncodingTopLevelEmptyStruct), - ("testEncodingTopLevelEmptyClass", testEncodingTopLevelEmptyClass), - ("testEncodingTopLevelSingleValueEnum", testEncodingTopLevelSingleValueEnum), - ("testEncodingTopLevelSingleValueStruct", testEncodingTopLevelSingleValueStruct), - // ("testEncodingTopLevelSingleValueClass", testEncodingTopLevelSingleValueClass), - // ("testEncodingTopLevelStructuredStruct", testEncodingTopLevelStructuredStruct), - ("testEncodingTopLevelStructuredClass", testEncodingTopLevelStructuredClass), - // ("testEncodingTopLevelStructuredSingleStruct", testEncodingTopLevelStructuredSingleStruct), - ("testEncodingTopLevelStructuredSingleClass", testEncodingTopLevelStructuredSingleClass), - // ("testEncodingTopLevelDeepStructuredType", testEncodingTopLevelDeepStructuredType), - // ("testEncodingClassWhichSharesEncoderWithSuper", testEncodingClassWhichSharesEncoderWithSuper), - ("testEncodingTopLevelNullableType", testEncodingTopLevelNullableType), - ("testEncodingDate", testEncodingDate), - ("testEncodingDateMillisecondsSince1970", testEncodingDateMillisecondsSince1970), - ("testEncodingBase64Data", testEncodingBase64Data), - // ("testNestedContainerCodingPaths", testNestedContainerCodingPaths), - // ("testSuperEncoderCodingPaths", testSuperEncoderCodingPaths), - ("testInterceptDecimal", testInterceptDecimal), - ("testInterceptURL", testInterceptURL), - // ("testValuesInSingleValueContainer", testValuesInSingleValueContainer), - // ("testValuesInKeyedContainer", testValuesInKeyedContainer), - // ("testValuesInUnkeyedContainer", testValuesInUnkeyedContainer), - ("testDictionary", testDictionary), - ("testNodeTypeMismatch", testNodeTypeMismatch), - // ("testDecodingConcreteTypeParameter", testDecodingConcreteTypeParameter), - ("testDecodingAnchors", testDecodingAnchors), - ("test_null_yml", test_null_yml), - ("testEncodingDateWithNanosecondGreaterThan999499977", testEncodingDateWithNanosecondGreaterThan999499977) - ] -#else return [ ("testEncodingTopLevelEmptyStruct", testEncodingTopLevelEmptyStruct), ("testEncodingTopLevelEmptyClass", testEncodingTopLevelEmptyClass), @@ -1212,6 +1180,5 @@ extension EncoderTests { ("testEncodingDateWithNanosecondGreaterThan999499977", testEncodingDateWithNanosecondGreaterThan999499977), ("testDecoderMark", testDecoderMark) ] -#endif } } // swiftlint:disable:this file_length diff --git a/Tests/YamsTests/NodeTests.swift b/Tests/YamsTests/NodeTests.swift index 933de986..7908b6fe 100644 --- a/Tests/YamsTests/NodeTests.swift +++ b/Tests/YamsTests/NodeTests.swift @@ -206,23 +206,6 @@ class NodeTests: XCTestCase { extension NodeTests { static var allTests: [(String, (NodeTests) -> () throws -> Void)] { -#if os(Windows) && swift(<5.6) - return [ - ("testExpressibleByArrayLiteral", testExpressibleByArrayLiteral), - ("testExpressibleByDictionaryLiteral", testExpressibleByDictionaryLiteral), - ("testExpressibleByFloatLiteral", testExpressibleByFloatLiteral), - ("testExpressibleByIntegerLiteral", testExpressibleByIntegerLiteral), - ("testExpressibleByStringLiteral", testExpressibleByStringLiteral), - // ("testTypedAccessorProperties", testTypedAccessorProperties), - // ("testArray", testArray), - ("testSubscriptMapping", testSubscriptMapping), - // ("testSubscriptSequence", testSubscriptSequence), - ("testSubscriptWithNonDefaultResolver", testSubscriptWithNonDefaultResolver), - ("testMappingBehavesLikeADictionary", testMappingBehavesLikeADictionary), - ("testSequenceBehavesLikeAnArray", testSequenceBehavesLikeAnArray), - ("testScalar", testScalar) - ] -#else return [ ("testExpressibleByArrayLiteral", testExpressibleByArrayLiteral), ("testExpressibleByDictionaryLiteral", testExpressibleByDictionaryLiteral), @@ -238,6 +221,5 @@ extension NodeTests { ("testSequenceBehavesLikeAnArray", testSequenceBehavesLikeAnArray), ("testScalar", testScalar) ] -#endif } } diff --git a/Tests/YamsTests/SpecTests.swift b/Tests/YamsTests/SpecTests.swift index 7e9145fb..91a4b6ff 100644 --- a/Tests/YamsTests/SpecTests.swift +++ b/Tests/YamsTests/SpecTests.swift @@ -916,39 +916,6 @@ class SpecTests: XCTestCase { // swiftlint:disable:this type_body_length extension SpecTests { static var allTests: [(String, (SpecTests) -> () throws -> Void)] { -#if os(Windows) && swift(<5.6) - return [ - ("testEmptyString", testEmptyString), - ("testMultibyteCharacters", testMultibyteCharacters), - // ("testSpecExample2_1_SequenceOfScalars", testSpecExample2_1_SequenceOfScalars), - // ("testSpecExample2_2_MappingScalarsToScalars", testSpecExample2_2_MappingScalarsToScalars), - ("testSpecExample2_3_MappingScalarsToSequences", testSpecExample2_3_MappingScalarsToSequences), - // ("testSpecExample2_4_SequenceOfMappings", testSpecExample2_4_SequenceOfMappings), - // ("testSpecExample2_5_SequenceOfSequences", testSpecExample2_5_SequenceOfSequences), - // ("testSpecExample2_6_MappingOfMappings", testSpecExample2_6_MappingOfMappings), - ("testSpecExample2_7_TwoDocumentsInAStream", testSpecExample2_7_TwoDocumentsInAStream), - // ("testSpecExample2_8_PlayByPlayFeedFromAGame", testSpecExample2_8_PlayByPlayFeedFromAGame), - ("testSpecExample2_9_SingleDocumentWithTwoComments", testSpecExample2_9_SingleDocumentWithTwoComments), - ("testSpecExample2_10_NodeForSammySosaAppearsTwiceInThisDocument", - testSpecExample2_10_NodeForSammySosaAppearsTwiceInThisDocument), - ("testSpecExample2_11_MappingBetweenSequences", testSpecExample2_11_MappingBetweenSequences), - // ("testSpecExample2_12_CompactNestedMapping", testSpecExample2_12_CompactNestedMapping), - ("testSpecExample2_13_Inliterals_NewlinesArePreserved", - testSpecExample2_13_Inliterals_NewlinesArePreserved), - ("testSpecExample2_14_InTheFoldedScalars_NewlinesBecomeSpaces", - testSpecExample2_14_InTheFoldedScalars_NewlinesBecomeSpaces), - ("testSpecExample2_15_InTheFoldedScalars_NewlinesBecomeSpaces", - testSpecExample2_15_InTheFoldedScalars_NewlinesBecomeSpaces), - ("testSpecExample2_16_IndentationDeterminesScope", testSpecExample2_16_IndentationDeterminesScope), - ("testSpecExample2_17_QuotedScalars", testSpecExample2_17_QuotedScalars), - ("testSpecExample2_18_MultiLineFlowScalars", testSpecExample2_18_MultiLineFlowScalars), - // ("testSpecExample2_19_Integers", testSpecExample2_19_Integers), - ("testSpecExample2_20_FloatingPoint", testSpecExample2_20_FloatingPoint), - ("testSpecExample2_23_VariousExplicitTags", testSpecExample2_23_VariousExplicitTags) - // ("testSpecExample2_27_Invoice", testSpecExample2_27_Invoice), - // ("testSpecExample2_28_LogFile", testSpecExample2_28_LogFile) - ] -#else return [ ("testEmptyString", testEmptyString), ("testMultibyteCharacters", testMultibyteCharacters), @@ -980,6 +947,5 @@ extension SpecTests { ("testSpecExample2_27_Invoice", testSpecExample2_27_Invoice), ("testSpecExample2_28_LogFile", testSpecExample2_28_LogFile) ] -#endif } } // swiftlint:disable:this file_length diff --git a/Yams.podspec b/Yams.podspec index 790624b2..89ec778a 100644 --- a/Yams.podspec +++ b/Yams.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.authors = { 'JP Simard' => 'jp@jpsim.com', 'Norio Nomura' => 'norio.nomura@gmail.com' } s.source_files = 'Sources/**/*.{h,c,swift}' - s.swift_versions = ['5.4', '5.5', '5.6', '5.7', '5.8', '5.9', '5.10'] + s.swift_versions = ['5.7', '5.8', '5.9', '5.10'] s.pod_target_xcconfig = { 'APPLICATION_EXTENSION_API_ONLY' => 'YES' } s.ios.deployment_target = '11.0' s.osx.deployment_target = '10.13'