diff --git a/.swift-version b/.swift-version index 8c50098d..5186d070 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -3.1 +4.0 diff --git a/.travis.yml b/.travis.yml index ddb9164c..7421724b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ matrix: include: - os: osx language: objective-c - osx_image: xcode8.3 + osx_image: xcode9 script: - set -o pipefail - xcodebuild build-for-testing test-without-building -workspace APIKit.xcworkspace -scheme APIKit -configuration Release ENABLE_TESTABILITY=YES | xcpretty -c @@ -16,7 +16,7 @@ matrix: - bash <(curl -s https://codecov.io/bash) - os: osx language: generic - osx_image: xcode8.3 + osx_image: xcode9 script: - swift build - swift test diff --git a/APIKit.podspec b/APIKit.podspec index c0bb9499..e5dfabf1 100644 --- a/APIKit.podspec +++ b/APIKit.podspec @@ -23,6 +23,8 @@ Pod::Spec.new do |s| :tag => "#{s.version}", } + s.pod_target_xcconfigs = { "SWIFT_VERSION" => "4.0" } + s.license = { :type => "MIT", :text => <<-LICENSE diff --git a/APIKit.xcodeproj/project.pbxproj b/APIKit.xcodeproj/project.pbxproj index 1dc7c5ba..afd625e4 100644 --- a/APIKit.xcodeproj/project.pbxproj +++ b/APIKit.xcodeproj/project.pbxproj @@ -127,7 +127,7 @@ 7F7048ED1D9D8A12003C99F6 /* ResponseError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ResponseError.swift; path = Sources/APIKit/Error/ResponseError.swift; sourceTree = SOURCE_ROOT; }; 7F7048EE1D9D8A12003C99F6 /* SessionTaskError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SessionTaskError.swift; path = Sources/APIKit/Error/SessionTaskError.swift; sourceTree = SOURCE_ROOT; }; 7F7048F21D9D8A1F003C99F6 /* URLEncodedSerialization.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = URLEncodedSerialization.swift; path = Sources/APIKit/Serializations/URLEncodedSerialization.swift; sourceTree = SOURCE_ROOT; }; - 7F8ECDFD1B6A799E00234E04 /* Demo.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Demo.playground; sourceTree = ""; }; + 7F8ECDFD1B6A799E00234E04 /* Demo.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Demo.playground; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 7FA1690C1D9D8C80006C982B /* HTTPStub.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HTTPStub.swift; sourceTree = ""; }; CD5115241B1FFBA900514240 /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Result.framework; sourceTree = BUILT_PRODUCTS_DIR; }; ECA831471DE4DDBF004EB1B5 /* ProtobufDataParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ProtobufDataParser.swift; path = Sources/APIKit/DataParser/ProtobufDataParser.swift; sourceTree = SOURCE_ROOT; }; @@ -402,7 +402,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0810; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = "Yosuke Ishikawa"; TargetAttributes = { 141F12161C1C9ABE0026D415 = { @@ -562,12 +562,18 @@ isa = XCBuildConfiguration; baseConfigurationReference = 141F12101C1C96820026D415 /* Debug.xcconfig */; buildSettings = { + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; ENABLE_TESTABILITY = YES; GCC_NO_COMMON_BLOCKS = YES; ONLY_ACTIVE_ARCH = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -575,10 +581,16 @@ isa = XCBuildConfiguration; baseConfigurationReference = 141F12111C1C96820026D415 /* Release.xcconfig */; buildSettings = { + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; GCC_NO_COMMON_BLOCKS = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; }; diff --git a/APIKit.xcodeproj/xcshareddata/xcschemes/APIKit.xcscheme b/APIKit.xcodeproj/xcshareddata/xcschemes/APIKit.xcscheme index 6fe3049d..4f7ccca7 100644 --- a/APIKit.xcodeproj/xcshareddata/xcschemes/APIKit.xcscheme +++ b/APIKit.xcodeproj/xcshareddata/xcschemes/APIKit.xcscheme @@ -1,6 +1,6 @@ @@ -70,6 +71,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 00000000..3236c9ea --- /dev/null +++ b/Package.resolved @@ -0,0 +1,16 @@ +{ + "object": { + "pins": [ + { + "package": "Result", + "repositoryURL": "https://github.com/antitypical/Result.git", + "state": { + "branch": null, + "revision": "7477584259bfce2560a19e06ad9f71db441fff11", + "version": "3.2.4" + } + } + ] + }, + "version": 1 +} diff --git a/Package.swift b/Package.swift index 8e80b74d..6d2402da 100644 --- a/Package.swift +++ b/Package.swift @@ -1,9 +1,24 @@ +// swift-tools-version:4.0 import PackageDescription let package = Package( name: "APIKit", + products: [ + .library(name: "APIKit", targets: ["APIKit"]), + ], dependencies: [ - .Package(url: "https://github.com/antitypical/Result.git", majorVersion: 3), + .package(url: "https://github.com/antitypical/Result.git", from: "3.0.0"), + ], + targets: [ + .target( + name: "APIKit", + dependencies: ["Result"], + exclude: ["BodyParameters/AbstractInputStream.m"] + ), + .testTarget( + name: "APIKitTests", + dependencies: ["APIKit"] + ), ], - exclude: ["Sources/APIKit/BodyParameters/AbstractInputStream.m"] + swiftLanguageVersions: [4] ) diff --git a/Sources/APIKit/Serializations/URLEncodedSerialization.swift b/Sources/APIKit/Serializations/URLEncodedSerialization.swift index cb996b39..1c13425d 100644 --- a/Sources/APIKit/Serializations/URLEncodedSerialization.swift +++ b/Sources/APIKit/Serializations/URLEncodedSerialization.swift @@ -27,7 +27,7 @@ private func escape(_ string: String) -> String { let endIndex = string.index(index, offsetBy: batchSize, limitedBy: string.endIndex) ?? string.endIndex let range = startIndex.. 0) - let boundary = (parameters.contentType as NSString).substring(with: match.first!.rangeAt(1)) + let boundary = (parameters.contentType as NSString).substring(with: match.first!.range(at: 1)) XCTAssertEqual(parameters.contentType, "multipart/form-data; boundary=\(boundary)") XCTAssertEqual(encodedData, "--\(boundary)\(returnCode)Content-Disposition: form-data; name=\"foo\"\(returnCode)\(returnCode)1\(returnCode)--\(boundary)\(returnCode)Content-Disposition: form-data; name=\"bar\"\(returnCode)\(returnCode)2\(returnCode)--\(boundary)--\(returnCode)") } catch { @@ -57,11 +57,11 @@ class MultipartFormDataParametersTests: XCTestCase { let pattern = "^multipart/form-data; boundary=([\\w.]+)$" let regexp = try NSRegularExpression(pattern: pattern, options: []) - let range = NSRange(location: 0, length: parameters.contentType.characters.count) + let range = NSRange(location: 0, length: parameters.contentType.count) let match = regexp.matches(in: parameters.contentType, options: [], range: range) XCTAssertTrue(match.count > 0) - let boundary = (parameters.contentType as NSString).substring(with: match.first!.rangeAt(1)) + let boundary = (parameters.contentType as NSString).substring(with: match.first!.range(at: 1)) XCTAssertEqual(parameters.contentType, "multipart/form-data; boundary=\(boundary)") XCTAssertEqual(encodedData, "--\(boundary)\(returnCode)Content-Disposition: form-data; name=\"foo\"\(returnCode)\(returnCode)1\(returnCode)--\(boundary)\(returnCode)Content-Disposition: form-data; name=\"bar\"\(returnCode)\(returnCode)2\(returnCode)--\(boundary)--\(returnCode)") } catch { @@ -92,11 +92,11 @@ class MultipartFormDataParametersTests: XCTestCase { let pattern = "^multipart/form-data; boundary=([\\w.]+)$" let regexp = try NSRegularExpression(pattern: pattern, options: []) - let range = NSRange(location: 0, length: parameters.contentType.characters.count) + let range = NSRange(location: 0, length: parameters.contentType.count) let match = regexp.matches(in: parameters.contentType, options: [], range: range) XCTAssertTrue(match.count > 0) - let boundary = (parameters.contentType as NSString).substring(with: match.first!.rangeAt(1)) + let boundary = (parameters.contentType as NSString).substring(with: match.first!.range(at: 1)) XCTAssertEqual(parameters.contentType, "multipart/form-data; boundary=\(boundary)") XCTAssertEqual(encodedData, "--\(boundary)\(returnCode)Content-Disposition: form-data; name=\"test\"; filename=\"test.json\"\r\nContent-Type: application/json\(returnCode)\(returnCode)\(testString)\(returnCode)--\(boundary)--\(returnCode)") } catch {