diff --git a/Cartfile b/Cartfile index 65016b2bf..9ae3d21a6 100644 --- a/Cartfile +++ b/Cartfile @@ -1,3 +1,3 @@ -github "Alamofire/Alamofire" "5.0.0-rc.3" +github "Alamofire/Alamofire" ~> 5.0 github "ReactiveCocoa/ReactiveSwift" ~> 6.0 github "ReactiveX/RxSwift" ~> 5.0 diff --git a/Cartfile.private b/Cartfile.private index 110327b71..ea92a7419 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1,3 +1,3 @@ -github "AliSoftware/OHHTTPStubs" ~> 8.0.0 +github "AliSoftware/OHHTTPStubs" ~> 9.0.0 github "Quick/Quick" ~> 2.0.0 github "Quick/Nimble" ~> 8.0.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index 7af9acd36..1a990af06 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,6 +1,6 @@ -github "Alamofire/Alamofire" "5.0.0-rc.3" -github "AliSoftware/OHHTTPStubs" "8.0.0" -github "Quick/Nimble" "v8.0.4" +github "Alamofire/Alamofire" "5.0.0" +github "AliSoftware/OHHTTPStubs" "9.0.0" +github "Quick/Nimble" "v8.0.5" github "Quick/Quick" "v2.2.0" -github "ReactiveCocoa/ReactiveSwift" "6.1.0" +github "ReactiveCocoa/ReactiveSwift" "6.2.0" github "ReactiveX/RxSwift" "5.0.1" diff --git a/Changelog.md b/Changelog.md index 042ced4b1..2b0ede947 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,7 @@ # Next ### Changed +- **Breaking Change** Minimum version of `Alamofire` is now 5.0. [#1992](https://github.com/Moya/Moya/pull/1992) by [@sunshinejr](https://github.com/sunshinejr). - **Breaking Change** `MultiTarget` now implements `AccessTokenAuthorizable` so that the inner target's `authorizationType` is correctly returned to the `AccessTokenPlugin` when requested. [#1979](https://github.com/Moya/Moya/pull/1979) by [@amaurydavid](https://github.com/amaurydavid). diff --git a/Examples/_shared/GitHubAPI.swift b/Examples/_shared/GitHubAPI.swift index 8ac0a5eca..739196c2d 100644 --- a/Examples/_shared/GitHubAPI.swift +++ b/Examples/_shared/GitHubAPI.swift @@ -9,9 +9,9 @@ private func JSONResponseDataFormatter(_ data: Data) -> String { do { let dataAsJSON = try JSONSerialization.jsonObject(with: data) let prettyData = try JSONSerialization.data(withJSONObject: dataAsJSON, options: .prettyPrinted) - return String(data: prettyData, encoding: .utf8) ?? String() + return String(data: prettyData, encoding: .utf8) ?? String(data: data, encoding: .utf8) ?? "" } catch { - return String() + return String(data: data, encoding: .utf8) ?? "" } } diff --git a/Moya.podspec b/Moya.podspec index c46fd59fd..b3a25d726 100644 --- a/Moya.podspec +++ b/Moya.podspec @@ -24,7 +24,7 @@ Pod::Spec.new do |s| s.subspec "Core" do |ss| ss.source_files = "Sources/Moya/", "Sources/Moya/Plugins/" - ss.dependency "Alamofire", "5.0.0-rc.3" + ss.dependency "Alamofire", "~> 5.0" ss.framework = "Foundation" end diff --git a/Package.resolved b/Package.resolved index 8e9c4c9ae..af66bce55 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/Alamofire/Alamofire.git", "state": { "branch": null, - "revision": "2cbf59935fbb1f26e352ce4db53f1cf9408d5313", - "version": "5.0.0-rc.3" + "revision": "0c8cb78d05b6d067ee331c05058ff4dedcb45ffa", + "version": "5.0.0" } }, { @@ -50,9 +50,9 @@ "package": "OHHTTPStubs", "repositoryURL": "https://github.com/AliSoftware/OHHTTPStubs.git", "state": { - "branch": "feature/spm-support", - "revision": "4726e07728b8bff3152a8c31c34a0bb7cc2aef19", - "version": null + "branch": null, + "revision": "e92b5a5746ef16add2a1424f1fc19529d9a75cde", + "version": "9.0.0" } }, { diff --git a/Package.swift b/Package.swift index 12beea227..386097c98 100644 --- a/Package.swift +++ b/Package.swift @@ -16,12 +16,12 @@ let package = Package( .library(name: "RxMoya", targets: ["RxMoya"]) ], dependencies: [ - .package(url: "https://github.com/Alamofire/Alamofire.git", .exact("5.0.0-rc.3")), + .package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.0.0")), .package(url: "https://github.com/Moya/ReactiveSwift.git", .upToNextMajor(from: "6.1.0")), .package(url: "https://github.com/ReactiveX/RxSwift.git", .upToNextMajor(from: "5.0.0")), .package(url: "https://github.com/Quick/Quick.git", .upToNextMajor(from: "2.0.0")), // dev .package(url: "https://github.com/Quick/Nimble.git", .upToNextMajor(from: "8.0.0")), // dev - .package(url: "https://github.com/AliSoftware/OHHTTPStubs.git", .branch("feature/spm-support")), // dev + .package(url: "https://github.com/AliSoftware/OHHTTPStubs.git", .upToNextMajor(from: "9.0.0")), // dev .package(url: "https://github.com/shibapm/Rocket", .upToNextMajor(from: "1.0.0")) // dev ], targets: [ diff --git a/Readme.md b/Readme.md index a8d163546..863e96aa2 100644 --- a/Readme.md +++ b/Readme.md @@ -2,7 +2,7 @@

