diff --git a/Configurations/Base.xcconfig b/Configurations/Base.xcconfig index a8a1138..522fbff 100644 --- a/Configurations/Base.xcconfig +++ b/Configurations/Base.xcconfig @@ -10,4 +10,6 @@ CODE_SIGN_IDENTITY[sdk=iphoneos*] = iPhone Developer; MACOSX_DEPLOYMENT_TARGET = 10.9; IPHONEOS_DEPLOYMENT_TARGET = 8.0; WATCHOS_DEPLOYMENT_TARGET = 2.0; -TVOS_DEPLOYMENT_TARGET = 9.0; \ No newline at end of file +TVOS_DEPLOYMENT_TARGET = 9.0; + +SWIFT_VERSION = 5.0 diff --git a/Package.swift b/Package.swift index f0b256b..8c11573 100644 --- a/Package.swift +++ b/Package.swift @@ -1,13 +1,30 @@ -// -// Package.swift -// SwiftState -// -// Created by Yasuhiro Inami on 2015-12-05. -// Copyright © 2015 Yasuhiro Inami. All rights reserved. -// +// swift-tools-version:5.3 +// The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( - name: "SwiftState" + name: "SwiftState", + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "SwiftState", + targets: ["SwiftState"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "SwiftState", + dependencies: [], + path:"Sources"), + .testTarget( + name: "SwiftStateTests", + dependencies: ["SwiftState"], + path:"Sources"), + ] ) diff --git a/Sources/EventType.swift b/Sources/EventType.swift index 7266065..b531f41 100644 --- a/Sources/EventType.swift +++ b/Sources/EventType.swift @@ -86,9 +86,8 @@ public func == (lhs: E, rhs: Event) -> Bool /// Useful for creating StateMachine without events, i.e. `StateMachine`. public enum NoEvent: EventType { - public var hashValue: Int + public func hash(into hasher: inout Hasher) { - return 0 } } diff --git a/Sources/Transition.swift b/Sources/Transition.swift index 0cba79d..445b183 100644 --- a/Sources/Transition.swift +++ b/Sources/Transition.swift @@ -36,9 +36,10 @@ public struct Transition: Hashable self.init(fromState: .some(fromState), toState: .some(toState)) } - public var hashValue: Int + public func hash(into hasher: inout Hasher) { - return self.fromState.hashValue &+ self.toState.hashValue.byteSwapped + hasher.combine(fromState.hashValue) + hasher.combine(toState.hashValue.byteSwapped) } } diff --git a/SwiftState.podspec b/SwiftState.podspec index b527f04..5443b3b 100644 --- a/SwiftState.podspec +++ b/SwiftState.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'SwiftState' - s.version = '5.0.0' + s.version = '6.0.0' s.license = { :type => 'MIT' } s.homepage = 'https://github.com/ReactKit/SwiftState' s.authors = { 'Yasuhiro Inami' => 'inamiy@gmail.com' } diff --git a/SwiftState.xcodeproj/project.pbxproj b/SwiftState.xcodeproj/project.pbxproj index c9bd54a..a8453b6 100644 --- a/SwiftState.xcodeproj/project.pbxproj +++ b/SwiftState.xcodeproj/project.pbxproj @@ -297,7 +297,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0900; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "Yasuhiro Inami"; TargetAttributes = { 1FA61FFF1996601000460108 = { @@ -312,10 +312,11 @@ }; buildConfigurationList = 1FA61FFA1996601000460108 /* Build configuration list for PBXProject "SwiftState" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = 1FA61FF61996601000460108; productRefGroup = 1FA620011996601000460108 /* Products */; @@ -408,6 +409,7 @@ baseConfigurationReference = 1FD79FA51C17412600CE7060 /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -416,12 +418,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = 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_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -462,6 +466,7 @@ baseConfigurationReference = 1FD79FA61C17412600CE7060 /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -470,12 +475,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = 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_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -498,6 +505,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; MTL_ENABLE_DEBUG_INFO = NO; + SWIFT_COMPILATION_MODE = wholemodule; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -520,7 +528,6 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.inamiy.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(PROJECT_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -541,7 +548,6 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.inamiy.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(PROJECT_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; }; name = Release; }; @@ -561,7 +567,6 @@ INFOPLIST_FILE = Tests/SwiftStateTests/Info.plist; PRODUCT_BUNDLE_IDENTIFIER = "com.inamiy.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -577,7 +582,6 @@ INFOPLIST_FILE = Tests/SwiftStateTests/Info.plist; PRODUCT_BUNDLE_IDENTIFIER = "com.inamiy.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; }; name = Release; }; diff --git a/SwiftState.xcodeproj/xcshareddata/xcschemes/SwiftState.xcscheme b/SwiftState.xcodeproj/xcshareddata/xcschemes/SwiftState.xcscheme index 156778f..49e1b54 100644 --- a/SwiftState.xcodeproj/xcshareddata/xcschemes/SwiftState.xcscheme +++ b/SwiftState.xcodeproj/xcshareddata/xcschemes/SwiftState.xcscheme @@ -1,6 +1,6 @@ + codeCoverageEnabled = "YES" + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -57,7 +56,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/Tests/SwiftStateTests/HierarchicalMachineTests.swift b/Tests/SwiftStateTests/HierarchicalMachineTests.swift index ac6ab7a..aa18eba 100644 --- a/Tests/SwiftStateTests/HierarchicalMachineTests.swift +++ b/Tests/SwiftStateTests/HierarchicalMachineTests.swift @@ -15,15 +15,15 @@ private enum _MainState: StateType case subMachine1(_SubState) case subMachine2(_SubState) - var hashValue: Int + func hash(into hasher: inout Hasher) { switch self { case .mainState0: - return "MainState0".hashValue + hasher.combine("MainState0".hashValue) case let .subMachine1(state): - return "SubMachine1-\(state)".hashValue + hasher.combine("SubMachine1-\(state)".hashValue) case let .subMachine2(state): - return "SubMachine2-\(state)".hashValue + hasher.combine("SubMachine2-\(state)".hashValue) } } } diff --git a/Tests/SwiftStateTests/MyEvent.swift b/Tests/SwiftStateTests/MyEvent.swift index bf86a3a..563a78a 100644 --- a/Tests/SwiftStateTests/MyEvent.swift +++ b/Tests/SwiftStateTests/MyEvent.swift @@ -17,10 +17,10 @@ enum StrEvent: EventType { case str(String) - var hashValue: Int + func hash(into hasher: inout Hasher) { switch self { - case .str(let str): return str.hashValue + case .str(let str): hasher.combine(str.hashValue) } } } diff --git a/Tests/SwiftStateTests/MyState.swift b/Tests/SwiftStateTests/MyState.swift index b1cc1db..7425bb6 100644 --- a/Tests/SwiftStateTests/MyState.swift +++ b/Tests/SwiftStateTests/MyState.swift @@ -17,10 +17,10 @@ enum StrState: StateType { case str(String) - var hashValue: Int + func hash(into hasher: inout Hasher) { switch self { - case .str(let str): return str.hashValue + case .str(let str): hasher.combine(str.hashValue) } } } diff --git a/Tests/SwiftStateTests/RouteMappingTests.swift b/Tests/SwiftStateTests/RouteMappingTests.swift index a0b8f38..a92ed06 100644 --- a/Tests/SwiftStateTests/RouteMappingTests.swift +++ b/Tests/SwiftStateTests/RouteMappingTests.swift @@ -21,13 +21,13 @@ private enum _State: StateType, Hashable case pending case loading(Int) - var hashValue: Int + func hash(into hasher: inout Hasher) { switch self { case .pending: - return "Pending".hashValue + hasher.combine("Pending".hashValue) case let .loading(x): - return "Loading\(x)".hashValue + hasher.combine("Loading\(x)".hashValue) } } } @@ -49,13 +49,13 @@ private enum _Event: SwiftState.EventType, Hashable case cancelAction case loadAction(Int) - var hashValue: Int + func hash(into hasher: inout Hasher) { switch self { case .cancelAction: - return "CancelAction".hashValue + hasher.combine("CancelAction".hashValue) case let .loadAction(x): - return "LoadAction\(x)".hashValue + hasher.combine("LoadAction\(x)".hashValue) } } }