swift 5
This commit is contained in:
parent
7e0917c2cd
commit
7219906306
@ -1,7 +1,7 @@
|
|||||||
language: objective-c
|
language: objective-c
|
||||||
xcode_project: Socket.IO-Client-Swift.xcodeproj # path to your xcodeproj folder
|
xcode_project: Socket.IO-Client-Swift.xcodeproj # path to your xcodeproj folder
|
||||||
xcode_scheme: SocketIO-Mac
|
xcode_scheme: SocketIO-Mac
|
||||||
osx_image: xcode10
|
osx_image: xcode10.2
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
# v15.0.0
|
||||||
|
|
||||||
|
- Swift 5
|
||||||
|
|
||||||
# v14.0.0
|
# v14.0.0
|
||||||
|
|
||||||
- Minimum version of the client is now Swift 4.2.
|
- Minimum version of the client is now Swift 4.2.
|
||||||
|
|||||||
2
Cartfile
2
Cartfile
@ -1 +1 @@
|
|||||||
github "daltoniam/Starscream" ~> 3.0
|
github "daltoniam/Starscream" ~> 3.1
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
github "daltoniam/Starscream" "3.0.6"
|
github "daltoniam/Starscream" "3.1.0"
|
||||||
|
|||||||
@ -6,8 +6,8 @@
|
|||||||
"repositoryURL": "https://github.com/daltoniam/Starscream",
|
"repositoryURL": "https://github.com/daltoniam/Starscream",
|
||||||
"state": {
|
"state": {
|
||||||
"branch": null,
|
"branch": null,
|
||||||
"revision": "ebdc260ea64e68f7569c62e8744b5cd15d3a49d6",
|
"revision": "9c03ef715d1bc9334b446c90df53586dd38cf849",
|
||||||
"version": "3.0.6"
|
"version": "3.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
// swift-tools-version:4.2
|
// swift-tools-version:5.0
|
||||||
|
|
||||||
import PackageDescription
|
import PackageDescription
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ let package = Package(
|
|||||||
.library(name: "SocketIO", targets: ["SocketIO"])
|
.library(name: "SocketIO", targets: ["SocketIO"])
|
||||||
],
|
],
|
||||||
dependencies: [
|
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: [
|
targets: [
|
||||||
.target(name: "SocketIO", dependencies: ["Starscream"]),
|
.target(name: "SocketIO", dependencies: ["Starscream"]),
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = "Socket.IO-Client-Swift"
|
s.name = "Socket.IO-Client-Swift"
|
||||||
s.module_name = "SocketIO"
|
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.summary = "Socket.IO-client for iOS and OS X"
|
||||||
s.description = <<-DESC
|
s.description = <<-DESC
|
||||||
Socket.IO-client for iOS and OS X.
|
Socket.IO-client for iOS and OS X.
|
||||||
@ -18,14 +18,14 @@ Pod::Spec.new do |s|
|
|||||||
s.requires_arc = true
|
s.requires_arc = true
|
||||||
s.source = {
|
s.source = {
|
||||||
:git => "https://github.com/socketio/socket.io-client-swift.git",
|
:git => "https://github.com/socketio/socket.io-client-swift.git",
|
||||||
:tag => 'v14.0.0',
|
:tag => 'v15.0.0',
|
||||||
:submodules => true
|
:submodules => true
|
||||||
}
|
}
|
||||||
|
|
||||||
s.swift_version = "4.2"
|
s.swift_version = "5"
|
||||||
s.pod_target_xcconfig = {
|
s.pod_target_xcconfig = {
|
||||||
'SWIFT_VERSION' => '4.2'
|
'SWIFT_VERSION' => '5.0'
|
||||||
}
|
}
|
||||||
s.source_files = "Source/SocketIO/**/*.swift", "Source/SocketIO/*.swift"
|
s.source_files = "Source/SocketIO/**/*.swift", "Source/SocketIO/*.swift"
|
||||||
s.dependency "Starscream", "~> 3.0.6"
|
s.dependency "Starscream", "~> 3.1"
|
||||||
end
|
end
|
||||||
|
|||||||
@ -394,7 +394,7 @@
|
|||||||
attributes = {
|
attributes = {
|
||||||
LastSwiftMigration = 0730;
|
LastSwiftMigration = 0730;
|
||||||
LastSwiftUpdateCheck = 0730;
|
LastSwiftUpdateCheck = 0730;
|
||||||
LastUpgradeCheck = 1000;
|
LastUpgradeCheck = 1020;
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
572EF2371B51F18A00EEBB58 = {
|
572EF2371B51F18A00EEBB58 = {
|
||||||
CreatedOnToolsVersion = 6.4;
|
CreatedOnToolsVersion = 6.4;
|
||||||
@ -411,6 +411,7 @@
|
|||||||
developmentRegion = English;
|
developmentRegion = English;
|
||||||
hasScannedForEncodings = 0;
|
hasScannedForEncodings = 0;
|
||||||
knownRegions = (
|
knownRegions = (
|
||||||
|
English,
|
||||||
en,
|
en,
|
||||||
);
|
);
|
||||||
mainGroup = 572EF20D1B51F12F00EEBB58;
|
mainGroup = 572EF20D1B51F12F00EEBB58;
|
||||||
@ -523,6 +524,7 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
BITCODE_GENERATION_MODE = bitcode;
|
BITCODE_GENERATION_MODE = bitcode;
|
||||||
|
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
CLANG_WARN_COMMA = YES;
|
CLANG_WARN_COMMA = YES;
|
||||||
@ -587,7 +589,7 @@
|
|||||||
PRODUCT_NAME = SocketIO;
|
PRODUCT_NAME = SocketIO;
|
||||||
SUPPORTED_PLATFORMS = "macosx appletvsimulator appletvos iphonesimulator iphoneos watchos watchsimulator";
|
SUPPORTED_PLATFORMS = "macosx appletvsimulator appletvos iphonesimulator iphoneos watchos watchsimulator";
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
SWIFT_VERSION = 3.0;
|
SWIFT_VERSION = 5.0;
|
||||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||||
VALID_ARCHS = "i386 x86_64 armv7 armv7s arm64 armv7k";
|
VALID_ARCHS = "i386 x86_64 armv7 armv7s arm64 armv7k";
|
||||||
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
||||||
@ -598,6 +600,7 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
BITCODE_GENERATION_MODE = bitcode;
|
BITCODE_GENERATION_MODE = bitcode;
|
||||||
|
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
CLANG_WARN_COMMA = YES;
|
CLANG_WARN_COMMA = YES;
|
||||||
@ -659,7 +662,7 @@
|
|||||||
PRODUCT_NAME = SocketIO;
|
PRODUCT_NAME = SocketIO;
|
||||||
SUPPORTED_PLATFORMS = "macosx appletvsimulator appletvos iphonesimulator iphoneos watchos watchsimulator";
|
SUPPORTED_PLATFORMS = "macosx appletvsimulator appletvos iphonesimulator iphoneos watchos watchsimulator";
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||||
SWIFT_VERSION = 3.0;
|
SWIFT_VERSION = 5.0;
|
||||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||||
VALID_ARCHS = "i386 x86_64 armv7 armv7s arm64 armv7k";
|
VALID_ARCHS = "i386 x86_64 armv7 armv7s arm64 armv7k";
|
||||||
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
||||||
@ -727,7 +730,7 @@
|
|||||||
SWIFT_INCLUDE_PATHS = "";
|
SWIFT_INCLUDE_PATHS = "";
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||||
SWIFT_VERSION = 4.0;
|
SWIFT_VERSION = 5.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2,3,4";
|
TARGETED_DEVICE_FAMILY = "1,2,3,4";
|
||||||
TVOS_DEPLOYMENT_TARGET = 10.0;
|
TVOS_DEPLOYMENT_TARGET = 10.0;
|
||||||
VALID_ARCHS = "$(inherited)";
|
VALID_ARCHS = "$(inherited)";
|
||||||
@ -790,7 +793,7 @@
|
|||||||
SUPPORTED_PLATFORMS = "$(inherited)";
|
SUPPORTED_PLATFORMS = "$(inherited)";
|
||||||
SWIFT_INCLUDE_PATHS = "";
|
SWIFT_INCLUDE_PATHS = "";
|
||||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||||
SWIFT_VERSION = 4.0;
|
SWIFT_VERSION = 5.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2,3,4";
|
TARGETED_DEVICE_FAMILY = "1,2,3,4";
|
||||||
TVOS_DEPLOYMENT_TARGET = 10.0;
|
TVOS_DEPLOYMENT_TARGET = 10.0;
|
||||||
VALID_ARCHS = "$(inherited)";
|
VALID_ARCHS = "$(inherited)";
|
||||||
@ -875,7 +878,7 @@
|
|||||||
SUPPORTED_PLATFORMS = "$(inherited)";
|
SUPPORTED_PLATFORMS = "$(inherited)";
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||||
SWIFT_VERSION = 4.0;
|
SWIFT_VERSION = 5.0;
|
||||||
TVOS_DEPLOYMENT_TARGET = 10.0;
|
TVOS_DEPLOYMENT_TARGET = 10.0;
|
||||||
VALID_ARCHS = "$(inherited)";
|
VALID_ARCHS = "$(inherited)";
|
||||||
};
|
};
|
||||||
@ -949,7 +952,7 @@
|
|||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
SUPPORTED_PLATFORMS = "$(inherited)";
|
SUPPORTED_PLATFORMS = "$(inherited)";
|
||||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||||
SWIFT_VERSION = 4.0;
|
SWIFT_VERSION = 5.0;
|
||||||
TVOS_DEPLOYMENT_TARGET = 10.0;
|
TVOS_DEPLOYMENT_TARGET = 10.0;
|
||||||
VALID_ARCHS = "$(inherited)";
|
VALID_ARCHS = "$(inherited)";
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "1000"
|
LastUpgradeVersion = "1020"
|
||||||
version = "1.3">
|
version = "1.3">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
|
|||||||
@ -36,9 +36,6 @@ public enum SocketAckStatus : String {
|
|||||||
private struct SocketAck : Hashable {
|
private struct SocketAck : Hashable {
|
||||||
let ack: Int
|
let ack: Int
|
||||||
var callback: AckCallback!
|
var callback: AckCallback!
|
||||||
var hashValue: Int {
|
|
||||||
return ack.hashValue
|
|
||||||
}
|
|
||||||
|
|
||||||
init(ack: Int) {
|
init(ack: Int) {
|
||||||
self.ack = ack
|
self.ack = ack
|
||||||
@ -49,6 +46,10 @@ private struct SocketAck : Hashable {
|
|||||||
self.callback = callback
|
self.callback = callback
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func hash(into hasher: inout Hasher) {
|
||||||
|
ack.hash(into: &hasher)
|
||||||
|
}
|
||||||
|
|
||||||
fileprivate static func <(lhs: SocketAck, rhs: SocketAck) -> Bool {
|
fileprivate static func <(lhs: SocketAck, rhs: SocketAck) -> Bool {
|
||||||
return lhs.ack < rhs.ack
|
return lhs.ack < rhs.ack
|
||||||
}
|
}
|
||||||
|
|||||||
@ -237,7 +237,7 @@ public protocol SocketIOClientSpec : AnyObject {
|
|||||||
|
|
||||||
public extension SocketIOClientSpec {
|
public extension SocketIOClientSpec {
|
||||||
/// Default implementation.
|
/// Default implementation.
|
||||||
public func didError(reason: String) {
|
func didError(reason: String) {
|
||||||
DefaultSocketLogger.Logger.error("\(reason)", type: "SocketIOClient")
|
DefaultSocketLogger.Logger.error("\(reason)", type: "SocketIOClient")
|
||||||
|
|
||||||
handleClientEvent(.error, data: [reason])
|
handleClientEvent(.error, data: [reason])
|
||||||
|
|||||||
@ -175,7 +175,7 @@ extension SocketEngineSpec {
|
|||||||
if polling {
|
if polling {
|
||||||
return .right("b4" + data.base64EncodedString(options: Data.Base64EncodingOptions(rawValue: 0)))
|
return .right("b4" + data.base64EncodedString(options: Data.Base64EncodingOptions(rawValue: 0)))
|
||||||
} else {
|
} else {
|
||||||
return .left(Data(bytes: [0x4]) + data)
|
return .left(Data([0x4]) + data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -158,7 +158,7 @@ public extension SocketPacket {
|
|||||||
// MARK: PacketType enum
|
// MARK: PacketType enum
|
||||||
|
|
||||||
/// The type of packets.
|
/// The type of packets.
|
||||||
public enum PacketType: Int {
|
enum PacketType: Int {
|
||||||
// MARK: Cases
|
// MARK: Cases
|
||||||
|
|
||||||
/// Connect: 0
|
/// Connect: 0
|
||||||
|
|||||||
@ -140,7 +140,7 @@ public extension SocketParsable where Self: SocketManagerSpec & SocketDataBuffer
|
|||||||
///
|
///
|
||||||
/// - parameter message: The string that needs parsing.
|
/// - parameter message: The string that needs parsing.
|
||||||
/// - returns: A completed socket packet or nil if the packet is invalid.
|
/// - 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 }
|
guard !message.isEmpty else { return nil }
|
||||||
|
|
||||||
DefaultSocketLogger.Logger.log("Parsing \(message)", type: "SocketParser")
|
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.
|
/// - 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.
|
/// - 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 {
|
guard !waitingPackets.isEmpty else {
|
||||||
DefaultSocketLogger.Logger.error("Got data when not remaking packet", type: "SocketParser")
|
DefaultSocketLogger.Logger.error("Got data when not remaking packet", type: "SocketParser")
|
||||||
|
|
||||||
|
|||||||
@ -51,17 +51,19 @@ public protocol SocketLogger : AnyObject {
|
|||||||
public extension SocketLogger {
|
public extension SocketLogger {
|
||||||
/// Default implementation.
|
/// Default implementation.
|
||||||
func log(_ message: @autoclosure () -> String, type: String) {
|
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.
|
/// Default implementation.
|
||||||
func error(_ message: @autoclosure () -> String, type: String) {
|
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) {
|
private func abstractLog(_ logType: String, message: @autoclosure () -> String, type: String) {
|
||||||
guard log else { return }
|
|
||||||
|
|
||||||
NSLog("\(logType) \(type): %@", message())
|
NSLog("\(logType) \(type): %@", message())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,7 +56,7 @@ struct SocketStringReader {
|
|||||||
mutating func readUntilOccurence(of string: String) -> String {
|
mutating func readUntilOccurence(of string: String) -> String {
|
||||||
let substring = message.utf16[currentIndex...]
|
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
|
currentIndex = message.utf16.endIndex
|
||||||
|
|
||||||
return String(substring)!
|
return String(substring)!
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user