-# Moya 14.0.0-beta.6 +# Moya 14.0.0 [![CircleCI](https://img.shields.io/circleci/project/github/Moya/Moya/master.svg)](https://circleci.com/gh/Moya/Moya/tree/master) [![codecov.io](https://codecov.io/github/Moya/Moya/coverage.svg?branch=master)](https://codecov.io/github/Moya/Moya?branch=master) @@ -76,7 +76,7 @@ _Note: If you are using Swift 4.2 in your project, but you are using Xcode 10.2, To integrate using Apple's Swift package manager, add the following as a dependency to your `Package.swift`: ```swift -.package(url: "https://github.com/Moya/Moya.git", .exact("14.0.0-beta.6")) +.package(url: "https://github.com/Moya/Moya.git", .upToNextMajor(from: "14.0.0")) ``` and then specify `"Moya"` as a dependency of the Target in which you wish to use Moya. @@ -95,7 +95,7 @@ let package = Package( targets: ["MyPackage"]), ], dependencies: [ - .package(url: "https://github.com/Moya/Moya.git", .exact("14.0.0-beta.6")) + .package(url: "https://github.com/Moya/Moya.git", .upToNextMajor(from: "14.0.0")) ], targets: [ .target( @@ -116,15 +116,15 @@ Note: If you are using **ReactiveMoya**, we are using [our own fork of ReactiveS For Moya, use the following entry in your Podfile: ```rb -pod 'Moya', '14.0.0-beta.6' +pod 'Moya', '~> 14.0' # or -pod 'Moya/RxSwift', '14.0.0-beta.6' +pod 'Moya/RxSwift', '~> 14.0' # or -pod 'Moya/ReactiveSwift', '14.0.0-beta.6' +pod 'Moya/ReactiveSwift', '~> 14.0' ``` Then run `pod install`. @@ -140,7 +140,7 @@ generated framework they'd like, `Moya`, `RxMoya`, or `ReactiveMoya`. Make the following entry in your Cartfile: ``` -github "Moya/Moya" "14.0.0-beta.6" +github "Moya/Moya" ~> 14.0 ``` Then run `carthage update`. diff --git a/Readme_CN.md b/Readme_CN.md index be859b6f5..ea61dccd8 100644 --- a/Readme_CN.md +++ b/Readme_CN.md @@ -2,7 +2,7 @@

