From 553af10b1b4e7e60b08521e1ef2027a522d825b4 Mon Sep 17 00:00:00 2001 From: Alex Fish Date: Mon, 5 Sep 2016 12:50:12 +0100 Subject: [PATCH] Convert to swift3 --- Box.xcodeproj/project.pbxproj | 20 ++++++++++++++++++- .../xcshareddata/xcschemes/Box-Mac.xcscheme | 10 +++++----- .../xcshareddata/xcschemes/Box-iOS.xcscheme | 10 +++++----- Box/Box.swift | 6 +++--- Box/BoxType.swift | 6 +++--- Box/MutableBox.swift | 4 ++-- BoxTests/Info.plist | 2 +- 7 files changed, 38 insertions(+), 20 deletions(-) diff --git a/Box.xcodeproj/project.pbxproj b/Box.xcodeproj/project.pbxproj index 4b5b763..1443485 100644 --- a/Box.xcodeproj/project.pbxproj +++ b/Box.xcodeproj/project.pbxproj @@ -256,7 +256,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0700; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = "Rob Rix"; TargetAttributes = { D470AC3619E86128003DA6C6 = { @@ -267,9 +267,11 @@ }; F8BB81D21A939B66001AA352 = { CreatedOnToolsVersion = 6.3; + LastSwiftMigration = 0800; }; F8BB81DC1A939B67001AA352 = { CreatedOnToolsVersion = 6.3; + LastSwiftMigration = 0800; }; }; }; @@ -394,15 +396,19 @@ 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; CURRENT_PROJECT_VERSION = 1; 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", @@ -440,8 +446,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; @@ -450,6 +458,7 @@ 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; @@ -461,6 +470,7 @@ MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.antitypical.$(PRODUCT_NAME:rfc1034identifier)"; SDKROOT = macosx; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -521,6 +531,7 @@ ); INFOPLIST_FILE = BoxTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.antitypical.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -535,6 +546,7 @@ ); INFOPLIST_FILE = BoxTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.antitypical.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; @@ -559,6 +571,7 @@ PRODUCT_NAME = Box; SDKROOT = iphoneos; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -579,6 +592,7 @@ PRODUCT_NAME = Box; SDKROOT = iphoneos; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -599,8 +613,10 @@ ); INFOPLIST_FILE = BoxTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.antitypical.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -615,8 +631,10 @@ ); INFOPLIST_FILE = BoxTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.antitypical.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; + SWIFT_VERSION = 3.0; VALIDATE_PRODUCT = YES; }; name = Release; diff --git a/Box.xcodeproj/xcshareddata/xcschemes/Box-Mac.xcscheme b/Box.xcodeproj/xcshareddata/xcschemes/Box-Mac.xcscheme index d5930bf..223359f 100644 --- a/Box.xcodeproj/xcshareddata/xcschemes/Box-Mac.xcscheme +++ b/Box.xcodeproj/xcshareddata/xcschemes/Box-Mac.xcscheme @@ -1,6 +1,6 @@ + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -66,11 +66,11 @@ + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -66,11 +66,11 @@ : BoxType, CustomStringConvertible { /// Constructs a `Box` with the given `value`. - public class func unit(value: T) -> Box { + public class func unit(_ value: T) -> Box { return Box(value) } @@ -20,7 +20,7 @@ public final class Box: BoxType, CustomStringConvertible { public let value: T /// Constructs a new Box by transforming `value` by `f`. - public func map(@noescape f: T -> U) -> Box { + public func map(_ f: (T) -> U) -> Box { return Box(f(value)) } @@ -28,6 +28,6 @@ public final class Box: BoxType, CustomStringConvertible { // MARK: Printable public var description: String { - return String(value) + return String(describing: value) } } diff --git a/Box/BoxType.swift b/Box/BoxType.swift index db6109a..a91e04d 100644 --- a/Box/BoxType.swift +++ b/Box/BoxType.swift @@ -26,14 +26,14 @@ public protocol MutableBoxType: BoxType { /// Equality of `BoxType`s of `Equatable` types. /// /// We cannot declare that e.g. `Box` conforms to `Equatable`, so this is a relatively ad hoc definition. -public func == (lhs: B, rhs: B) -> Bool { +public func == (lhs: B, rhs: B) -> Bool where B.Value: Equatable { return lhs.value == rhs.value } /// Inequality of `BoxType`s of `Equatable` types. /// /// We cannot declare that e.g. `Box` conforms to `Equatable`, so this is a relatively ad hoc definition. -public func != (lhs: B, rhs: B) -> Bool { +public func != (lhs: B, rhs: B) -> Bool where B.Value: Equatable { return lhs.value != rhs.value } @@ -41,6 +41,6 @@ public func != (lhs: B, rhs: B) -> Bool { // MARK: Map /// Maps the value of a box into a new box. -public func map(v: B, @noescape f: B.Value -> C.Value) -> C { +public func map(_ v: B, f: (B.Value) -> C.Value) -> C { return C(f(v.value)) } diff --git a/Box/MutableBox.swift b/Box/MutableBox.swift index 0e434b6..2fe30b6 100644 --- a/Box/MutableBox.swift +++ b/Box/MutableBox.swift @@ -15,13 +15,13 @@ public final class MutableBox: MutableBoxType, CustomStringConvertible { public var value: T /// Constructs a new MutableBox by transforming `value` by `f`. - public func map(@noescape f: T -> U) -> MutableBox { + public func map(_ f: (T) -> U) -> MutableBox { return MutableBox(f(value)) } // MARK: Printable public var description: String { - return String(value) + return String(describing: value) } } diff --git a/BoxTests/Info.plist b/BoxTests/Info.plist index 358bdf0..ba72822 100644 --- a/BoxTests/Info.plist +++ b/BoxTests/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - com.antitypical.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName