From 917b3be9dcdfea4e962d7dd5ec869a7bbbfac5cd Mon Sep 17 00:00:00 2001 From: Emanuele Rudel Date: Sat, 15 Jun 2019 23:17:25 -0700 Subject: [PATCH 1/9] Update for Swift 5.0 --- Sources/EventType.swift | 3 +-- Sources/Transition.swift | 5 +++-- SwiftState.xcodeproj/project.pbxproj | 20 +++++++++++++------ .../xcschemes/SwiftState.xcscheme | 8 +++----- .../HierarchicalMachineTests.swift | 8 ++++---- Tests/SwiftStateTests/MyEvent.swift | 4 ++-- Tests/SwiftStateTests/MyState.swift | 4 ++-- Tests/SwiftStateTests/RouteMappingTests.swift | 12 +++++------ 8 files changed, 35 insertions(+), 29 deletions(-) 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.xcodeproj/project.pbxproj b/SwiftState.xcodeproj/project.pbxproj index 643c163..3e261d5 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 = ""; }; @@ -519,7 +527,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.inamiy.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(PROJECT_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -539,7 +547,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.inamiy.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(PROJECT_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -559,7 +567,7 @@ INFOPLIST_FILE = Tests/SwiftStateTests/Info.plist; PRODUCT_BUNDLE_IDENTIFIER = "com.inamiy.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -575,7 +583,7 @@ INFOPLIST_FILE = Tests/SwiftStateTests/Info.plist; PRODUCT_BUNDLE_IDENTIFIER = "com.inamiy.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.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) } } } From e7f32fd6ab2386a317f439b6385f2dabd6db4fb7 Mon Sep 17 00:00:00 2001 From: Yasuhiro Inami Date: Mon, 17 Jun 2019 02:03:27 +0900 Subject: [PATCH 2/9] Update xcconfig --- Configurations/Base.xcconfig | 4 +++- SwiftState.xcodeproj/project.pbxproj | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-) 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/SwiftState.xcodeproj/project.pbxproj b/SwiftState.xcodeproj/project.pbxproj index 66629a2..a8453b6 100644 --- a/SwiftState.xcodeproj/project.pbxproj +++ b/SwiftState.xcodeproj/project.pbxproj @@ -528,7 +528,6 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.inamiy.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(PROJECT_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -549,7 +548,6 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.inamiy.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(PROJECT_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 5.0; }; name = Release; }; @@ -569,7 +567,6 @@ INFOPLIST_FILE = Tests/SwiftStateTests/Info.plist; PRODUCT_BUNDLE_IDENTIFIER = "com.inamiy.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -585,7 +582,6 @@ INFOPLIST_FILE = Tests/SwiftStateTests/Info.plist; PRODUCT_BUNDLE_IDENTIFIER = "com.inamiy.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; }; name = Release; }; From 8cb92f38ccf34a8b3aa81c5c5cd90ebddaa976f8 Mon Sep 17 00:00:00 2001 From: Yasuhiro Inami Date: Mon, 17 Jun 2019 02:03:54 +0900 Subject: [PATCH 3/9] Update podspec --- SwiftState.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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' } From fbc36eab93a59a368e5f24a3b4902f1b941b1d39 Mon Sep 17 00:00:00 2001 From: Srinivas Prabhu Date: Tue, 8 Dec 2020 18:37:11 +0530 Subject: [PATCH 4/9] spm support --- Package.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Package.swift b/Package.swift index f0b256b..1fd0a49 100644 --- a/Package.swift +++ b/Package.swift @@ -10,4 +10,12 @@ import PackageDescription let package = Package( name: "SwiftState" + name: "SwiftState", + platforms: [.iOS(.v11),.watchOS(*)], + products: [ + .library(name: "SwiftState", targets: ["SwiftState"]) + ], + targets: [ + .target(name: "SwiftState", path: "Sources") + ] ) From 1c5b64de18cc44561c4061b885dcb3c6da5af558 Mon Sep 17 00:00:00 2001 From: Srinivas Prabhu Date: Tue, 8 Dec 2020 18:42:53 +0530 Subject: [PATCH 5/9] compiler error fix --- Package.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Package.swift b/Package.swift index 1fd0a49..ebc1a95 100644 --- a/Package.swift +++ b/Package.swift @@ -9,7 +9,6 @@ import PackageDescription let package = Package( - name: "SwiftState" name: "SwiftState", platforms: [.iOS(.v11),.watchOS(*)], products: [ From 9f3f97b9e065d9cc9f6d29d40ff6e6a7ae82e157 Mon Sep 17 00:00:00 2001 From: Srinivas Prabhu Date: Tue, 8 Dec 2020 18:47:36 +0530 Subject: [PATCH 6/9] swift package manager support --- Package.swift | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Package.swift b/Package.swift index ebc1a95..b4f6daa 100644 --- a/Package.swift +++ b/Package.swift @@ -1,20 +1,28 @@ -// -// 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", - platforms: [.iOS(.v11),.watchOS(*)], products: [ - .library(name: "SwiftState", targets: ["SwiftState"]) + // 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: [ - .target(name: "SwiftState", path: "Sources") + // 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: []), + .testTarget( + name: "SwiftStateTests", + dependencies: ["SwiftState"]), ] ) From 3a49bb88f58b764ff2b2db42146fade2ff683dd8 Mon Sep 17 00:00:00 2001 From: Srinivas Prabhu Date: Tue, 8 Dec 2020 18:53:10 +0530 Subject: [PATCH 7/9] Attempt to fix spm issue --- Sources/{_HandlerID.swift => HandlerID.swift} | 0 Sources/{_HandlerInfo.swift => HandlerInfo.swift} | 0 Sources/{_Random.swift => Random.swift} | 0 Sources/{_RouteID.swift => RouteID.swift} | 0 Sources/{_RouteMappingID.swift => RouteMappingID.swift} | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename Sources/{_HandlerID.swift => HandlerID.swift} (100%) rename Sources/{_HandlerInfo.swift => HandlerInfo.swift} (100%) rename Sources/{_Random.swift => Random.swift} (100%) rename Sources/{_RouteID.swift => RouteID.swift} (100%) rename Sources/{_RouteMappingID.swift => RouteMappingID.swift} (100%) diff --git a/Sources/_HandlerID.swift b/Sources/HandlerID.swift similarity index 100% rename from Sources/_HandlerID.swift rename to Sources/HandlerID.swift diff --git a/Sources/_HandlerInfo.swift b/Sources/HandlerInfo.swift similarity index 100% rename from Sources/_HandlerInfo.swift rename to Sources/HandlerInfo.swift diff --git a/Sources/_Random.swift b/Sources/Random.swift similarity index 100% rename from Sources/_Random.swift rename to Sources/Random.swift diff --git a/Sources/_RouteID.swift b/Sources/RouteID.swift similarity index 100% rename from Sources/_RouteID.swift rename to Sources/RouteID.swift diff --git a/Sources/_RouteMappingID.swift b/Sources/RouteMappingID.swift similarity index 100% rename from Sources/_RouteMappingID.swift rename to Sources/RouteMappingID.swift From 84886b8259b9a093d8445abf39c91f6461c6ad32 Mon Sep 17 00:00:00 2001 From: Srinivas Prabhu Date: Tue, 8 Dec 2020 19:01:31 +0530 Subject: [PATCH 8/9] update --- Sources/{HandlerID.swift => _HandlerID.swift} | 0 Sources/{HandlerInfo.swift => _HandlerInfo.swift} | 0 Sources/{Random.swift => _Random.swift} | 0 Sources/{RouteID.swift => _RouteID.swift} | 0 Sources/{RouteMappingID.swift => _RouteMappingID.swift} | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename Sources/{HandlerID.swift => _HandlerID.swift} (100%) rename Sources/{HandlerInfo.swift => _HandlerInfo.swift} (100%) rename Sources/{Random.swift => _Random.swift} (100%) rename Sources/{RouteID.swift => _RouteID.swift} (100%) rename Sources/{RouteMappingID.swift => _RouteMappingID.swift} (100%) diff --git a/Sources/HandlerID.swift b/Sources/_HandlerID.swift similarity index 100% rename from Sources/HandlerID.swift rename to Sources/_HandlerID.swift diff --git a/Sources/HandlerInfo.swift b/Sources/_HandlerInfo.swift similarity index 100% rename from Sources/HandlerInfo.swift rename to Sources/_HandlerInfo.swift diff --git a/Sources/Random.swift b/Sources/_Random.swift similarity index 100% rename from Sources/Random.swift rename to Sources/_Random.swift diff --git a/Sources/RouteID.swift b/Sources/_RouteID.swift similarity index 100% rename from Sources/RouteID.swift rename to Sources/_RouteID.swift diff --git a/Sources/RouteMappingID.swift b/Sources/_RouteMappingID.swift similarity index 100% rename from Sources/RouteMappingID.swift rename to Sources/_RouteMappingID.swift From 43aa9c04d60b0be5d3140f0e8a23e6670371f51b Mon Sep 17 00:00:00 2001 From: Srinivas Prabhu Date: Tue, 8 Dec 2020 19:07:26 +0530 Subject: [PATCH 9/9] Updated source path in spm file --- Package.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index b4f6daa..8c11573 100644 --- a/Package.swift +++ b/Package.swift @@ -20,9 +20,11 @@ let package = Package( // Targets can depend on other targets in this package, and on products in packages this package depends on. .target( name: "SwiftState", - dependencies: []), + dependencies: [], + path:"Sources"), .testTarget( name: "SwiftStateTests", - dependencies: ["SwiftState"]), + dependencies: ["SwiftState"], + path:"Sources"), ] )