Skip to content

Commit

Permalink
Swift 4 compatible framework (DiUS#27)
Browse files Browse the repository at this point in the history
* Updates the project with Xcode suggested Swift4 updates

* Updates frameworks’ version in Cartfile

* Removes argument from closure

* Explicitly exposes swift functions to objc

* Fixes non-prototype declaration

* Bumps up TravisCI osx_image to 9

* Removes block declaration is not a prototype warning
  • Loading branch information
Marko Justinek authored and andrewspinks committed Sep 23, 2017
1 parent 2dd464d commit c74eaae
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode8.2
osx_image: xcode9
before_install:
- scripts/import_keychain.sh
- security find-identity -v -p codesigning
Expand Down
4 changes: 2 additions & 2 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
github "Alamofire/Alamofire" ~> 4.4
github "Thomvis/BrightFutures" ~> 5.1
github "Alamofire/Alamofire" ~> 4.5
github "Thomvis/BrightFutures" ~> 5.2
github "Quick/Nimble" ~> 7.0
4 changes: 2 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github "Alamofire/Alamofire" "4.4.0"
github "Quick/Nimble" "v7.0.0"
github "Alamofire/Alamofire" "4.5.0"
github "Quick/Nimble" "v7.0.1"
github "Quick/Quick" "v1.1.0"
github "Thomvis/BrightFutures" "5.2.0"
github "antitypical/Result" "3.2.3"
30 changes: 23 additions & 7 deletions PactConsumerSwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,16 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = "Andrew Spinks";
TargetAttributes = {
A11F1A6A1A5C890D00DAB9CE = {
CreatedOnToolsVersion = 6.1.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
A11F1A751A5C890E00DAB9CE = {
CreatedOnToolsVersion = 6.1.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
};
};
Expand Down Expand Up @@ -388,14 +388,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
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_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -438,14 +444,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
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_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -497,7 +509,8 @@
PRODUCT_BUNDLE_IDENTIFIER = "spinks.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand Down Expand Up @@ -525,7 +538,8 @@
PRODUCT_BUNDLE_IDENTIFIER = "spinks.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -547,7 +561,8 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "PactConsumerSwiftTests/PactConsumerSwiftTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -564,7 +579,8 @@
PRODUCT_BUNDLE_IDENTIFIER = "spinks.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "PactConsumerSwiftTests/PactConsumerSwiftTests-Bridging-Header.h";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.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 = "0800"
LastUpgradeVersion = "0900"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -40,6 +40,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<PreActions>
Expand Down Expand Up @@ -106,6 +107,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
8 changes: 6 additions & 2 deletions PactConsumerSwift/Interaction.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import Alamofire

@objc public enum PactHTTPMethod: Int {
@objc
public enum PactHTTPMethod: Int {
case OPTIONS, GET, HEAD, POST, PUT, PATCH, DELETE, TRACE, CONNECT
}

@objc open class Interaction: NSObject {
@objc
open class Interaction: NSObject {
open var providerState: String?
open var testDescription: String = ""
open var request: [String: Any] = [:]
Expand All @@ -16,6 +18,7 @@ import Alamofire
return self
}

@objc
@discardableResult
open func uponReceiving(_ testDescription: String) -> Interaction {
self.testDescription = testDescription
Expand Down Expand Up @@ -57,6 +60,7 @@ import Alamofire
return self
}

@objc
open func payload() -> [String: Any] {
var payload: [String: Any] = ["description": testDescription,
"request": request,
Expand Down
2 changes: 2 additions & 0 deletions PactConsumerSwift/MockService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Nimble
fileprivate let pactVerificationService: PactVerificationService
fileprivate var interactions: [Interaction] = []

@objc
open var baseUrl: String {
return pactVerificationService.baseUrl
}
Expand All @@ -30,6 +31,7 @@ import Nimble
pactVerificationService: PactVerificationService())
}

@objc
open func given(_ providerState: String) -> Interaction {
let interaction = Interaction().given(providerState)
interactions.append(interaction)
Expand Down
12 changes: 5 additions & 7 deletions PactConsumerSwiftTests/PactObjectiveCTests.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "OCAnimalServiceClient.h"
Expand All @@ -25,7 +23,7 @@ - (void)tearDown {
}

- (void)testGetAlligator {
typedef void (^CompleteBlock)();
typedef void (^CompleteBlock)(void);

[[[[self.animalMockService given:@"an alligator exists"]
uponReceiving:@"ObjC - a request for an alligator"]
Expand All @@ -44,7 +42,7 @@ - (void)testGetAlligator {
}

- (void)testWithQueryParams {
typedef void (^CompleteBlock)();
typedef void (^CompleteBlock)(void);

[[[[self.animalMockService given:@"an alligator exists"]
uponReceiving:@"ObjC - a request for animals living in water"]
Expand All @@ -69,7 +67,7 @@ - (void)testWithQueryParams {
#pragma mark - Mather tests

- (void)testMatchingRegex {
typedef void (^CompleteBlock)();
typedef void (^CompleteBlock)(void);

[[[[self.animalMockService given:@"an alligator exists with a birthdate"]
uponReceiving:@"ObjC - a request for alligator with birthdate"]
Expand All @@ -92,7 +90,7 @@ - (void)testMatchingRegex {
}

- (void)testMatchingType {
typedef void (^CompleteBlock)();
typedef void (^CompleteBlock)(void);

[[[[self.animalMockService given:@"an alligator exists with legs"]
uponReceiving:@"ObjC - a request for alligator with legs"]
Expand All @@ -116,7 +114,7 @@ - (void)testMatchingType {


- (void)testMatchingVariableLengthArray {
typedef void (^CompleteBlock)();
typedef void (^CompleteBlock)(void);

[[[[self.animalMockService given:@"multiple land based animals exist"]
uponReceiving:@"ObjC - a request for animals living on land"]
Expand Down
2 changes: 1 addition & 1 deletion PactConsumerSwiftTests/PactSpecs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class PactSwiftSpec: QuickSpec {

//Run the tests
animalMockService!.run { (testComplete) -> Void in
animalServiceClient!.wontEat(animal: "pidgeon", success: { (response) in
animalServiceClient!.wontEat(animal: "pidgeon", success: { () in
// We are expecting this test to fail - the error handler should be called
expect(true).to(equal(false))
testComplete()
Expand Down

0 comments on commit c74eaae

Please sign in to comment.