From fc4e1802f60067cd79e2ef7d35900c2c25ba4292 Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 11 Feb 2019 19:01:43 +0000 Subject: [PATCH 1/4] call closeOutEngine to clean up after a ping timeout --- Source/SocketIO/Engine/SocketEngine.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/SocketIO/Engine/SocketEngine.swift b/Source/SocketIO/Engine/SocketEngine.swift index ee3af223..50839ad1 100644 --- a/Source/SocketIO/Engine/SocketEngine.swift +++ b/Source/SocketIO/Engine/SocketEngine.swift @@ -544,8 +544,7 @@ open class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePollable, So // Server is not responding if pongsMissed > pongsMissedMax { - client?.engineDidClose(reason: "Ping timeout") - + closeOutEngine(reason: "Ping timeout") return } From 7219906306a74f3502b17662f26fb4a1965016ce Mon Sep 17 00:00:00 2001 From: Erik Little Date: Tue, 26 Mar 2019 12:20:34 -0400 Subject: [PATCH 2/4] swift 5 --- .travis.yml | 2 +- CHANGELOG.md | 4 ++++ Cartfile | 2 +- Cartfile.resolved | 2 +- Package.resolved | 4 ++-- Package.swift | 4 ++-- Socket.IO-Client-Swift.podspec | 10 +++++----- .../project.pbxproj | 17 ++++++++++------- .../xcshareddata/xcschemes/SocketIO.xcscheme | 2 +- Source/SocketIO/Ack/SocketAckManager.swift | 7 ++++--- Source/SocketIO/Client/SocketIOClientSpec.swift | 2 +- Source/SocketIO/Engine/SocketEngineSpec.swift | 2 +- Source/SocketIO/Parse/SocketPacket.swift | 2 +- Source/SocketIO/Parse/SocketParsable.swift | 4 ++-- Source/SocketIO/Util/SocketLogger.swift | 10 ++++++---- Source/SocketIO/Util/SocketStringReader.swift | 2 +- 16 files changed, 43 insertions(+), 33 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2f387900..3db382d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: objective-c xcode_project: Socket.IO-Client-Swift.xcodeproj # path to your xcodeproj folder xcode_scheme: SocketIO-Mac -osx_image: xcode10 +osx_image: xcode10.2 branches: only: - master diff --git a/CHANGELOG.md b/CHANGELOG.md index 38fadbb7..7aa62bfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# v15.0.0 + +- Swift 5 + # v14.0.0 - Minimum version of the client is now Swift 4.2. diff --git a/Cartfile b/Cartfile index 1013fa13..4f886c2b 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "daltoniam/Starscream" ~> 3.0 +github "daltoniam/Starscream" ~> 3.1 diff --git a/Cartfile.resolved b/Cartfile.resolved index d6801c91..c76f7271 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "daltoniam/Starscream" "3.0.6" +github "daltoniam/Starscream" "3.1.0" diff --git a/Package.resolved b/Package.resolved index 8a888aa1..6f383f4c 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/daltoniam/Starscream", "state": { "branch": null, - "revision": "ebdc260ea64e68f7569c62e8744b5cd15d3a49d6", - "version": "3.0.6" + "revision": "9c03ef715d1bc9334b446c90df53586dd38cf849", + "version": "3.1.0" } } ] diff --git a/Package.swift b/Package.swift index d7a50903..001312c9 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:4.2 +// swift-tools-version:5.0 import PackageDescription @@ -8,7 +8,7 @@ let package = Package( .library(name: "SocketIO", targets: ["SocketIO"]) ], dependencies: [ - .package(url: "https://github.com/daltoniam/Starscream", .upToNextMinor(from: "3.0.0")), + .package(url: "https://github.com/daltoniam/Starscream", .upToNextMinor(from: "3.1.0")), ], targets: [ .target(name: "SocketIO", dependencies: ["Starscream"]), diff --git a/Socket.IO-Client-Swift.podspec b/Socket.IO-Client-Swift.podspec index adebe238..f0987dfc 100644 --- a/Socket.IO-Client-Swift.podspec +++ b/Socket.IO-Client-Swift.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "Socket.IO-Client-Swift" s.module_name = "SocketIO" - s.version = "14.0.0" + s.version = "15.0.0" s.summary = "Socket.IO-client for iOS and OS X" s.description = <<-DESC Socket.IO-client for iOS and OS X. @@ -18,14 +18,14 @@ Pod::Spec.new do |s| s.requires_arc = true s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", - :tag => 'v14.0.0', + :tag => 'v15.0.0', :submodules => true } - s.swift_version = "4.2" + s.swift_version = "5" s.pod_target_xcconfig = { - 'SWIFT_VERSION' => '4.2' + 'SWIFT_VERSION' => '5.0' } s.source_files = "Source/SocketIO/**/*.swift", "Source/SocketIO/*.swift" - s.dependency "Starscream", "~> 3.0.6" + s.dependency "Starscream", "~> 3.1" end diff --git a/Socket.IO-Client-Swift.xcodeproj/project.pbxproj b/Socket.IO-Client-Swift.xcodeproj/project.pbxproj index f5b648dd..21c31ee5 100644 --- a/Socket.IO-Client-Swift.xcodeproj/project.pbxproj +++ b/Socket.IO-Client-Swift.xcodeproj/project.pbxproj @@ -394,7 +394,7 @@ attributes = { LastSwiftMigration = 0730; LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 1000; + LastUpgradeCheck = 1020; TargetAttributes = { 572EF2371B51F18A00EEBB58 = { CreatedOnToolsVersion = 6.4; @@ -411,6 +411,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = 572EF20D1B51F12F00EEBB58; @@ -523,6 +524,7 @@ isa = XCBuildConfiguration; buildSettings = { BITCODE_GENERATION_MODE = bitcode; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; @@ -587,7 +589,7 @@ PRODUCT_NAME = SocketIO; SUPPORTED_PLATFORMS = "macosx appletvsimulator appletvos iphonesimulator iphoneos watchos watchsimulator"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TVOS_DEPLOYMENT_TARGET = 9.0; VALID_ARCHS = "i386 x86_64 armv7 armv7s arm64 armv7k"; WATCHOS_DEPLOYMENT_TARGET = 2.0; @@ -598,6 +600,7 @@ isa = XCBuildConfiguration; buildSettings = { BITCODE_GENERATION_MODE = bitcode; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; @@ -659,7 +662,7 @@ PRODUCT_NAME = SocketIO; SUPPORTED_PLATFORMS = "macosx appletvsimulator appletvos iphonesimulator iphoneos watchos watchsimulator"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TVOS_DEPLOYMENT_TARGET = 9.0; VALID_ARCHS = "i386 x86_64 armv7 armv7s arm64 armv7k"; WATCHOS_DEPLOYMENT_TARGET = 2.0; @@ -727,7 +730,7 @@ SWIFT_INCLUDE_PATHS = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2,3,4"; TVOS_DEPLOYMENT_TARGET = 10.0; VALID_ARCHS = "$(inherited)"; @@ -790,7 +793,7 @@ SUPPORTED_PLATFORMS = "$(inherited)"; SWIFT_INCLUDE_PATHS = ""; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2,3,4"; TVOS_DEPLOYMENT_TARGET = 10.0; VALID_ARCHS = "$(inherited)"; @@ -875,7 +878,7 @@ SUPPORTED_PLATFORMS = "$(inherited)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TVOS_DEPLOYMENT_TARGET = 10.0; VALID_ARCHS = "$(inherited)"; }; @@ -949,7 +952,7 @@ SDKROOT = macosx; SUPPORTED_PLATFORMS = "$(inherited)"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TVOS_DEPLOYMENT_TARGET = 10.0; VALID_ARCHS = "$(inherited)"; }; diff --git a/Socket.IO-Client-Swift.xcodeproj/xcshareddata/xcschemes/SocketIO.xcscheme b/Socket.IO-Client-Swift.xcodeproj/xcshareddata/xcschemes/SocketIO.xcscheme index 28680816..890f0d4b 100644 --- a/Socket.IO-Client-Swift.xcodeproj/xcshareddata/xcschemes/SocketIO.xcscheme +++ b/Socket.IO-Client-Swift.xcodeproj/xcshareddata/xcschemes/SocketIO.xcscheme @@ -1,6 +1,6 @@ Bool { return lhs.ack < rhs.ack } diff --git a/Source/SocketIO/Client/SocketIOClientSpec.swift b/Source/SocketIO/Client/SocketIOClientSpec.swift index de9f31ab..06c67e6e 100644 --- a/Source/SocketIO/Client/SocketIOClientSpec.swift +++ b/Source/SocketIO/Client/SocketIOClientSpec.swift @@ -237,7 +237,7 @@ public protocol SocketIOClientSpec : AnyObject { public extension SocketIOClientSpec { /// Default implementation. - public func didError(reason: String) { + func didError(reason: String) { DefaultSocketLogger.Logger.error("\(reason)", type: "SocketIOClient") handleClientEvent(.error, data: [reason]) diff --git a/Source/SocketIO/Engine/SocketEngineSpec.swift b/Source/SocketIO/Engine/SocketEngineSpec.swift index 2f01d741..a7ccf337 100644 --- a/Source/SocketIO/Engine/SocketEngineSpec.swift +++ b/Source/SocketIO/Engine/SocketEngineSpec.swift @@ -175,7 +175,7 @@ extension SocketEngineSpec { if polling { return .right("b4" + data.base64EncodedString(options: Data.Base64EncodingOptions(rawValue: 0))) } else { - return .left(Data(bytes: [0x4]) + data) + return .left(Data([0x4]) + data) } } diff --git a/Source/SocketIO/Parse/SocketPacket.swift b/Source/SocketIO/Parse/SocketPacket.swift index e715d047..1d818dbb 100644 --- a/Source/SocketIO/Parse/SocketPacket.swift +++ b/Source/SocketIO/Parse/SocketPacket.swift @@ -158,7 +158,7 @@ public extension SocketPacket { // MARK: PacketType enum /// The type of packets. - public enum PacketType: Int { + enum PacketType: Int { // MARK: Cases /// Connect: 0 diff --git a/Source/SocketIO/Parse/SocketParsable.swift b/Source/SocketIO/Parse/SocketParsable.swift index d181df46..9be9c603 100644 --- a/Source/SocketIO/Parse/SocketParsable.swift +++ b/Source/SocketIO/Parse/SocketParsable.swift @@ -140,7 +140,7 @@ public extension SocketParsable where Self: SocketManagerSpec & SocketDataBuffer /// /// - parameter message: The string that needs parsing. /// - returns: A completed socket packet or nil if the packet is invalid. - public func parseSocketMessage(_ message: String) -> SocketPacket? { + func parseSocketMessage(_ message: String) -> SocketPacket? { guard !message.isEmpty else { return nil } DefaultSocketLogger.Logger.log("Parsing \(message)", type: "SocketParser") @@ -166,7 +166,7 @@ public extension SocketParsable where Self: SocketManagerSpec & SocketDataBuffer /// /// - parameter data: The data that should be attached to a packet. /// - returns: A completed socket packet if there is no more data left to collect. - public func parseBinaryData(_ data: Data) -> SocketPacket? { + func parseBinaryData(_ data: Data) -> SocketPacket? { guard !waitingPackets.isEmpty else { DefaultSocketLogger.Logger.error("Got data when not remaking packet", type: "SocketParser") diff --git a/Source/SocketIO/Util/SocketLogger.swift b/Source/SocketIO/Util/SocketLogger.swift index 69293fbd..ccb92be4 100644 --- a/Source/SocketIO/Util/SocketLogger.swift +++ b/Source/SocketIO/Util/SocketLogger.swift @@ -51,17 +51,19 @@ public protocol SocketLogger : AnyObject { public extension SocketLogger { /// Default implementation. func log(_ message: @autoclosure () -> String, type: String) { - abstractLog("LOG", message: message, type: type) + guard log else { return } + + abstractLog("LOG", message: message(), type: type) } /// Default implementation. func error(_ message: @autoclosure () -> String, type: String) { - abstractLog("ERROR", message: message, type: type) + guard log else { return } + + abstractLog("ERROR", message: message(), type: type) } private func abstractLog(_ logType: String, message: @autoclosure () -> String, type: String) { - guard log else { return } - NSLog("\(logType) \(type): %@", message()) } } diff --git a/Source/SocketIO/Util/SocketStringReader.swift b/Source/SocketIO/Util/SocketStringReader.swift index 0a743440..e9abb7e0 100644 --- a/Source/SocketIO/Util/SocketStringReader.swift +++ b/Source/SocketIO/Util/SocketStringReader.swift @@ -56,7 +56,7 @@ struct SocketStringReader { mutating func readUntilOccurence(of string: String) -> String { let substring = message.utf16[currentIndex...] - guard let foundIndex = substring.index(of: string.utf16.first!) else { + guard let foundIndex = substring.firstIndex(where: { $0 == string.utf16.first! }) else { currentIndex = message.utf16.endIndex return String(substring)! From 3df38fcff5d441d5c8f567c2288f46c50cb8929c Mon Sep 17 00:00:00 2001 From: Erik Little Date: Tue, 26 Mar 2019 12:35:31 -0400 Subject: [PATCH 3/4] beta version --- Socket.IO-Client-Swift.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Socket.IO-Client-Swift.podspec b/Socket.IO-Client-Swift.podspec index f0987dfc..671e8593 100644 --- a/Socket.IO-Client-Swift.podspec +++ b/Socket.IO-Client-Swift.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "Socket.IO-Client-Swift" s.module_name = "SocketIO" - s.version = "15.0.0" + s.version = "15.0.0-beta1" s.summary = "Socket.IO-client for iOS and OS X" s.description = <<-DESC Socket.IO-client for iOS and OS X. @@ -18,7 +18,7 @@ Pod::Spec.new do |s| s.requires_arc = true s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", - :tag => 'v15.0.0', + :tag => 'v15.0.0-beta', :submodules => true } From bd7428485cd3482f358a7d86d62ddbd9f2961085 Mon Sep 17 00:00:00 2001 From: Erik Little Date: Tue, 26 Mar 2019 12:41:23 -0400 Subject: [PATCH 4/4] correct beta version in podspec --- Socket.IO-Client-Swift.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Socket.IO-Client-Swift.podspec b/Socket.IO-Client-Swift.podspec index 671e8593..1bcfe306 100644 --- a/Socket.IO-Client-Swift.podspec +++ b/Socket.IO-Client-Swift.podspec @@ -18,7 +18,7 @@ Pod::Spec.new do |s| s.requires_arc = true s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", - :tag => 'v15.0.0-beta', + :tag => 'v15.0.0-beta1', :submodules => true }