diff --git a/.swift-version b/.swift-version index f398a20..8012ebb 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -3.0 \ No newline at end of file +4.2 \ No newline at end of file diff --git a/.swiftlint.yml b/.swiftlint.yml index 6a9869a..4dbb187 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -1,3 +1,3 @@ disabled_rules: - line_length - - nesting + - nesting \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 3355772..28ef13b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,10 @@ os: - osx language: generic -osx_image: xcode9 +osx_image: xcode10 script: # - xcrun instruments -t 'Blank' -l 10 -w "iPhone 6s (10.3)" - - xcodebuild -scheme Example -configuration Debug -sdk iphonesimulator11.0 -destination "OS=11.0,name=iPhone 6s" build - - xcodebuild -scheme TABResourceLoader -configuration Debug -sdk iphonesimulator11.0 -destination "OS=11.0,name=iPhone 6s" test -enableCodeCoverage YES + - xcodebuild -scheme Example -configuration Debug -sdk iphonesimulator12.0 -destination "OS=12.0,name=iPhone 6s" build + - xcodebuild -scheme TABResourceLoader -configuration Debug -sdk iphonesimulator12.0 -destination "OS=12.0,name=iPhone 6s" test -enableCodeCoverage YES after_success: - bash <(curl -s https://codecov.io/bash) \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fe5a83..eada9b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 8.0.0 + +- Add Swift 4.2 support + ## 7.2.2 - Adds optional `requestTimeoutInterval` property to `NetworkResourceType` which can be used to set a `URLRequest` specific timeout for the resource. diff --git a/Example/AppDelegate.swift b/Example/AppDelegate.swift index dda89da..81f0551 100644 --- a/Example/AppDelegate.swift +++ b/Example/AppDelegate.swift @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { setupNetworkActivityHandler(for: application) return true } diff --git a/Example/Models/Multiple responses example/CitiesResponse.swift b/Example/Models/Multiple responses example/CitiesResponse.swift index 95dea39..5345948 100644 --- a/Example/Models/Multiple responses example/CitiesResponse.swift +++ b/Example/Models/Multiple responses example/CitiesResponse.swift @@ -21,7 +21,7 @@ enum CitiesResponse { extension CitiesResponse { public init(jsonDictionary: [String : Any]) throws { if let citiesJSONArray = jsonDictionary["cities"] as? [[String: Any]] { - self = .cities(citiesJSONArray.flatMap(City.init)) + self = .cities(citiesJSONArray.compactMap(City.init)) } else if let city = City(jsonDictionary: jsonDictionary) { self = .city(city) } else if let serverError = ServerError(jsonDictionary: jsonDictionary) { diff --git a/Example/Models/Simple example/CitiesResource.swift b/Example/Models/Simple example/CitiesResource.swift index 278acf7..fbf0b74 100644 --- a/Example/Models/Simple example/CitiesResource.swift +++ b/Example/Models/Simple example/CitiesResource.swift @@ -31,7 +31,7 @@ struct CitiesResource: NetworkJSONDictionaryResourceType { else { throw CitiesResourceError.parsingFailed } - return citiesJSONArray.flatMap(City.init) + return citiesJSONArray.compactMap(City.init) } } diff --git a/Sources/TABResourceLoader/Concrete types/Result.swift b/Sources/TABResourceLoader/Concrete types/Result.swift index 61f0f4c..a04fe31 100644 --- a/Sources/TABResourceLoader/Concrete types/Result.swift +++ b/Sources/TABResourceLoader/Concrete types/Result.swift @@ -47,8 +47,8 @@ extension Result { // Convert the `Result` back to typical Swift `throws` error handling public func unwrap() throws -> T { switch self { - case .success(let v): return v - case .failure(let e): throw e + case .success(let capturedValue): return capturedValue + case .failure(let error): throw error } } } diff --git a/TABResourceLoader.podspec b/TABResourceLoader.podspec index 37ca0e2..0040d6c 100644 --- a/TABResourceLoader.podspec +++ b/TABResourceLoader.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |spec| spec.name = 'TABResourceLoader' spec.homepage = 'https://github.com/theappbusiness/TABResourceLoader' - spec.version = '7.2.2' + spec.version = '8.0.0' spec.license = { :type => 'MIT' } spec.authors = { 'Luciano Marisi' => 'luciano@techbrewers.com' } spec.summary = 'Framework for loading resources from a network service' diff --git a/TABResourceLoader.xcodeproj/project.pbxproj b/TABResourceLoader.xcodeproj/project.pbxproj index d9bdb47..d14fe3a 100644 --- a/TABResourceLoader.xcodeproj/project.pbxproj +++ b/TABResourceLoader.xcodeproj/project.pbxproj @@ -612,7 +612,7 @@ }; 4F079CD81D84559200D08DA0 = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 0900; + LastSwiftMigration = ""; }; 4F8D1FB91D8DFFD30099DD9A = { CreatedOnToolsVersion = 8.0; @@ -935,7 +935,7 @@ SKIP_INSTALL = YES; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_TREAT_WARNINGS_AS_ERRORS = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -955,7 +955,7 @@ SKIP_INSTALL = YES; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_TREAT_WARNINGS_AS_ERRORS = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -967,7 +967,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.lucianomarisi.TABResourceLoaderTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -979,7 +979,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.lucianomarisi.TABResourceLoaderTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -996,7 +996,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.lucianomarisi.Example; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -1012,7 +1012,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.lucianomarisi.Example; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/Tests/TABResourceLoaderTests/Mocks/MockJSONArrayResourceType.swift b/Tests/TABResourceLoaderTests/Mocks/MockJSONArrayResourceType.swift index 13bc9e4..eaf108d 100644 --- a/Tests/TABResourceLoaderTests/Mocks/MockJSONArrayResourceType.swift +++ b/Tests/TABResourceLoaderTests/Mocks/MockJSONArrayResourceType.swift @@ -13,7 +13,7 @@ struct MockJSONArrayResourceType: JSONArrayResourceType { typealias Model = [MockObject] func model(from jsonArray: [Any]) throws -> [MockObject] { - let parsedMockObjects: [MockObject] = jsonArray.flatMap { + let parsedMockObjects: [MockObject] = jsonArray.compactMap { guard let jsonDictionary = $0 as? [String: Any] else { return nil } return MockObject(jsonDictionary: jsonDictionary) } diff --git a/Tests/TABResourceLoaderTests/Protocols/ImageResourceTypeTests.swift b/Tests/TABResourceLoaderTests/Protocols/ImageResourceTypeTests.swift index b383f48..45341c6 100644 --- a/Tests/TABResourceLoaderTests/Protocols/ImageResourceTypeTests.swift +++ b/Tests/TABResourceLoaderTests/Protocols/ImageResourceTypeTests.swift @@ -33,7 +33,7 @@ class ImageResourceTypeTests: XCTestCase { func test_resultFromData_whenDataIsValid() { let mockImage = ImageMocker.mock() - let imageData = UIImagePNGRepresentation(mockImage)! + let imageData = mockImage.pngData()! let testResult = try? mockImageResourceType.model(from: imageData) XCTAssertNotNil(testResult) }