From 922050662d5091cbe214dd9f143573f4ea913a1b Mon Sep 17 00:00:00 2001 From: Max Howell Date: Wed, 27 Jul 2016 13:39:14 -0700 Subject: [PATCH 01/14] Set swift version used to 3.0 --- OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj b/OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj index 3a4f4e4d..594cc08f 100644 --- a/OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj +++ b/OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj @@ -1316,7 +1316,7 @@ MODULEMAP_FILE = "$(SRCROOT)/Supporting Files/module.modulemap"; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; TVOS_DEPLOYMENT_TARGET = 9.0; }; name = Debug; @@ -1353,7 +1353,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.9; MODULEMAP_FILE = "$(SRCROOT)/Supporting Files/module.modulemap"; SDKROOT = iphoneos; - SWIFT_VERSION = 2.3; + SWIFT_VERSION = 3.0; TVOS_DEPLOYMENT_TARGET = 9.0; VALIDATE_PRODUCT = YES; }; From 706ac3f59972d53af963a7cfa3b901df00a490c5 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Wed, 27 Jul 2016 13:52:32 -0700 Subject: [PATCH 02/14] Update schemes, build options and use Swift 3 syntax --- .../OHHTTPStubs.xcodeproj/project.pbxproj | 40 ++++++++++++------- .../OHHTTPStubs Mac Framework.xcscheme | 2 +- .../OHHTTPStubs iOS Framework.xcscheme | 2 +- .../OHHTTPStubs iOS StaticLib.xcscheme | 2 +- .../OHHTTPStubs tvOS Framework.xcscheme | 2 +- .../Sources/Swift/OHHTTPStubsSwift.swift | 34 ++++++++-------- 6 files changed, 46 insertions(+), 36 deletions(-) diff --git a/OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj b/OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj index 594cc08f..dd01f7f6 100644 --- a/OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj +++ b/OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj @@ -804,7 +804,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0710; - LastUpgradeCheck = 0700; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = AliSoftware; TargetAttributes = { 09110A5019805F4800D175E4 = { @@ -1291,14 +1291,17 @@ CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGNING_REQUIRED = NO; CODE_SIGN_IDENTITY = ""; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 5.1.0; + ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -1336,13 +1339,16 @@ CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGNING_REQUIRED = NO; CODE_SIGN_IDENTITY = ""; COPY_PHASE_STRIP = YES; CURRENT_PROJECT_VERSION = 5.1.0; ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; @@ -1363,7 +1369,7 @@ isa = XCBuildConfiguration; buildSettings = { DSTROOT = /tmp/OHHTTPStubs.dst; - IPHONEOS_DEPLOYMENT_TARGET = 5.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = OHHTTPStubs; SKIP_INSTALL = YES; @@ -1374,7 +1380,7 @@ isa = XCBuildConfiguration; buildSettings = { DSTROOT = /tmp/OHHTTPStubs.dst; - IPHONEOS_DEPLOYMENT_TARGET = 5.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = OHHTTPStubs; SKIP_INSTALL = YES; @@ -1392,7 +1398,7 @@ "OHHTTPSTUBS_USE_STATIC_LIBRARY=1", ); INFOPLIST_FILE = "UnitTests/UnitTests-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -1415,7 +1421,7 @@ "OHHTTPSTUBS_USE_STATIC_LIBRARY=1", ); INFOPLIST_FILE = "UnitTests/UnitTests-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -1475,6 +1481,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = "com.alisoftware.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; WRAPPER_EXTENSION = xctest; }; name = Release; @@ -1482,11 +1489,11 @@ 095981E119806A7900807DBE /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = "$(CURRENT_PROJECT_VERSION)"; - EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(DEVELOPER_FRAMEWORKS_DIR)", @@ -1503,7 +1510,6 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.alisoftware.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = OHHTTPStubs; SDKROOT = macosx; - SWIFT_VERSION = 2.3; WRAPPER_EXTENSION = framework; }; name = Debug; @@ -1511,12 +1517,12 @@ 095981E219806A7900807DBE /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; COMBINE_HIDPI_IMAGES = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = "$(CURRENT_PROJECT_VERSION)"; - EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(DEVELOPER_FRAMEWORKS_DIR)", @@ -1529,7 +1535,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.alisoftware.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = OHHTTPStubs; SDKROOT = macosx; - SWIFT_VERSION = 2.3; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; WRAPPER_EXTENSION = framework; }; name = Release; @@ -1538,9 +1544,9 @@ isa = XCBuildConfiguration; baseConfigurationReference = FADAD1A74682F410A97EE06F /* Pods-TestingPods-OHHTTPStubs Mac Tests.debug.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES; COMBINE_HIDPI_IMAGES = YES; - EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; FRAMEWORK_SEARCH_PATHS = ( "$(DEVELOPER_FRAMEWORKS_DIR)", "$(inherited)", @@ -1567,10 +1573,10 @@ isa = XCBuildConfiguration; baseConfigurationReference = 070E9B74647A6F3AE67C97A7 /* Pods-TestingPods-OHHTTPStubs Mac Tests.release.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES; COMBINE_HIDPI_IMAGES = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; FRAMEWORK_SEARCH_PATHS = ( "$(DEVELOPER_FRAMEWORKS_DIR)", "$(inherited)", @@ -1585,6 +1591,7 @@ ); PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; WRAPPER_EXTENSION = xctest; }; name = Release; @@ -1592,12 +1599,12 @@ 725CD9AE1A9EB65200F84C8B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CLANG_WARN_UNREACHABLE_CODE = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = "$(CURRENT_PROJECT_VERSION)"; DYLIB_INSTALL_NAME_BASE = "@rpath"; - EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -1617,12 +1624,12 @@ 725CD9AF1A9EB65200F84C8B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CLANG_WARN_UNREACHABLE_CODE = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = "$(CURRENT_PROJECT_VERSION)"; DYLIB_INSTALL_NAME_BASE = "@rpath"; - EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; INFOPLIST_FILE = "Supporting Files/OHHTTPStubs iOS-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; @@ -1631,6 +1638,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.alisoftware.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = OHHTTPStubs; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -1668,18 +1676,19 @@ PRODUCT_BUNDLE_IDENTIFIER = "alisoftware.OHHTTPStubs-tvOS-Fmk-Tests"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; }; EAA436A31BE1598D000E9E99 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CLANG_WARN_UNREACHABLE_CODE = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = "$(CURRENT_PROJECT_VERSION)"; DYLIB_INSTALL_NAME_BASE = "@rpath"; - EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -1700,12 +1709,12 @@ EAA436A41BE1598D000E9E99 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CLANG_WARN_UNREACHABLE_CODE = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = "$(CURRENT_PROJECT_VERSION)"; DYLIB_INSTALL_NAME_BASE = "@rpath"; - EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; INFOPLIST_FILE = "Supporting Files/OHHTTPStubs iOS-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; @@ -1715,6 +1724,7 @@ PRODUCT_NAME = OHHTTPStubs; SDKROOT = appletvos; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_VERSION = 2.3; }; name = Release; diff --git a/OHHTTPStubs/OHHTTPStubs.xcodeproj/xcshareddata/xcschemes/OHHTTPStubs Mac Framework.xcscheme b/OHHTTPStubs/OHHTTPStubs.xcodeproj/xcshareddata/xcschemes/OHHTTPStubs Mac Framework.xcscheme index f5a14781..42afc85e 100644 --- a/OHHTTPStubs/OHHTTPStubs.xcodeproj/xcshareddata/xcschemes/OHHTTPStubs Mac Framework.xcscheme +++ b/OHHTTPStubs/OHHTTPStubs.xcodeproj/xcshareddata/xcschemes/OHHTTPStubs Mac Framework.xcscheme @@ -1,6 +1,6 @@ OHHTTPStubsDescriptor { - return OHHTTPStubs.stubRequestsPassingTest(condition, withStubResponse: response) + return OHHTTPStubs.stubRequests(passingTest: condition, withStubResponse: response) } @@ -68,7 +68,7 @@ public func stub(condition: OHHTTPStubsTestBlock, response: OHHTTPStubsResponseB * is using the GET method */ public func isMethodGET() -> OHHTTPStubsTestBlock { - return { $0.HTTPMethod == "GET" } + return { $0.httpMethod == "GET" } } /** @@ -78,7 +78,7 @@ public func isMethodGET() -> OHHTTPStubsTestBlock { * is using the POST method */ public func isMethodPOST() -> OHHTTPStubsTestBlock { - return { $0.HTTPMethod == "POST" } + return { $0.httpMethod == "POST" } } /** @@ -88,7 +88,7 @@ public func isMethodPOST() -> OHHTTPStubsTestBlock { * is using the PUT method */ public func isMethodPUT() -> OHHTTPStubsTestBlock { - return { $0.HTTPMethod == "PUT" } + return { $0.httpMethod == "PUT" } } /** @@ -98,7 +98,7 @@ public func isMethodPUT() -> OHHTTPStubsTestBlock { * is using the PATCH method */ public func isMethodPATCH() -> OHHTTPStubsTestBlock { - return { $0.HTTPMethod == "PATCH" } + return { $0.httpMethod == "PATCH" } } /** @@ -108,7 +108,7 @@ public func isMethodPATCH() -> OHHTTPStubsTestBlock { * is using the DELETE method */ public func isMethodDELETE() -> OHHTTPStubsTestBlock { - return { $0.HTTPMethod == "DELETE" } + return { $0.httpMethod == "DELETE" } } /** @@ -120,7 +120,7 @@ public func isMethodDELETE() -> OHHTTPStubsTestBlock { * has the given scheme */ public func isScheme(scheme: String) -> OHHTTPStubsTestBlock { - return { req in req.URL?.scheme == scheme } + return { req in req.url?.scheme == scheme } } /** @@ -132,7 +132,7 @@ public func isScheme(scheme: String) -> OHHTTPStubsTestBlock { * has the given host */ public func isHost(host: String) -> OHHTTPStubsTestBlock { - return { req in req.URL?.host == host } + return { req in req.url?.host == host } } /** @@ -147,7 +147,7 @@ public func isHost(host: String) -> OHHTTPStubsTestBlock { * should include in the `path` parameter unless you're testing relative URLs) */ public func isPath(path: String) -> OHHTTPStubsTestBlock { - return { req in req.URL?.path == path } + return { req in req.url?.path == path } } /** @@ -162,7 +162,7 @@ public func isPath(path: String) -> OHHTTPStubsTestBlock { * should include in the `path` parameter unless you're testing relative URLs) */ public func pathStartsWith(path: String) -> OHHTTPStubsTestBlock { - return { req in req.URL?.path?.hasPrefix(path) ?? false } + return { req in req.url?.path?.hasPrefix(path) ?? false } } /** @@ -174,7 +174,7 @@ public func pathStartsWith(path: String) -> OHHTTPStubsTestBlock { * ends with the given extension */ public func isExtension(ext: String) -> OHHTTPStubsTestBlock { - return { req in req.URL?.pathExtension == ext } + return { req in req.url?.pathExtension == ext } } /** @@ -192,8 +192,8 @@ public func isExtension(ext: String) -> OHHTTPStubsTestBlock { @available(iOS 8.0, OSX 10.10, *) public func containsQueryParams(params: [String:String?]) -> OHHTTPStubsTestBlock { return { req in - if let url = req.URL { - let comps = NSURLComponents(URL: url, resolvingAgainstBaseURL: true) + if let url = req.url { + let comps = NSURLComponents(url: url, resolvingAgainstBaseURL: true) if let queryItems = comps?.queryItems { for (k,v) in params { if queryItems.filter({ qi in qi.name == k && qi.value == v }).count == 0 { return false } @@ -212,8 +212,8 @@ public func containsQueryParams(params: [String:String?]) -> OHHTTPStubsTestBloc * - Returns: a matcher that returns true if the `NSURLRequest`'s headers contain a value for the key name */ public func hasHeaderNamed(name: String) -> OHHTTPStubsTestBlock { - return { (req: NSURLRequest) -> Bool in - return req.valueForHTTPHeaderField(name) != nil + return { (req: URLRequest) -> Bool in + return req.value(forHTTPHeaderField: name) != nil } } @@ -226,8 +226,8 @@ public func hasHeaderNamed(name: String) -> OHHTTPStubsTestBlock { * is equal to the parameter value */ public func hasHeaderNamed(name: String, value: String) -> OHHTTPStubsTestBlock { - return { (req: NSURLRequest) -> Bool in - return req.valueForHTTPHeaderField(name) == value + return { (req: URLRequest) -> Bool in + return req.value(forHTTPHeaderField: name) == value } } From a31c5d40e7e6bd85d5e4cab225554646747a797d Mon Sep 17 00:00:00 2001 From: Max Howell Date: Thu, 28 Jul 2016 11:37:19 -0700 Subject: [PATCH 03/14] Add extensions to support Swift 3 syntax in Swift 2.x code --- .../OHHTTPStubs.xcodeproj/project.pbxproj | 2 ++ .../Sources/Swift/OHHTTPStubsSwift.swift | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj b/OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj index dd01f7f6..28001630 100644 --- a/OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj +++ b/OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj @@ -1510,6 +1510,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.alisoftware.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = OHHTTPStubs; SDKROOT = macosx; + SWIFT_VERSION = 3.0; WRAPPER_EXTENSION = framework; }; name = Debug; @@ -1536,6 +1537,7 @@ PRODUCT_NAME = OHHTTPStubs; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; WRAPPER_EXTENSION = framework; }; name = Release; diff --git a/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift b/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift index 3c229af9..a7316f65 100644 --- a/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift +++ b/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift @@ -27,6 +27,36 @@ */ +#if swift(>=3.0) +#else +#if swift(>=2.2) + extension OHHTTPStubs { + private class func stubRequests(passingTest passingTest: OHHTTPStubsTestBlock, withStubResponse: OHHTTPStubsResponseBlock) -> OHHTTPStubsDescriptor { + return stubRequestsPassingTest(passingTest, withStubResponse: withStubResponse) + } + } + + extension NSURLRequest { + private var httpMethod: String? { return HTTPMethod } + private var url: NSURL? { return URL } + } + + extension NSURLComponents { + private convenience init?(url: NSURL, resolvingAgainstBaseURL: Bool) { + self.init(URL: url, resolvingAgainstBaseURL: resolvingAgainstBaseURL) + } + } + + private typealias URLRequest = NSURLRequest + + extension URLRequest { + private func value(forHTTPHeaderField key: String) -> String? { + return valueForHTTPHeaderField(key) + } + } +#endif +#endif + // MARK: Syntaxic Sugar for OHHTTPStubs From 10ad179e172c0201e23553cf9b98bfa019f555e7 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Mon, 1 Aug 2016 12:13:05 -0700 Subject: [PATCH 04/14] Fix pathStartsWith for tvOS --- OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift b/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift index a7316f65..7cd39bca 100644 --- a/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift +++ b/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift @@ -192,7 +192,11 @@ public func isPath(path: String) -> OHHTTPStubsTestBlock { * should include in the `path` parameter unless you're testing relative URLs) */ public func pathStartsWith(path: String) -> OHHTTPStubsTestBlock { +#if os(tvOS) return { req in req.url?.path?.hasPrefix(path) ?? false } +#else + return { req in req.url?.path.hasPrefix(path) ?? false } +#endif } /** From e5bb3801a5f80ebb6a7f531034544068339e91f0 Mon Sep 17 00:00:00 2001 From: Liquidsoul Date: Tue, 9 Aug 2016 15:05:42 +0200 Subject: [PATCH 05/14] Make lib and tests compile with Xcode 8 beta 4 All tests do not pass yet --- .../Sources/Swift/OHHTTPStubsSwift.swift | 26 +++-- .../Test Suites/SwiftHelpersTests.swift | 109 +++++++++++++++--- 2 files changed, 111 insertions(+), 24 deletions(-) diff --git a/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift b/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift index 7cd39bca..bde2daa8 100644 --- a/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift +++ b/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift @@ -37,8 +37,8 @@ } extension NSURLRequest { - private var httpMethod: String? { return HTTPMethod } - private var url: NSURL? { return URL } + var httpMethod: String? { return HTTPMethod } + var url: NSURL? { return URL } } extension NSURLComponents { @@ -149,7 +149,7 @@ public func isMethodDELETE() -> OHHTTPStubsTestBlock { * - Returns: a matcher (OHHTTPStubsTestBlock) that succeeds only if the request * has the given scheme */ -public func isScheme(scheme: String) -> OHHTTPStubsTestBlock { +public func isScheme(_ scheme: String) -> OHHTTPStubsTestBlock { return { req in req.url?.scheme == scheme } } @@ -161,7 +161,7 @@ public func isScheme(scheme: String) -> OHHTTPStubsTestBlock { * - Returns: a matcher (OHHTTPStubsTestBlock) that succeeds only if the request * has the given host */ -public func isHost(host: String) -> OHHTTPStubsTestBlock { +public func isHost(_ host: String) -> OHHTTPStubsTestBlock { return { req in req.url?.host == host } } @@ -176,7 +176,7 @@ public func isHost(host: String) -> OHHTTPStubsTestBlock { * - Note: URL paths are usually absolute and thus starts with a '/' (which you * should include in the `path` parameter unless you're testing relative URLs) */ -public func isPath(path: String) -> OHHTTPStubsTestBlock { +public func isPath(_ path: String) -> OHHTTPStubsTestBlock { return { req in req.url?.path == path } } @@ -191,11 +191,15 @@ public func isPath(path: String) -> OHHTTPStubsTestBlock { * - Note: URL paths are usually absolute and thus starts with a '/' (which you * should include in the `path` parameter unless you're testing relative URLs) */ -public func pathStartsWith(path: String) -> OHHTTPStubsTestBlock { +public func pathStartsWith(_ path: String) -> OHHTTPStubsTestBlock { +#if swift(>=3.0) + return { req in req.url?.path.hasPrefix(path) ?? false } +#else #if os(tvOS) return { req in req.url?.path?.hasPrefix(path) ?? false } #else - return { req in req.url?.path.hasPrefix(path) ?? false } + return { req in req.url?.path?.hasPrefix(path) ?? false } +#endif #endif } @@ -207,7 +211,7 @@ public func pathStartsWith(path: String) -> OHHTTPStubsTestBlock { * - Returns: a matcher (OHHTTPStubsTestBlock) that succeeds only if the request path * ends with the given extension */ -public func isExtension(ext: String) -> OHHTTPStubsTestBlock { +public func isExtension(_ ext: String) -> OHHTTPStubsTestBlock { return { req in req.url?.pathExtension == ext } } @@ -224,7 +228,7 @@ public func isExtension(ext: String) -> OHHTTPStubsTestBlock { * (2) using `[q:nil]`, which matches a query parameter "?q" without a value at all */ @available(iOS 8.0, OSX 10.10, *) -public func containsQueryParams(params: [String:String?]) -> OHHTTPStubsTestBlock { +public func containsQueryParams(_ params: [String:String?]) -> OHHTTPStubsTestBlock { return { req in if let url = req.url { let comps = NSURLComponents(url: url, resolvingAgainstBaseURL: true) @@ -245,7 +249,7 @@ public func containsQueryParams(params: [String:String?]) -> OHHTTPStubsTestBloc * * - Returns: a matcher that returns true if the `NSURLRequest`'s headers contain a value for the key name */ -public func hasHeaderNamed(name: String) -> OHHTTPStubsTestBlock { +public func hasHeaderNamed(_ name: String) -> OHHTTPStubsTestBlock { return { (req: URLRequest) -> Bool in return req.value(forHTTPHeaderField: name) != nil } @@ -259,7 +263,7 @@ public func hasHeaderNamed(name: String) -> OHHTTPStubsTestBlock { * - Returns: a matcher that returns true if the `NSURLRequest`'s headers contain a value for the key name and it's value * is equal to the parameter value */ -public func hasHeaderNamed(name: String, value: String) -> OHHTTPStubsTestBlock { +public func hasHeaderNamed(_ name: String, value: String) -> OHHTTPStubsTestBlock { return { (req: URLRequest) -> Bool in return req.value(forHTTPHeaderField: name) == value } diff --git a/OHHTTPStubs/UnitTests/Test Suites/SwiftHelpersTests.swift b/OHHTTPStubs/UnitTests/Test Suites/SwiftHelpersTests.swift index 26749dbb..b6de43d1 100644 --- a/OHHTTPStubs/UnitTests/Test Suites/SwiftHelpersTests.swift +++ b/OHHTTPStubs/UnitTests/Test Suites/SwiftHelpersTests.swift @@ -8,18 +8,44 @@ import Foundation import XCTest -import OHHTTPStubs +@testable import OHHTTPStubs + +#if swift(>=3.0) +#else +#if swift(>=2.2) + extension SequenceType { + private func enumerated() -> EnumerateSequence { + return enumerate() + } + } + + extension NSMutableURLRequest { + override var httpMethod: String? { + get { + return HTTPMethod + } + set(method) { + self.HTTPMethod = method! + } + } + } +#endif +#endif class SwiftHelpersTests : XCTestCase { - + func testHTTPMethod() { let methods = ["GET", "PUT", "PATCH", "POST", "DELETE", "FOO"] let matchers = [isMethodGET(), isMethodPUT(), isMethodPATCH(), isMethodPOST(), isMethodDELETE()] - - for (idxMethod, method) in methods.enumerate() { + + for (idxMethod, method) in methods.enumerated() { +#if swift(>=3.0) + var req = URLRequest(url: URL(string: "foo://bar")!) +#else let req = NSMutableURLRequest(URL: NSURL(string: "foo://bar")!) - req.HTTPMethod = method - for (idxMatcher, matcher) in matchers.enumerate() { +#endif + req.httpMethod = method + for (idxMatcher, matcher) in matchers.enumerated() { let expected = idxMethod == idxMatcher // expect to be true only if indexes match XCTAssert(matcher(req) == expected, "Function is\(methods[idxMatcher])() failed to test request with HTTP method \(method).") } @@ -39,7 +65,11 @@ class SwiftHelpersTests : XCTestCase { ] for (url, result) in urls { +#if swift(>=3.0) + let req = URLRequest(url: URL(string: url)!) +#else let req = NSURLRequest(URL: NSURL(string: url)!) +#endif XCTAssert(matcher(req) == result, "isScheme(\"foo\") matcher failed when testing url \(url)") } } @@ -56,7 +86,11 @@ class SwiftHelpersTests : XCTestCase { ] for (url, result) in urls { +#if swift(>=3.0) + let req = URLRequest(url: URL(string: url)!) +#else let req = NSURLRequest(URL: NSURL(string: url)!) +#endif XCTAssert(matcher(req) == result, "isHost(\"foo\") matcher failed when testing url \(url)") } } @@ -69,7 +103,7 @@ class SwiftHelpersTests : XCTestCase { testIsPath("foo/bar/baz", isAbsoluteMatcher: false) } - func testIsPath(path: String, isAbsoluteMatcher: Bool) { + func testIsPath(_ path: String, isAbsoluteMatcher: Bool) { let matcher = isPath(path) let urls = [ @@ -98,8 +132,12 @@ class SwiftHelpersTests : XCTestCase { ] for (url, result) in urls { +#if swift(>=3.0) + let req = URLRequest(url: URL(string: url)!) +#else let req = NSURLRequest(URL: NSURL(string: url)!) - let p = req.URL?.path +#endif + let p = req.url?.path print("URL: \(url) -> Path: \(p)") XCTAssert(matcher(req) == result, "isPath(\"\(path)\" matcher failed when testing url \(url)") } @@ -113,7 +151,7 @@ class SwiftHelpersTests : XCTestCase { testPathStartsWith("foo/bar", isAbsoluteMatcher: false) } - func testPathStartsWith(path: String, isAbsoluteMatcher: Bool) { + func testPathStartsWith(_ path: String, isAbsoluteMatcher: Bool) { let matcher = pathStartsWith(path) let urls = [ @@ -143,8 +181,12 @@ class SwiftHelpersTests : XCTestCase { ] for (url, result) in urls { +#if swift(>=3.0) + let req = URLRequest(url: URL(string: url)!) +#else let req = NSURLRequest(URL: NSURL(string: url)!) - let p = req.URL?.path +#endif + let p = req.url?.path print("URL: \(url) -> Path: \(p)") XCTAssert(matcher(req) == result, "pathStartsWith(\"\(path)\" matcher failed when testing url \(url)") } @@ -164,7 +206,11 @@ class SwiftHelpersTests : XCTestCase { ] for (url, result) in urls { +#if swift(>=3.0) + let req = URLRequest(url: URL(string: url)!) +#else let req = NSURLRequest(URL: NSURL(string: url)!) +#endif XCTAssert(matcher(req) == result, "isExtension(\"txt\") matcher failed when testing url \(url)") } @@ -196,13 +242,22 @@ class SwiftHelpersTests : XCTestCase { ] for (url, result) in urls { +#if swift(>=3.0) + let req = URLRequest(url: URL(string: url)!) +#else let req = NSURLRequest(URL: NSURL(string: url)!) +#endif + XCTAssert(matcher(req) == result, "containsQueryParams(\"\(params)\") matcher failed when testing url \(url)") } } func testHasHeaderNamedIsTrue() { +#if swift(>=3.0) + var req = URLRequest(url: URL(string: "foo://bar")!) +#else let req = NSMutableURLRequest(URL: NSURL(string: "foo://bar")!) +#endif req.addValue("1234567890", forHTTPHeaderField: "ArbitraryKey") let hasHeader = hasHeaderNamed("ArbitraryKey")(req) @@ -211,7 +266,11 @@ class SwiftHelpersTests : XCTestCase { } func testHasHeaderNamedIsFalse() { - let req = NSMutableURLRequest(URL: NSURL(string: "foo://bar")!) +#if swift(>=3.0) + let req = URLRequest(url: URL(string: "foo://bar")!) +#else + let req = NSURLRequest(URL: NSURL(string: "foo://bar")!) +#endif let hasHeader = hasHeaderNamed("ArbitraryKey")(req) @@ -219,7 +278,11 @@ class SwiftHelpersTests : XCTestCase { } func testHeaderValueForKeyEqualsIsTrue() { +#if swift(>=3.0) + var req = URLRequest(url: URL(string: "foo://bar")!) +#else let req = NSMutableURLRequest(URL: NSURL(string: "foo://bar")!) +#endif req.addValue("bar", forHTTPHeaderField: "foo") let matchesHeader = hasHeaderNamed("foo", value: "bar")(req) @@ -228,7 +291,11 @@ class SwiftHelpersTests : XCTestCase { } func testHeaderValueForKeyEqualsIsFalse() { +#if swift(>=3.0) + var req = URLRequest(url: URL(string: "foo://bar")!) +#else let req = NSMutableURLRequest(URL: NSURL(string: "foo://bar")!) +#endif req.addValue("bar", forHTTPHeaderField: "foo") let matchesHeader = hasHeaderNamed("foo", value: "baz")(req) @@ -237,8 +304,12 @@ class SwiftHelpersTests : XCTestCase { } func testHeaderValueForKeyEqualsDoesNotExist() { - let req = NSMutableURLRequest(URL: NSURL(string: "foo://bar")!) - +#if swift(>=3.0) + let req = URLRequest(url: URL(string: "foo://bar")!) +#else + let req = NSURLRequest(URL: NSURL(string: "foo://bar")!) +#endif + let matchesHeader = hasHeaderNamed("foo", value: "baz")(req) XCTAssertFalse(matchesHeader) @@ -274,7 +345,11 @@ class SwiftHelpersTests : XCTestCase { func testOrOperator() { for url in sampleURLs { +#if swift(>=3.0) + let req = URLRequest(url: URL(string: url)!) +#else let req = NSURLRequest(URL: NSURL(string: url)!) +#endif XCTAssert((trueMatcher || trueMatcher)(req) == true, "trueMatcher || trueMatcher should result in a trueMatcher") XCTAssert((trueMatcher || falseMatcher)(req) == true, "trueMatcher || falseMatcher should result in a trueMatcher") XCTAssert((falseMatcher || trueMatcher)(req) == true, "falseMatcher || trueMatcher should result in a trueMatcher") @@ -284,7 +359,11 @@ class SwiftHelpersTests : XCTestCase { func testAndOperator() { for url in sampleURLs { +#if swift(>=3.0) + let req = URLRequest(url: URL(string: url)!) +#else let req = NSURLRequest(URL: NSURL(string: url)!) +#endif XCTAssert((trueMatcher && trueMatcher)(req) == true, "trueMatcher && trueMatcher should result in a trueMatcher") XCTAssert((trueMatcher && falseMatcher)(req) == false, "trueMatcher && falseMatcher should result in a falseMatcher") XCTAssert((falseMatcher && trueMatcher)(req) == false, "falseMatcher && trueMatcher should result in a falseMatcher") @@ -294,7 +373,11 @@ class SwiftHelpersTests : XCTestCase { func testNotOperator() { for url in sampleURLs { +#if swift(>=3.0) + let req = URLRequest(url: URL(string: url)!) +#else let req = NSURLRequest(URL: NSURL(string: url)!) +#endif XCTAssert((!trueMatcher)(req) == false, "!trueMatcher should result in a falseMatcher") XCTAssert((!falseMatcher)(req) == true, "!falseMatcher should result in a trueMatcher") } From 1ffda18403fa783c8de795cae015af36896a2a44 Mon Sep 17 00:00:00 2001 From: Liquidsoul Date: Tue, 9 Aug 2016 15:33:33 +0200 Subject: [PATCH 06/14] Remove target level SWIFT_VERSION setting SWIFT_VERSION is now configured only at the project level --- OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj b/OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj index 28001630..1726e979 100644 --- a/OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj +++ b/OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj @@ -1510,7 +1510,6 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.alisoftware.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = OHHTTPStubs; SDKROOT = macosx; - SWIFT_VERSION = 3.0; WRAPPER_EXTENSION = framework; }; name = Debug; @@ -1537,7 +1536,6 @@ PRODUCT_NAME = OHHTTPStubs; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; WRAPPER_EXTENSION = framework; }; name = Release; @@ -1704,7 +1702,6 @@ PRODUCT_NAME = OHHTTPStubs; SDKROOT = appletvos; SKIP_INSTALL = YES; - SWIFT_VERSION = 2.3; }; name = Debug; }; @@ -1727,7 +1724,6 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 2.3; }; name = Release; }; From 95054906ce0db4d8dda9e9e5a8ff3b70d26fc93b Mon Sep 17 00:00:00 2001 From: Liquidsoul Date: Tue, 9 Aug 2016 15:35:05 +0200 Subject: [PATCH 07/14] Workaround to fix isPath tests in Swift 3.0 We need to cast to NSURL because URL.path does not behave like NSURL.path in Swift 3.0. URL.path does not stop at the first ';' and returns the entire string. --- OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift b/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift index bde2daa8..150372ee 100644 --- a/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift +++ b/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift @@ -177,7 +177,7 @@ public func isHost(_ host: String) -> OHHTTPStubsTestBlock { * should include in the `path` parameter unless you're testing relative URLs) */ public func isPath(_ path: String) -> OHHTTPStubsTestBlock { - return { req in req.url?.path == path } + return { req in (req.url as NSURL?)?.path == path } // Need to cast to NSURL because URL.path does not behave like NSURL.path in Swift 3.0. URL.path does not stop at the first ';' and returns the entire string. } /** From 197318295c145bc59aa6795bed252b03fb8693fc Mon Sep 17 00:00:00 2001 From: Liquidsoul Date: Thu, 18 Aug 2016 07:25:44 +0200 Subject: [PATCH 08/14] Remove unneeded #if os(tvOS) conditional --- OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift | 4 ---- 1 file changed, 4 deletions(-) diff --git a/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift b/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift index 150372ee..3c0620a2 100644 --- a/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift +++ b/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift @@ -195,11 +195,7 @@ public func pathStartsWith(_ path: String) -> OHHTTPStubsTestBlock { #if swift(>=3.0) return { req in req.url?.path.hasPrefix(path) ?? false } #else -#if os(tvOS) return { req in req.url?.path?.hasPrefix(path) ?? false } -#else - return { req in req.url?.path?.hasPrefix(path) ?? false } -#endif #endif } From 6790e280ce380aa369639b2efb502b50265af6c9 Mon Sep 17 00:00:00 2001 From: Liquidsoul Date: Thu, 18 Aug 2016 07:33:01 +0200 Subject: [PATCH 09/14] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b638202..e70eaeab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ [@ikesyo](https://github.com/ikesyo), [#185](https://github.com/AliSoftware/OHHTTPStubs/pull/185) * Fix: Carthage support and Examples configurations [@Liquidsoul](https://github.com/Liquidsoul), [#190](https://github.com/AliSoftware/OHHTTPStubs/issues/190) +* Added Swift 3.0 support. + [@mxcl](https://github.com/mxcl), [@Liquidsoul](https://github.com/Liquidsoul), [#192](https://github.com/AliSoftware/OHHTTPStubs/pull/192) ## [5.1.0](https://github.com/AliSoftware/OHHTTPStubs/releases/tag/5.1.0) From 3475b96321c9a2d0bf7ed2c8d334a045f13cb3a6 Mon Sep 17 00:00:00 2001 From: Liquidsoul Date: Thu, 18 Aug 2016 13:48:18 +0200 Subject: [PATCH 10/14] Use legacy Swift (2.3) --- OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj b/OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj index 1726e979..7466b53e 100644 --- a/OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj +++ b/OHHTTPStubs/OHHTTPStubs.xcodeproj/project.pbxproj @@ -1319,7 +1319,7 @@ MODULEMAP_FILE = "$(SRCROOT)/Supporting Files/module.modulemap"; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 2.3; TVOS_DEPLOYMENT_TARGET = 9.0; }; name = Debug; @@ -1359,7 +1359,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.9; MODULEMAP_FILE = "$(SRCROOT)/Supporting Files/module.modulemap"; SDKROOT = iphoneos; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 2.3; TVOS_DEPLOYMENT_TARGET = 9.0; VALIDATE_PRODUCT = YES; }; From c4a013af801776d82cf5a4c42f957f56a7d39cb1 Mon Sep 17 00:00:00 2001 From: Liquidsoul Date: Fri, 19 Aug 2016 21:23:58 +0200 Subject: [PATCH 11/14] Fix CHANGELOG formatting --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e70eaeab..85935007 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,9 @@ [@ikesyo](https://github.com/ikesyo), [#184](https://github.com/AliSoftware/OHHTTPStubs/pull/184) * Set deployment targets at the project level to be used in a universal target. [@ikesyo](https://github.com/ikesyo), [#185](https://github.com/AliSoftware/OHHTTPStubs/pull/185) -* Fix: Carthage support and Examples configurations +* Fix: Carthage support and Examples configurations. [@Liquidsoul](https://github.com/Liquidsoul), [#190](https://github.com/AliSoftware/OHHTTPStubs/issues/190) -* Added Swift 3.0 support. +* Added Swift 3.0 support. [@mxcl](https://github.com/mxcl), [@Liquidsoul](https://github.com/Liquidsoul), [#192](https://github.com/AliSoftware/OHHTTPStubs/pull/192) ## [5.1.0](https://github.com/AliSoftware/OHHTTPStubs/releases/tag/5.1.0) From 84428236885020b09b89869d06f7a15d4e430142 Mon Sep 17 00:00:00 2001 From: Liquidsoul Date: Sat, 20 Aug 2016 11:02:33 +0200 Subject: [PATCH 12/14] Add swift 2.3/3.0 support details info in README.md --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 4d7287a7..08c4f3eb 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,23 @@ Simply add `pod 'OHHTTPStubs'` to your `Podfile`. _`OHHTTPStubs` should also be compatible with Carthage — but I won't guarantee help/support for it as I don't use it personally._ +## Using the right Swift Version of `OHHTTPStubs` for your project in Xcode 8 + +`OHHTTPStubs` support both Swift 2.3 and Swift 3.0 🎉 + +### CocoaPods + +If you use CocoaPods version [`1.1.0.beta.1`](https://github.com/CocoaPods/CocoaPods/releases/tag/1.1.0.beta.1), then CocoaPods will compile `OHHTTPStubs` with the right Swift Version matching the one you use for your project automatically. +For more info, see [CocoaPods/CocoaPods#5540](https://github.com/CocoaPods/CocoaPods/pull/5540) and [CocoaPods/CocoaPods#5760](https://github.com/CocoaPods/CocoaPods/pull/5760). + +### Carthage + +The framework on `master` will build using Swift 2.3. If you want Carthage to build the framework with Swift 3.0, you can use the `swift-3.0` branch (whose only difference with master is that the project's Build Settings set `SWIFT_VERSION=3.0` instead of `2.3`). + +Later, a few weeks after the Xcode 8 official release, we plan to merge the `swift-3.0` branch into `master` and create a _compatibility branch_ `swift-2.3` for Carthage users who have not migrated their Swift code yet. We'll try to keep the branch up-to-date with master as best we can. + +Maybe Carthage will addess this in a future release. See the related issue [Carthage/Carthage#1445](https://github.com/Carthage/Carthage/issues/1445). + # Special Considerations ## Using OHHTTPStubs in your Unit Tests From 9c24342003a72fa50f14e90342d08e3b3f0ed5c6 Mon Sep 17 00:00:00 2001 From: Liquidsoul Date: Sat, 20 Aug 2016 19:57:41 +0200 Subject: [PATCH 13/14] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 08c4f3eb..c969ea2a 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ The framework on `master` will build using Swift 2.3. If you want Carthage to bu Later, a few weeks after the Xcode 8 official release, we plan to merge the `swift-3.0` branch into `master` and create a _compatibility branch_ `swift-2.3` for Carthage users who have not migrated their Swift code yet. We'll try to keep the branch up-to-date with master as best we can. -Maybe Carthage will addess this in a future release. See the related issue [Carthage/Carthage#1445](https://github.com/Carthage/Carthage/issues/1445). +Maybe Carthage will address this in a future release. See the related issue [Carthage/Carthage#1445](https://github.com/Carthage/Carthage/issues/1445). # Special Considerations From f2f6956a4c1897fb405983fbdd3a6951d382fc58 Mon Sep 17 00:00:00 2001 From: Liquidsoul Date: Sat, 20 Aug 2016 19:58:06 +0200 Subject: [PATCH 14/14] Add a note about SWIFT_VERSION and Xcode 7 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c969ea2a..20e2432f 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,8 @@ Later, a few weeks after the Xcode 8 official release, we plan to merge the `swi Maybe Carthage will address this in a future release. See the related issue [Carthage/Carthage#1445](https://github.com/Carthage/Carthage/issues/1445). +**Note**: if you use Xcode 7, `SWIFT_VERSION` is ignored and the framework will be built with Swift 2.2 + # Special Considerations ## Using OHHTTPStubs in your Unit Tests