diff --git a/.circleci/config.yml b/.circleci/config.yml index d5834c5b5..c3eb382b8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,36 +1,55 @@ version: 2 +defaults: &defaults + macos: + xcode: '9.3.0' + parallelism: 1 + shell: /bin/bash --login + environment: + CIRCLE_ARTIFACTS: /tmp/circleci-artifacts + CIRCLE_TEST_REPORTS: /tmp/circleci-test-results + LANG: en_US.UTF-8 + BUNDLE_PATH: vendor/bundle jobs: + carthage_without_swiftlint_integration: + <<: *defaults + working_directory: ~/Moya/Moya_Carthage_1 + steps: + - checkout + - run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS + - restore_cache: + keys: + - v1-carthage-no-swiftlint-deps-{{ checksum "Cartfile.resolved" }} + - run: + name: Set Ruby Version + command: echo "ruby-2.4" > ~/.ruby-version + - run: + name: Update Homebrew + command: brew update + - run: + name: Carthage checkout + command: carthage checkout + - run: + name: Test Carthage Build before installing SwiftLint + command: carthage build --no-skip-current --cache-builds --no-use-binaries --verbose + - save_cache: + key: v1-carthage-no-swiftlint-deps-{{ checksum "Cartfile.resolved" }} + paths: + - Carthage build: + <<: *defaults working_directory: ~/Moya/Moya - parallelism: 1 - shell: /bin/bash --login - environment: - CIRCLE_ARTIFACTS: /tmp/circleci-artifacts - CIRCLE_TEST_REPORTS: /tmp/circleci-test-results - LANG: en_US.UTF-8 - BUNDLE_PATH: vendor/bundle - macos: - xcode: '9.2.0' steps: - checkout - run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS - restore_cache: keys: - - v1-dep-{{ .Branch }}- - - v1-dep-master- - - v1-dep- + - v1-dep-{{ checksum "Cartfile.resolved" }} - run: name: Set Ruby Version command: echo "ruby-2.4" > ~/.ruby-version - - run: - name: Fetch CocoaPods Specs - command: curl -sS https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash - run: name: Update Homebrew command: brew update - - run: - name: Test Carthage Build before installing SwiftLint - command: carthage build --no-skip-current --cache-builds - run: name: Install Swiftlint command: brew install swiftlint @@ -44,7 +63,7 @@ jobs: name: Bootstrap Carthage command: scripts/bootstrap-if-needed.sh - save_cache: - key: v1-dep-{{ .Branch }}-{{ epoch }} + key: v1-dep-{{ checksum "Cartfile.resolved" }} paths: - vendor/bundle - Carthage @@ -78,3 +97,9 @@ jobs: path: /tmp/circleci-artifacts - store_artifacts: path: /tmp/circleci-test-results +workflows: + version: 2 + pr_build: + jobs: + - build + - carthage_without_swiftlint_integration diff --git a/.swift-version b/.swift-version deleted file mode 100644 index 5186d0706..000000000 --- a/.swift-version +++ /dev/null @@ -1 +0,0 @@ -4.0 diff --git a/Moya.podspec b/Moya.podspec index f19fab666..59811e2e9 100644 --- a/Moya.podspec +++ b/Moya.podspec @@ -19,6 +19,8 @@ Pod::Spec.new do |s| s.tvos.deployment_target = '9.0' s.source = { :git => "https://github.com/Moya/Moya.git", :tag => s.version } s.default_subspec = "Core" + s.swift_version = '4.0' + s.cocoapods_version = '>= 1.4.0' s.subspec "Core" do |ss| ss.source_files = "Sources/Moya/", "Sources/Moya/Plugins/" diff --git a/Moya.xcodeproj/project.pbxproj b/Moya.xcodeproj/project.pbxproj index 32503d870..8aecb9de7 100644 --- a/Moya.xcodeproj/project.pbxproj +++ b/Moya.xcodeproj/project.pbxproj @@ -29,8 +29,8 @@ 149749431F8923EC00FA4900 /* AnyEncodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 149749421F8923EC00FA4900 /* AnyEncodable.swift */; }; 149749451F892E2F00FA4900 /* URLRequest+Encoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 149749441F892E2F00FA4900 /* URLRequest+Encoding.swift */; }; 15D3A2BD1223B59E2BBE09F0 /* MoyaError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D47F3DC51C28D950491FAAB /* MoyaError.swift */; }; - 1F8AA0BC1FE0630300C9D7B6 /* ValidationType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F8AA0BB1FE0630300C9D7B6 /* ValidationType.swift */; }; 1F24393320125F8200C9D813 /* EndpointClosureSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F24393220125F8200C9D813 /* EndpointClosureSpec.swift */; }; + 1F8AA0BC1FE0630300C9D7B6 /* ValidationType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F8AA0BB1FE0630300C9D7B6 /* ValidationType.swift */; }; 1FD44D9E21CEA6B6221807EF /* NetworkLoggerPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4553E5591EE96535C5310C02 /* NetworkLoggerPlugin.swift */; }; 2ADDFC96D7F7912333534C46 /* SignalProducer+Response.swift in Sources */ = {isa = PBXBuildFile; fileRef = 269C64D1ABED61A91DD873D3 /* SignalProducer+Response.swift */; }; 2C7132B56A7B129E12BAACAC /* EndpointSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = E825A32256FC030B8BA2684D /* EndpointSpec.swift */; }; @@ -150,8 +150,8 @@ 149749421F8923EC00FA4900 /* AnyEncodable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnyEncodable.swift; sourceTree = ""; }; 149749441F892E2F00FA4900 /* URLRequest+Encoding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URLRequest+Encoding.swift"; sourceTree = ""; }; 14FB7A3E1F3E089900308949 /* Single+Response.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Single+Response.swift"; sourceTree = ""; }; - 1F8AA0BB1FE0630300C9D7B6 /* ValidationType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValidationType.swift; sourceTree = ""; }; 1F24393220125F8200C9D813 /* EndpointClosureSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EndpointClosureSpec.swift; sourceTree = ""; }; + 1F8AA0BB1FE0630300C9D7B6 /* ValidationType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValidationType.swift; sourceTree = ""; }; 225C397C03E17F7DFBCA2848 /* MoyaProvider+Internal.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = "MoyaProvider+Internal.swift"; sourceTree = ""; }; 269C64D1ABED61A91DD873D3 /* SignalProducer+Response.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = "SignalProducer+Response.swift"; sourceTree = ""; }; 2AD20F6A819D899E3278E903 /* NetworkActivityPlugin.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = NetworkActivityPlugin.swift; sourceTree = ""; }; @@ -981,7 +981,7 @@ SKIP_INSTALL = YES; SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1032,7 +1032,7 @@ SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1077,7 +1077,7 @@ SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TVOS_DEPLOYMENT_TARGET = 9.0; WATCHOS_DEPLOYMENT_TARGET = 2.0; }; @@ -1173,7 +1173,7 @@ SKIP_INSTALL = YES; SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1386,7 +1386,7 @@ SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1492,7 +1492,7 @@ SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1534,7 +1534,7 @@ SDKROOT = macosx; SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TVOS_DEPLOYMENT_TARGET = 9.0; WATCHOS_DEPLOYMENT_TARGET = 2.0; }; @@ -1582,7 +1582,7 @@ SKIP_INSTALL = YES; SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; diff --git a/Sources/Moya/Image.swift b/Sources/Moya/Image.swift index 6e82908e8..233be5f2a 100644 --- a/Sources/Moya/Image.swift +++ b/Sources/Moya/Image.swift @@ -1,7 +1,7 @@ #if os(iOS) || os(watchOS) || os(tvOS) import UIKit.UIImage public typealias ImageType = UIImage -#elseif os(OSX) +#elseif os(macOS) import AppKit.NSImage public typealias ImageType = NSImage #endif diff --git a/Sources/Moya/Plugins/AccessTokenPlugin.swift b/Sources/Moya/Plugins/AccessTokenPlugin.swift index 1d56aca21..e1234e223 100644 --- a/Sources/Moya/Plugins/AccessTokenPlugin.swift +++ b/Sources/Moya/Plugins/AccessTokenPlugin.swift @@ -77,7 +77,7 @@ public struct AccessTokenPlugin: PluginType { let authorizationType = authorizable.authorizationType var request = request - + switch authorizationType { case .basic, .bearer, .custom: if let value = authorizationType.value { diff --git a/Sources/ReactiveMoya/SignalProducer+Response.swift b/Sources/ReactiveMoya/SignalProducer+Response.swift index b0129e0ef..f2e01d418 100644 --- a/Sources/ReactiveMoya/SignalProducer+Response.swift +++ b/Sources/ReactiveMoya/SignalProducer+Response.swift @@ -4,6 +4,13 @@ import ReactiveSwift import Moya #endif +// just to try if this fixes the build +#if os(iOS) || os(watchOS) || os(tvOS) +import UIKit.UIImage +#elseif os(macOS) +import AppKit.NSImage +#endif + /// Extension for processing raw NSData generated by network access. extension SignalProducerProtocol where Value == Response, Error == MoyaError { diff --git a/Sources/RxMoya/Observable+Response.swift b/Sources/RxMoya/Observable+Response.swift index 1e6dc89ed..9847dd38c 100644 --- a/Sources/RxMoya/Observable+Response.swift +++ b/Sources/RxMoya/Observable+Response.swift @@ -4,6 +4,13 @@ import RxSwift import Moya #endif +// just to try if this fixes the build +#if os(iOS) || os(watchOS) || os(tvOS) +import UIKit.UIImage +#elseif os(macOS) +import AppKit.NSImage +#endif + /// Extension for processing raw NSData generated by network access. extension ObservableType where E == Response { diff --git a/Sources/RxMoya/Single+Response.swift b/Sources/RxMoya/Single+Response.swift index 1373b6ad4..5ae55ab67 100644 --- a/Sources/RxMoya/Single+Response.swift +++ b/Sources/RxMoya/Single+Response.swift @@ -4,6 +4,13 @@ import RxSwift import Moya #endif +// just to try if this fixes the build +#if os(iOS) || os(watchOS) || os(tvOS) +import UIKit.UIImage +#elseif os(macOS) +import AppKit.NSImage +#endif + /// Extension for processing raw NSData generated by network access. extension PrimitiveSequence where TraitType == SingleTrait, ElementType == Response { diff --git a/Tests/MoyaProviderIntegrationTests.swift b/Tests/MoyaProviderIntegrationTests.swift index 3504dc5e8..fffd267b2 100644 --- a/Tests/MoyaProviderIntegrationTests.swift +++ b/Tests/MoyaProviderIntegrationTests.swift @@ -237,7 +237,7 @@ final class MoyaProviderIntegrationTests: QuickSpec { plugin = NetworkLoggerPlugin(verbose: true, output: { (_, _, printing: Any...) in //mapping the Any... from items to a string that can be compared - let stringArray: [String] = printing.map { $0 as? String }.flatMap { $0 } + let stringArray: [String] = printing.map { $0 as? String }.compactMap { $0 } let string: String = stringArray.reduce("") { $0 + $1 + " " } log += string }) diff --git a/Tests/NetworkLoggerPluginSpec.swift b/Tests/NetworkLoggerPluginSpec.swift index 62c8131ac..3d12ad8a9 100644 --- a/Tests/NetworkLoggerPluginSpec.swift +++ b/Tests/NetworkLoggerPluginSpec.swift @@ -10,21 +10,21 @@ final class NetworkLoggerPluginSpec: QuickSpec { var log = "" let plugin = NetworkLoggerPlugin(verbose: true, output: { (_, _, printing: Any...) in //mapping the Any... from items to a string that can be compared - let stringArray: [String] = printing.map { $0 as? String }.flatMap { $0 } + let stringArray: [String] = printing.map { $0 as? String }.compactMap { $0 } let string: String = stringArray.reduce("") { $0 + $1 + " " } log += string }) let pluginWithCurl = NetworkLoggerPlugin(verbose: true, cURL: true, output: { (_, _, printing: Any...) in //mapping the Any... from items to a string that can be compared - let stringArray: [String] = printing.map { $0 as? String }.flatMap { $0 } + let stringArray: [String] = printing.map { $0 as? String }.compactMap { $0 } let string: String = stringArray.reduce("") { $0 + $1 + " " } log += string }) let pluginWithRequestDataFormatter = NetworkLoggerPlugin(verbose: true, output: { (_, _, printing: Any...) in //mapping the Any... from items to a string that can be compared - let stringArray: [String] = printing.map { $0 as? String }.flatMap { $0 } + let stringArray: [String] = printing.map { $0 as? String }.compactMap { $0 } let string: String = stringArray.reduce("") { $0 + $1 + " " } log += string }, responseDataFormatter: { _ in @@ -33,7 +33,7 @@ final class NetworkLoggerPluginSpec: QuickSpec { let pluginWithResponseDataFormatter = NetworkLoggerPlugin(verbose: true, output: { (_, _, printing: Any...) in //mapping the Any... from items to a string that can be compared - let stringArray: [String] = printing.map { $0 as? String }.flatMap { $0 } + let stringArray: [String] = printing.map { $0 as? String }.compactMap { $0 } let string: String = stringArray.reduce("") { $0 + $1 + " " } log += string }, responseDataFormatter: { _ in diff --git a/Tests/TestHelpers.swift b/Tests/TestHelpers.swift index 7e7bf83a7..e5b1a59f7 100644 --- a/Tests/TestHelpers.swift +++ b/Tests/TestHelpers.swift @@ -3,7 +3,7 @@ import Moya #if os(iOS) || os(watchOS) || os(tvOS) import UIKit import Foundation -#elseif os(OSX) +#elseif os(macOS) import AppKit #endif @@ -239,11 +239,11 @@ extension ImageType { func asJPEGRepresentation(_ compression: CGFloat) -> Data? { return UIImageJPEGRepresentation(self, compression) } - #elseif os(OSX) + #elseif os(macOS) func asJPEGRepresentation(_ compression: CGFloat) -> Data? { var imageRect = CGRect(x: 0, y: 0, width: self.size.width, height: self.size.height) let imageRep = NSBitmapImageRep(cgImage: self.cgImage(forProposedRect: &imageRect, context: nil, hints: nil)!) - return imageRep.representation(using: .JPEG, properties: [:]) + return imageRep.representation(using: .jpeg, properties: [:]) } #endif }