Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for Xcode 9 and Swift 4 #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: swift
osx_image: xcode8.2
osx_image: xcode9
before_install:
- gem install fastlane -NV
script:
Expand Down
Binary file modified Playgrounds/Spry-Xcode.zip
Binary file not shown.
Binary file modified Playgrounds/Spry-iPad.zip
Binary file not shown.
8 changes: 4 additions & 4 deletions Source/Spry/Core/Comparable+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extension NSNumber : Comparable {
/// - lhs: A value to compare.
/// - rhs: Another value to compare.
public static func <(lhs: NSNumber, rhs: NSNumber) -> Bool {
return Double(lhs) < Double(rhs)
return Double(truncating: lhs) < Double(truncating: rhs)
}

/// Returns a Boolean value indicating whether the value of the first
Expand All @@ -27,7 +27,7 @@ extension NSNumber : Comparable {
/// - lhs: A value to compare.
/// - rhs: Another value to compare.
public static func <=(lhs: NSNumber, rhs: NSNumber) -> Bool {
return Double(lhs) <= Double(rhs)
return Double(truncating: lhs) <= Double(truncating: rhs)
}

/// Returns a Boolean value indicating whether the value of the first
Expand All @@ -37,7 +37,7 @@ extension NSNumber : Comparable {
/// - lhs: A value to compare.
/// - rhs: Another value to compare.
public static func >=(lhs: NSNumber, rhs: NSNumber) -> Bool {
return Double(lhs) >= Double(rhs)
return Double(truncating: lhs) >= Double(truncating: rhs)
}

/// Returns a Boolean value indicating whether the value of the first
Expand All @@ -47,7 +47,7 @@ extension NSNumber : Comparable {
/// - lhs: A value to compare.
/// - rhs: Another value to compare.
public static func >(lhs: NSNumber, rhs: NSNumber) -> Bool {
return Double(lhs) > Double(rhs)
return Double(truncating: lhs) > Double(truncating: rhs)
}

}
Expand Down
2 changes: 1 addition & 1 deletion Source/Spry/Matchers/beCloseTo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

internal let DefaultDelta = 0.0001
public let DefaultDelta = 0.0001

private func isCloseTo(_ actualValue: ConvertibleToDouble?, expectedValue: ConvertibleToDouble, delta: Double) -> Bool {
return actualValue != nil && abs(actualValue!.doubleValue - expectedValue.doubleValue) < delta
Expand Down
6 changes: 3 additions & 3 deletions Source/Spry/Matchers/equal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public func equal<T: Equatable>(_ expectedValue: T) -> Matcher<T> {
/// Values can support equal by supporting the Equatable protocol.
///
/// @see beCloseTo if you want to match imprecise types (eg - floats, doubles).
public func equal<T: Equatable, C: Equatable>(_ expectedValue: [T: C]) -> Matcher<[T: C]> {
public func equal<T, C: Equatable>(_ expectedValue: [T: C]) -> Matcher<[T: C]> {
return Matcher { expression in
guard let actualValue = try expression.evaluate() else { return false }
return expectedValue == actualValue
Expand Down Expand Up @@ -152,7 +152,7 @@ public func !=<T: Comparable>(lhs: Expectation<Set<T>>, rhs: Set<T>?) -> Expecta
///
/// @see beCloseTo if you want to match imprecise types (eg - floats, doubles).
@discardableResult
public func ==<T: Equatable, C: Equatable>(lhs: Expectation<[T: C]>, rhs: [T: C]?) -> ExpectationResult {
public func ==<T, C: Equatable>(lhs: Expectation<[T: C]>, rhs: [T: C]?) -> ExpectationResult {
return lhs.to(equal(rhs!))
}

Expand All @@ -161,6 +161,6 @@ public func ==<T: Equatable, C: Equatable>(lhs: Expectation<[T: C]>, rhs: [T: C]
///
/// @see beCloseTo if you want to match imprecise types (eg - floats, doubles).
@discardableResult
public func !=<T: Equatable, C: Equatable>(lhs: Expectation<[T: C]>, rhs: [T: C]?) -> ExpectationResult {
public func !=<T, C: Equatable>(lhs: Expectation<[T: C]>, rhs: [T: C]?) -> ExpectationResult {
return lhs.toNot(equal(rhs!))
}
47 changes: 36 additions & 11 deletions Spry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -476,24 +476,26 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0820;
LastUpgradeCheck = 0820;
LastUpgradeCheck = 0900;
TargetAttributes = {
549BF8C61E5DA9DC00308A6C = {
CreatedOnToolsVersion = 8.2.1;
LastSwiftMigration = 0820;
LastSwiftMigration = 0900;
ProvisioningStyle = Manual;
};
549BF8CF1E5DA9DD00308A6C = {
CreatedOnToolsVersion = 8.2.1;
LastSwiftMigration = 0820;
LastSwiftMigration = 0900;
ProvisioningStyle = Automatic;
};
549BF8FD1E5DB9E100308A6C = {
CreatedOnToolsVersion = 8.2.1;
LastSwiftMigration = 0900;
ProvisioningStyle = Automatic;
};
549BF9051E5DB9E100308A6C = {
CreatedOnToolsVersion = 8.2.1;
LastSwiftMigration = 0900;
ProvisioningStyle = Automatic;
};
};
Expand Down Expand Up @@ -706,20 +708,27 @@
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
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;
CODE_SIGNING_REQUIRED = NO;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
Expand All @@ -732,6 +741,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.9;
ONLY_ACTIVE_ARCH = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
TVOS_DEPLOYMENT_TARGET = 9.0;
Expand All @@ -745,19 +755,26 @@
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
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;
CODE_SIGNING_REQUIRED = NO;
CURRENT_PROJECT_VERSION = 1;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down Expand Up @@ -811,7 +828,8 @@
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
VALID_ARCHS = x86_64;
VERSION_INFO_PREFIX = "";
};
Expand Down Expand Up @@ -847,7 +865,8 @@
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
VALID_ARCHS = x86_64;
VERSION_INFO_PREFIX = "";
};
Expand Down Expand Up @@ -884,7 +903,8 @@
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OBJC_BRIDGING_HEADER = "Tests/Spry-macOSTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand Down Expand Up @@ -913,7 +933,8 @@
SDKROOT = macosx;
SWIFT_OBJC_BRIDGING_HEADER = "Tests/Spry-macOSTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down Expand Up @@ -946,7 +967,8 @@
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSION_INFO_PREFIX = "";
};
Expand Down Expand Up @@ -976,7 +998,8 @@
PRODUCT_NAME = Spry;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSION_INFO_PREFIX = "";
};
Expand Down Expand Up @@ -1007,7 +1030,8 @@
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -1030,7 +1054,8 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.152percent.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = SpryTests;
SDKROOT = iphoneos;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
4 changes: 3 additions & 1 deletion Spry.xcodeproj/xcshareddata/xcschemes/Spry-iOS.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -55,6 +56,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
4 changes: 3 additions & 1 deletion Spry.xcodeproj/xcshareddata/xcschemes/Spry-macOS.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -55,6 +56,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down