Skip to content

Commit

Permalink
Swift 4 / Xcode 9
Browse files Browse the repository at this point in the history
  • Loading branch information
mdiep committed Oct 13, 2017
1 parent 8faa221 commit 5d6d842
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .swift-version
@@ -1 +1 @@
3.0.2
4.0
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode8.2
osx_image: xcode9
branches:
only:
- master
Expand Down
31 changes: 23 additions & 8 deletions Logician.xcodeproj/project.pbxproj
Expand Up @@ -279,7 +279,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0820;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = "Matt Diephouse";
TargetAttributes = {
84F407151E29B9EC00ADD734 = {
Expand All @@ -292,11 +292,12 @@
};
BE3D361C1D7880BC00729A4C = {
CreatedOnToolsVersion = 8.0;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
ProvisioningStyle = Automatic;
};
BE3D36251D7880BD00729A4C = {
CreatedOnToolsVersion = 8.0;
LastSwiftMigration = 0900;
ProvisioningStyle = Automatic;
};
};
Expand Down Expand Up @@ -436,7 +437,7 @@
buildSettings = {
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand All @@ -459,7 +460,7 @@
buildSettings = {
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand Down Expand Up @@ -520,15 +521,22 @@
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_DOCUMENTATION_COMMENTS = YES;
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_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -572,15 +580,22 @@
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_DOCUMENTATION_COMMENTS = YES;
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_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -625,7 +640,7 @@
PRODUCT_NAME = Logician;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -646,7 +661,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.diephouse.matt.Logician;
PRODUCT_NAME = Logician;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -659,7 +674,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.diephouse.matt.LogicianTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -672,7 +687,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.diephouse.matt.LogicianTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
@@ -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
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
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
2 changes: 1 addition & 1 deletion Sources/Constraint.swift
Expand Up @@ -33,7 +33,7 @@ internal func equal<P: PropertyProtocol>(_ properties: [P], value: P.Value? = ni

/// Create an inequality constraint between some properties and, optionally, a
/// value.
internal func unequal<P: PropertyProtocol>(_ properties: [P], values: Set<P.Value> = []) -> Constraint where P.Value: Hashable {
internal func unequal<P: PropertyProtocol>(_ properties: [P], values: Set<P.Value> = []) -> Constraint {
let properties = properties.map { $0.property }
return { state in
var values = values
Expand Down
12 changes: 6 additions & 6 deletions Sources/Goal.swift
Expand Up @@ -36,17 +36,17 @@ private func goal(_ constraint: @escaping Constraint) -> Goal {
// MARK: - Equality

/// A goal that's satisfied when a variable equals a value.
public func == <V: VariableProtocol>(variable: V, value: V.Value) -> Goal where V.Value: Equatable {
public func == <V: VariableProtocol>(variable: V, value: V.Value) -> Goal {
return goal { try $0.unifying(variable.variable, value) }
}

/// A goal that's satisfied when a value equals a variable.
public func == <V: VariableProtocol>(value: V.Value, variable: V) -> Goal where V.Value: Equatable {
public func == <V: VariableProtocol>(value: V.Value, variable: V) -> Goal {
return variable == value
}

/// A goal that's satisfied when two variables are equal.
public func == <V: VariableProtocol>(lhs: V, rhs: V) -> Goal where V.Value: Equatable {
public func == <V: VariableProtocol>(lhs: V, rhs: V) -> Goal {
return goal { try $0.unifying(lhs.variable, rhs.variable) }
}

Expand All @@ -65,7 +65,7 @@ public func == <P: PropertyProtocol>(lhs: P, rhs: P) -> Goal where P.Value: Equa
return goal(equal([ lhs, rhs ]))
}

extension Variable where Value: Equatable {
extension Variable {
/// A goal that's satisfied when a variable is one of a number of values.
public func `in`<C: Collection>(_ values: C) -> Goal where C.Iterator.Element == Value {
return any(values.map { self == $0 })
Expand Down Expand Up @@ -144,7 +144,7 @@ public func all(_ goals: [Goal]) -> Goal {
}

/// A goal that succeeds when all of the subgoals succeed.
public func all(_ goals: @escaping Goal...) -> Goal {
public func all(_ goals: Goal...) -> Goal {
return all(goals)
}

Expand All @@ -168,7 +168,7 @@ public func any(_ goals: [Goal]) -> Goal {
/// A goal that succeeds when any of the subgoals succeeds.
///
/// This can multiple alternative solutions.
public func any(_ goals: @escaping Goal...) -> Goal {
public func any(_ goals: Goal...) -> Goal {
return any(goals)
}

Expand Down
5 changes: 1 addition & 4 deletions Sources/Variable.swift
Expand Up @@ -8,10 +8,7 @@

import Foundation

public protocol VariableProtocol: PropertyProtocol {
/// The type of value that the variable represents.
associatedtype Value: Equatable

public protocol VariableProtocol: PropertyProtocol where Value: Equatable {
/// Extracts the variable from the receiver.
var variable: Variable<Value> { get }
}
Expand Down

0 comments on commit 5d6d842

Please sign in to comment.