-# Moya 14.0.0-beta.6 +# Moya 14.0.0 [![CircleCI](https://img.shields.io/circleci/project/github/Moya/Moya/master.svg)](https://circleci.com/gh/Moya/Moya/tree/master) [![codecov.io](https://codecov.io/github/Moya/Moya/coverage.svg?branch=master)](https://codecov.io/github/Moya/Moya?branch=master) @@ -61,7 +61,7 @@ Moya 的一些特色功能: 要使用苹果的 Swift Package Manager 集成,将以下内容作为依赖添加到你的 `Package.swift`: ```swift -.package(url: "https://github.com/Moya/Moya.git", .exact("14.0.0-beta.6")) +.package(url: "https://github.com/Moya/Moya.git", .upToNextMajor(from: "14.0.0")) ``` 然后指定 `"Moya"` 为你想要使用 Moya 的 Target 的依赖。如果你想要使用响应式扩展,将 `"ReactiveMoya"` 和 `"RxMoya"` 也也作为依赖加入进来。这里是一个 `PackageDescription` 实例: @@ -78,7 +78,7 @@ let package = Package( targets: ["MyPackage"]), ], dependencies: [ - .package(url: "https://github.com/Moya/Moya.git", .exact("14.0.0-beta.6")) + .package(url: "https://github.com/Moya/Moya.git", .upToNextMajor(from: "14.0.0")) ], targets: [ .target( @@ -95,15 +95,15 @@ let package = Package( 在你的 Podfile 文件中添加 Moya: ```rb -pod 'Moya', '14.0.0-beta.6' +pod 'Moya', '~> 14.0' # or -pod 'Moya/RxSwift', '14.0.0-beta.6' +pod 'Moya/RxSwift', '~> 14.0' # or -pod 'Moya/ReactiveSwift', '14.0.0-beta.6' +pod 'Moya/ReactiveSwift', '~> 14.0' ``` 然后运行 `pod install`。 @@ -117,7 +117,7 @@ Carthage 用户可以指向这个仓库并使用他们喜欢的生成框架,`M 在你的 Cartfile 中添加下面的代码: ``` -github "Moya/Moya" ~> "14.0.0-beta.6" +github "Moya/Moya" ~> 14.0 ``` 然后运行 `carthage update`。 diff --git a/Tests/MoyaTests/MoyaProvider+ReactiveSpec.swift b/Tests/MoyaTests/MoyaProvider+ReactiveSpec.swift index be3f89a76..90bc37052 100644 --- a/Tests/MoyaTests/MoyaProvider+ReactiveSpec.swift +++ b/Tests/MoyaTests/MoyaProvider+ReactiveSpec.swift @@ -1,11 +1,9 @@ import Quick import Nimble import ReactiveSwift - -#if canImport(OHHTTPStubs) import OHHTTPStubs -#elseif canImport(OHHTTPStubsSwift) -import OHHTTPStubsCore + +#if canImport(OHHTTPStubsSwift) import OHHTTPStubsSwift #endif @@ -103,8 +101,8 @@ final class MoyaProviderReactiveSpec: QuickSpec { describe("provider with inflight tracking") { var provider: MoyaProvider! beforeEach { - OHHTTPStubs.stubRequests(passingTest: {$0.url!.path == "/zen"}, withStubResponse: { _ in - return OHHTTPStubsResponse(data: GitHub.zen.sampleData, statusCode: 200, headers: nil) + HTTPStubs.stubRequests(passingTest: {$0.url!.path == "/zen"}, withStubResponse: { _ in + return HTTPStubsResponse(data: GitHub.zen.sampleData, statusCode: 200, headers: nil) }) provider = MoyaProvider(trackInflights: true) } @@ -148,8 +146,8 @@ final class MoyaProviderReactiveSpec: QuickSpec { try? FileManager.default.removeItem(at: file) //`responseTime(-4)` equals to 1000 bytes at a time. The sample data is 4000 bytes. - OHHTTPStubs.stubRequests(passingTest: {$0.url!.path.hasSuffix("logo_github.png")}, withStubResponse: { _ in - return OHHTTPStubsResponse(data: GitHubUserContent.downloadMoyaWebContent("logo_github.png").sampleData, statusCode: 200, headers: nil).responseTime(-4) + HTTPStubs.stubRequests(passingTest: {$0.url!.path.hasSuffix("logo_github.png")}, withStubResponse: { _ in + return HTTPStubsResponse(data: GitHubUserContent.downloadMoyaWebContent("logo_github.png").sampleData, statusCode: 200, headers: nil).responseTime(-4) }) provider = MoyaProvider() } diff --git a/Tests/MoyaTests/MoyaProvider+RxSpec.swift b/Tests/MoyaTests/MoyaProvider+RxSpec.swift index 8bdefbd66..5d94d0171 100644 --- a/Tests/MoyaTests/MoyaProvider+RxSpec.swift +++ b/Tests/MoyaTests/MoyaProvider+RxSpec.swift @@ -1,11 +1,9 @@ import Quick import Nimble import RxSwift - -#if canImport(OHHTTPStubs) import OHHTTPStubs -#elseif canImport(OHHTTPStubsSwift) -import OHHTTPStubsCore + +#if canImport(OHHTTPStubsSwift) import OHHTTPStubsSwift #endif @@ -104,8 +102,8 @@ final class MoyaProviderRxSpec: QuickSpec { var provider: MoyaProvider! beforeEach { - OHHTTPStubs.stubRequests(passingTest: {$0.url!.path == "/zen"}, withStubResponse: { _ in - return OHHTTPStubsResponse(data: GitHub.zen.sampleData, statusCode: 200, headers: nil) + HTTPStubs.stubRequests(passingTest: {$0.url!.path == "/zen"}, withStubResponse: { _ in + return HTTPStubsResponse(data: GitHub.zen.sampleData, statusCode: 200, headers: nil) }) provider = MoyaProvider(trackInflights: true) } @@ -156,8 +154,8 @@ final class MoyaProviderRxSpec: QuickSpec { try? FileManager.default.removeItem(at: file) //`responseTime(-4)` equals to 1000 bytes at a time. The sample data is 4000 bytes. - OHHTTPStubs.stubRequests(passingTest: {$0.url!.path.hasSuffix("logo_github.png")}, withStubResponse: { _ in - return OHHTTPStubsResponse(data: GitHubUserContent.downloadMoyaWebContent("logo_github.png").sampleData, statusCode: 200, headers: nil).responseTime(-4) + HTTPStubs.stubRequests(passingTest: {$0.url!.path.hasSuffix("logo_github.png")}, withStubResponse: { _ in + return HTTPStubsResponse(data: GitHubUserContent.downloadMoyaWebContent("logo_github.png").sampleData, statusCode: 200, headers: nil).responseTime(-4) }) provider = MoyaProvider() } @@ -195,16 +193,16 @@ final class MoyaProviderRxSpec: QuickSpec { } describe("a custom callback queue") { - var stubDescriptor: OHHTTPStubsDescriptor! + var stubDescriptor: HTTPStubsDescriptor! beforeEach { - stubDescriptor = OHHTTPStubs.stubRequests(passingTest: {$0.url!.path == "/zen"}, withStubResponse: { _ in - return OHHTTPStubsResponse(data: GitHub.zen.sampleData, statusCode: 200, headers: nil) + stubDescriptor = HTTPStubs.stubRequests(passingTest: {$0.url!.path == "/zen"}, withStubResponse: { _ in + return HTTPStubsResponse(data: GitHub.zen.sampleData, statusCode: 200, headers: nil) }) } afterEach { - OHHTTPStubs.removeStub(stubDescriptor) + HTTPStubs.removeStub(stubDescriptor) } describe("a provider with a predefined callback queue") { diff --git a/Tests/MoyaTests/MoyaProviderIntegrationTests.swift b/Tests/MoyaTests/MoyaProviderIntegrationTests.swift index 053e621b0..29ce874e4 100644 --- a/Tests/MoyaTests/MoyaProviderIntegrationTests.swift +++ b/Tests/MoyaTests/MoyaProviderIntegrationTests.swift @@ -1,11 +1,9 @@ import Quick import Nimble import Foundation - -#if canImport(OHHTTPStubs) import OHHTTPStubs -#elseif canImport(OHHTTPStubsSwift) -import OHHTTPStubsCore + +#if canImport(OHHTTPStubsSwift) import OHHTTPStubsSwift #endif @@ -31,26 +29,26 @@ final class MoyaProviderIntegrationTests: QuickSpec { let zenMessage = String(data: GitHub.zen.sampleData, encoding: .utf8) beforeEach { - OHHTTPStubs.stubRequests(passingTest: {$0.url!.path == "/zen"}, withStubResponse: { _ in - return OHHTTPStubsResponse(data: GitHub.zen.sampleData, statusCode: 200, headers: nil) + HTTPStubs.stubRequests(passingTest: {$0.url!.path == "/zen"}, withStubResponse: { _ in + return HTTPStubsResponse(data: GitHub.zen.sampleData, statusCode: 200, headers: nil) }) - OHHTTPStubs.stubRequests(passingTest: {$0.url!.path == "/users/ashfurrow"}, withStubResponse: { _ in - return OHHTTPStubsResponse(data: GitHub.userProfile("ashfurrow").sampleData, statusCode: 200, headers: nil) + HTTPStubs.stubRequests(passingTest: {$0.url!.path == "/users/ashfurrow"}, withStubResponse: { _ in + return HTTPStubsResponse(data: GitHub.userProfile("ashfurrow").sampleData, statusCode: 200, headers: nil) }) - OHHTTPStubs.stubRequests(passingTest: {$0.url!.path == "/users/invalid"}, withStubResponse: { _ in - return OHHTTPStubsResponse(data: GitHub.userProfile("invalid").sampleData, statusCode: 400, headers: nil) + HTTPStubs.stubRequests(passingTest: {$0.url!.path == "/users/invalid"}, withStubResponse: { _ in + return HTTPStubsResponse(data: GitHub.userProfile("invalid").sampleData, statusCode: 400, headers: nil) }) - OHHTTPStubs.stubRequests(passingTest: {$0.url!.path == "/basic-auth/user/passwd"}, withStubResponse: { _ in - return OHHTTPStubsResponse(data: HTTPBin.basicAuth.sampleData, statusCode: 200, headers: nil) + HTTPStubs.stubRequests(passingTest: {$0.url!.path == "/basic-auth/user/passwd"}, withStubResponse: { _ in + return HTTPStubsResponse(data: HTTPBin.basicAuth.sampleData, statusCode: 200, headers: nil) }) } afterEach { - OHHTTPStubs.removeAllStubs() + HTTPStubs.removeAllStubs() } describe("valid endpoints") { diff --git a/Tests/MoyaTests/MoyaProviderSpec.swift b/Tests/MoyaTests/MoyaProviderSpec.swift index e842133a5..ca4632376 100644 --- a/Tests/MoyaTests/MoyaProviderSpec.swift +++ b/Tests/MoyaTests/MoyaProviderSpec.swift @@ -3,11 +3,9 @@ import Quick import Nimble import Foundation - -#if canImport(OHHTTPStubs) import OHHTTPStubs -#elseif canImport(OHHTTPStubsSwift) -import OHHTTPStubsCore + +#if canImport(OHHTTPStubsSwift) import OHHTTPStubsSwift #endif @@ -681,8 +679,8 @@ final class MoyaProviderSpec: QuickSpec { var provider: MoyaProvider! beforeEach { - OHHTTPStubs.stubRequests(passingTest: {$0.url!.path == "/zen"}, withStubResponse: { _ in - return OHHTTPStubsResponse(data: GitHub.zen.sampleData, statusCode: 200, headers: nil) + HTTPStubs.stubRequests(passingTest: {$0.url!.path == "/zen"}, withStubResponse: { _ in + return HTTPStubsResponse(data: GitHub.zen.sampleData, statusCode: 200, headers: nil) }) provider = MoyaProvider(trackInflights: true) } @@ -755,8 +753,8 @@ final class MoyaProviderSpec: QuickSpec { try? FileManager.default.removeItem(at: file) //`responseTime(-4)` equals to 1000 bytes at a time. The sample data is 4000 bytes. - OHHTTPStubs.stubRequests(passingTest: {$0.url!.path.hasSuffix("logo_github.png")}, withStubResponse: { _ in - return OHHTTPStubsResponse(data: GitHubUserContent.downloadMoyaWebContent("logo_github.png").sampleData, statusCode: 200, headers: nil).responseTime(-4) + HTTPStubs.stubRequests(passingTest: {$0.url!.path.hasSuffix("logo_github.png")}, withStubResponse: { _ in + return HTTPStubsResponse(data: GitHubUserContent.downloadMoyaWebContent("logo_github.png").sampleData, statusCode: 200, headers: nil).responseTime(-4) }) provider = MoyaProvider() } @@ -835,8 +833,8 @@ final class MoyaProviderSpec: QuickSpec { try? FileManager.default.removeItem(at: file) //`responseTime(-4)` equals to 1000 bytes at a time. The sample data is 4000 bytes. - OHHTTPStubs.stubRequests(passingTest: {$0.url!.path.hasSuffix("logo_github.png")}, withStubResponse: { _ in - return OHHTTPStubsResponse(data: GitHubUserContent.downloadMoyaWebContent("logo_github.png").sampleData, statusCode: 200, headers: ["Content-Length": ""]).responseTime(-4) + HTTPStubs.stubRequests(passingTest: {$0.url!.path.hasSuffix("logo_github.png")}, withStubResponse: { _ in + return HTTPStubsResponse(data: GitHubUserContent.downloadMoyaWebContent("logo_github.png").sampleData, statusCode: 200, headers: ["Content-Length": ""]).responseTime(-4) }) provider = MoyaProvider() } @@ -981,16 +979,16 @@ final class MoyaProviderSpec: QuickSpec { } describe("using a custom callback queue") { - var stubDescriptor: OHHTTPStubsDescriptor! + var stubDescriptor: HTTPStubsDescriptor! beforeEach { - stubDescriptor = OHHTTPStubs.stubRequests(passingTest: {$0.url!.path == "/zen"}, withStubResponse: { _ in - return OHHTTPStubsResponse(data: GitHub.zen.sampleData, statusCode: 200, headers: nil) + stubDescriptor = HTTPStubs.stubRequests(passingTest: {$0.url!.path == "/zen"}, withStubResponse: { _ in + return HTTPStubsResponse(data: GitHub.zen.sampleData, statusCode: 200, headers: nil) }) } afterEach { - OHHTTPStubs.removeStub(stubDescriptor) + HTTPStubs.removeStub(stubDescriptor) } describe("a provider with a predefined callback queue") {