Skip to content

Commit

Permalink
Merge pull request #63 from kylef/kylef/swift-3.0
Browse files Browse the repository at this point in the history
Update to Swift 3.0
  • Loading branch information
kylef authored Oct 7, 2016
2 parents 6efca19 + 2dd1ff3 commit 30d56ca
Show file tree
Hide file tree
Showing 16 changed files with 408 additions and 345 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: objective-c
osx_image: xcode8.0
osx_image: xcode8
script:
- cd URITemplate && swift package generate-xcodeproj
- xcodebuild -project Mockingjay.xcodeproj -scheme Mockingjay test -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO | xcpretty
- pod lib lint --quick
2 changes: 1 addition & 1 deletion Mockingjay.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Pod::Spec.new do |spec|
spec.requires_arc = true

spec.subspec 'Core' do |core_spec|
core_spec.dependency 'URITemplate', '~> 1.3'
core_spec.dependency 'URITemplate', '~> 2.0'
core_spec.source_files = 'Mockingjay/Mockingjay.{h,swift}',
'Mockingjay/MockingjayProtocol.swift',
'Mockingjay/{Matchers,Builders}.swift',
Expand Down
100 changes: 64 additions & 36 deletions Mockingjay.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

/* Begin PBXBuildFile section */
2705946B1C4FA7A6002A3AA9 /* MockingjayXCTestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2705946A1C4FA7A6002A3AA9 /* MockingjayXCTestTests.swift */; };
2715FACF1D8C81AB00A89DF7 /* URITemplate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2715FAC91D8C818C00A89DF7 /* URITemplate.framework */; };
274367921AA27A7C0030C97B /* Mockingjay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 274367911AA27A7C0030C97B /* Mockingjay.swift */; };
274367941AA27AAD0030C97B /* MockingjayProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 274367931AA27AAD0030C97B /* MockingjayProtocol.swift */; };
274367961AA27B170030C97B /* MockingjayProtocolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 274367951AA27B170030C97B /* MockingjayProtocolTests.swift */; };
274367981AA28AFC0030C97B /* Matchers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 274367971AA28AFC0030C97B /* Matchers.swift */; };
2743679A1AA28B0D0030C97B /* MatcherTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 274367991AA28B0D0030C97B /* MatcherTests.swift */; };
274367AE1AA29AED0030C97B /* URITemplate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 274367A91AA29ADA0030C97B /* URITemplate.framework */; };
274367B01AA29E510030C97B /* Builders.swift in Sources */ = {isa = PBXBuildFile; fileRef = 274367AF1AA29E510030C97B /* Builders.swift */; };
274367B21AA29E620030C97B /* BuildersTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 274367B11AA29E620030C97B /* BuildersTests.swift */; };
274367C61AA35FD00030C97B /* NSURLSessionConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 274367C51AA35FD00030C97B /* NSURLSessionConfiguration.swift */; };
Expand All @@ -27,27 +27,34 @@
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
274367A81AA29ADA0030C97B /* PBXContainerItemProxy */ = {
2715FAC41D8C818C00A89DF7 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 274367A31AA29ADA0030C97B /* URITemplate.xcodeproj */;
containerPortal = 2715FABD1D8C818C00A89DF7 /* URITemplate.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 77356D801A253325002822CF;
remoteInfo = URITemplate;
remoteGlobalIDString = "_____Product_Spectre";
remoteInfo = Spectre;
};
274367AA1AA29ADA0030C97B /* PBXContainerItemProxy */ = {
2715FAC61D8C818C00A89DF7 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 274367A31AA29ADA0030C97B /* URITemplate.xcodeproj */;
containerPortal = 2715FABD1D8C818C00A89DF7 /* URITemplate.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 77356D8B1A253325002822CF;
remoteInfo = URITemplateTests;
remoteGlobalIDString = "_____Product_PathKit";
remoteInfo = PathKit;
};
274367AC1AA29AE70030C97B /* PBXContainerItemProxy */ = {
2715FAC81D8C818C00A89DF7 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 274367A31AA29ADA0030C97B /* URITemplate.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 77356D7F1A253325002822CF;
containerPortal = 2715FABD1D8C818C00A89DF7 /* URITemplate.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = "_____Product_URITemplate";
remoteInfo = URITemplate;
};
2715FACA1D8C818C00A89DF7 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 2715FABD1D8C818C00A89DF7 /* URITemplate.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = "_____Product_URITemplateTests";
remoteInfo = URITemplateTests;
};
2746CDCC1A702F7800719B66 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 2746CDB61A702F7800719B66 /* Project object */;
Expand All @@ -59,13 +66,13 @@

/* Begin PBXFileReference section */
2705946A1C4FA7A6002A3AA9 /* MockingjayXCTestTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MockingjayXCTestTests.swift; sourceTree = "<group>"; };
2715FABD1D8C818C00A89DF7 /* URITemplate.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = URITemplate.xcodeproj; path = URITemplate/URITemplate.xcodeproj; sourceTree = "<group>"; };
274367911AA27A7C0030C97B /* Mockingjay.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Mockingjay.swift; sourceTree = "<group>"; };
274367931AA27AAD0030C97B /* MockingjayProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MockingjayProtocol.swift; sourceTree = "<group>"; };
274367951AA27B170030C97B /* MockingjayProtocolTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MockingjayProtocolTests.swift; sourceTree = "<group>"; };
274367971AA28AFC0030C97B /* Matchers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Matchers.swift; sourceTree = "<group>"; };
274367991AA28B0D0030C97B /* MatcherTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MatcherTests.swift; sourceTree = "<group>"; };
2743679B1AA28D4D0030C97B /* XCTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XCTest.swift; sourceTree = "<group>"; };
274367A31AA29ADA0030C97B /* URITemplate.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = URITemplate.xcodeproj; path = URITemplate/URITemplate.xcodeproj; sourceTree = "<group>"; };
274367AF1AA29E510030C97B /* Builders.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Builders.swift; sourceTree = "<group>"; };
274367B11AA29E620030C97B /* BuildersTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BuildersTests.swift; sourceTree = "<group>"; };
274367C51AA35FD00030C97B /* NSURLSessionConfiguration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSURLSessionConfiguration.swift; sourceTree = "<group>"; };
Expand All @@ -88,7 +95,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
274367AE1AA29AED0030C97B /* URITemplate.framework in Frameworks */,
2715FACF1D8C81AB00A89DF7 /* URITemplate.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -103,19 +110,21 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
274367A41AA29ADA0030C97B /* Products */ = {
2715FABE1D8C818C00A89DF7 /* Products */ = {
isa = PBXGroup;
children = (
274367A91AA29ADA0030C97B /* URITemplate.framework */,
274367AB1AA29ADA0030C97B /* URITemplateTests.xctest */,
2715FAC51D8C818C00A89DF7 /* Spectre.framework */,
2715FAC71D8C818C00A89DF7 /* PathKit.framework */,
2715FAC91D8C818C00A89DF7 /* URITemplate.framework */,
2715FACB1D8C818C00A89DF7 /* URITemplateTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
2746CDB51A702F7800719B66 = {
isa = PBXGroup;
children = (
274367A31AA29ADA0030C97B /* URITemplate.xcodeproj */,
2715FABD1D8C818C00A89DF7 /* URITemplate.xcodeproj */,
2746CDDB1A702FC100719B66 /* Configurations */,
2746CDC11A702F7800719B66 /* Mockingjay */,
2746CDCE1A702F7800719B66 /* MockingjayTests */,
Expand Down Expand Up @@ -225,7 +234,6 @@
buildRules = (
);
dependencies = (
274367AD1AA29AE70030C97B /* PBXTargetDependency */,
);
name = Mockingjay;
productName = Mockingjay;
Expand Down Expand Up @@ -258,7 +266,7 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0700;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = Cocode;
TargetAttributes = {
2746CDBE1A702F7800719B66 = {
Expand All @@ -283,8 +291,8 @@
projectDirPath = "";
projectReferences = (
{
ProductGroup = 274367A41AA29ADA0030C97B /* Products */;
ProjectRef = 274367A31AA29ADA0030C97B /* URITemplate.xcodeproj */;
ProductGroup = 2715FABE1D8C818C00A89DF7 /* Products */;
ProjectRef = 2715FABD1D8C818C00A89DF7 /* URITemplate.xcodeproj */;
},
);
projectRoot = "";
Expand All @@ -296,18 +304,32 @@
/* End PBXProject section */

/* Begin PBXReferenceProxy section */
274367A91AA29ADA0030C97B /* URITemplate.framework */ = {
2715FAC51D8C818C00A89DF7 /* Spectre.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = Spectre.framework;
remoteRef = 2715FAC41D8C818C00A89DF7 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
2715FAC71D8C818C00A89DF7 /* PathKit.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = PathKit.framework;
remoteRef = 2715FAC61D8C818C00A89DF7 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
2715FAC91D8C818C00A89DF7 /* URITemplate.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = URITemplate.framework;
remoteRef = 274367A81AA29ADA0030C97B /* PBXContainerItemProxy */;
remoteRef = 2715FAC81D8C818C00A89DF7 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
274367AB1AA29ADA0030C97B /* URITemplateTests.xctest */ = {
2715FACB1D8C818C00A89DF7 /* URITemplateTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
fileType = file;
path = URITemplateTests.xctest;
remoteRef = 274367AA1AA29ADA0030C97B /* PBXContainerItemProxy */;
remoteRef = 2715FACA1D8C818C00A89DF7 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
Expand Down Expand Up @@ -361,11 +383,6 @@
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
274367AD1AA29AE70030C97B /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = URITemplate;
targetProxy = 274367AC1AA29AE70030C97B /* PBXContainerItemProxy */;
};
2746CDCD1A702F7800719B66 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 2746CDBE1A702F7800719B66 /* Mockingjay */;
Expand All @@ -387,8 +404,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
Expand All @@ -397,6 +416,7 @@
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",
Expand All @@ -409,7 +429,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.9;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand All @@ -433,8 +453,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
Expand All @@ -443,16 +465,18 @@
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;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.9;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand Down Expand Up @@ -482,6 +506,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
name = Debug;
Expand Down Expand Up @@ -509,6 +534,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.cocode.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
name = Release;
Expand All @@ -526,6 +552,7 @@
INFOPLIST_FILE = MockingjayTests/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocode.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -538,6 +565,7 @@
INFOPLIST_FILE = MockingjayTests/Info.plist;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocode.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
30 changes: 15 additions & 15 deletions Mockingjay/Builders.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,38 @@ import Foundation
// Collection of generic builders

/// Generic builder for returning a failure
public func failure(error:NSError) -> (request:NSURLRequest) -> Response {
return { _ in return .Failure(error) }
public func failure(_ error: NSError) -> (_ request: URLRequest) -> Response {
return { _ in return .failure(error) }
}

public func http(status:Int = 200, headers:[String:String]? = nil, download:Download=nil) -> (request:NSURLRequest) -> Response {
return { (request:NSURLRequest) in
if let response = NSHTTPURLResponse(URL: request.URL!, statusCode: status, HTTPVersion: nil, headerFields: headers) {
return Response.Success(response, download)
public func http(_ status:Int = 200, headers:[String:String]? = nil, download:Download=nil) -> (_ request: URLRequest) -> Response {
return { (request:URLRequest) in
if let response = HTTPURLResponse(url: request.url!, statusCode: status, httpVersion: nil, headerFields: headers) {
return Response.success(response, download)
}

return .Failure(NSError(domain: NSInternalInconsistencyException, code: 0, userInfo: [NSLocalizedDescriptionKey: "Failed to construct response for stub."]))
return .failure(NSError(domain: NSExceptionName.internalInconsistencyException.rawValue, code: 0, userInfo: [NSLocalizedDescriptionKey: "Failed to construct response for stub."]))
}
}

public func json(body:AnyObject, status:Int = 200, headers:[String:String]? = nil) -> (request:NSURLRequest) -> Response {
return { (request:NSURLRequest) in
public func json(_ body: Any, status:Int = 200, headers:[String:String]? = nil) -> (_ request: URLRequest) -> Response {
return { (request:URLRequest) in
do {
let data = try NSJSONSerialization.dataWithJSONObject(body, options: NSJSONWritingOptions())
return jsonData(data, status: status, headers: headers)(request: request)
let data = try JSONSerialization.data(withJSONObject: body, options: JSONSerialization.WritingOptions())
return jsonData(data, status: status, headers: headers)(request)
} catch {
return .Failure(error as NSError)
return .failure(error as NSError)
}
}
}

public func jsonData(data: NSData, status: Int = 200, headers: [String:String]? = nil) -> (request:NSURLRequest) -> Response {
return { (request:NSURLRequest) in
public func jsonData(_ data: Data, status: Int = 200, headers: [String:String]? = nil) -> (_ request: URLRequest) -> Response {
return { (request:URLRequest) in
var headers = headers ?? [String:String]()
if headers["Content-Type"] == nil {
headers["Content-Type"] = "application/json; charset=utf-8"
}

return http(status, headers: headers, download: .Content(data))(request:request)
return http(status, headers: headers, download: .content(data))(request)
}
}
Loading

0 comments on commit 30d56ca

Please sign in to comment.