Skip to content

Commit

Permalink
Swift 4.2 support (#74)
Browse files Browse the repository at this point in the history
* Update code to support Swift 4.2

* Use Xcode 10 on CI, rather than Xcode 9

* Use iOS 12 for building, rather than iOS 11

* Update Swiflint file to set min identifier length to 1

* Change Swift version to 4.2 for tests and example app

* Update variable names to fix SwiftLint min_identifier length violation

* Updatw Swift version from 3.0 to 4.2

* Remove min_identifier length = 1

* Update pod version to 8.0.0

* Update changelog
  • Loading branch information
theblixguy authored Sep 25, 2018
1 parent 197dc0b commit 37bda3e
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
4.2
2 changes: 1 addition & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
disabled_rules:
- line_length
- nesting
- nesting
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion Example/Models/Simple example/CitiesResource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct CitiesResource: NetworkJSONDictionaryResourceType {
else {
throw CitiesResourceError.parsingFailed
}
return citiesJSONArray.flatMap(City.init)
return citiesJSONArray.compactMap(City.init)
}

}
4 changes: 2 additions & 2 deletions Sources/TABResourceLoader/Concrete types/Result.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
2 changes: 1 addition & 1 deletion TABResourceLoader.podspec
Original file line number Diff line number Diff line change
@@ -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' => '[email protected]' }
spec.summary = 'Framework for loading resources from a network service'
Expand Down
14 changes: 7 additions & 7 deletions TABResourceLoader.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@
};
4F079CD81D84559200D08DA0 = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0900;
LastSwiftMigration = "";
};
4F8D1FB91D8DFFD30099DD9A = {
CreatedOnToolsVersion = 8.0;
Expand Down Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand All @@ -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;
};
Expand All @@ -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;
};
Expand All @@ -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;
};
Expand All @@ -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;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 37bda3e

Please sign in to comment.