Compare commits

..

3 Commits

Author SHA1 Message Date
Erik Little
e644abb839
enable bitcode 2023-02-01 18:35:31 -08:00
Erik Little
a6825c8db1
disable bitcode 2023-02-01 18:23:57 -08:00
Erik Little
b8f1fbabd6
try and fix carthage build 2023-02-01 18:20:18 -08:00
17 changed files with 51 additions and 110 deletions

2
.gitignore vendored
View File

@ -50,5 +50,3 @@ Socket.IO-Test-Server/node_modules/*
.idea/
docs/docsets/
docs/undocumented.json
.swiftpm

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>

View File

@ -1,8 +1,3 @@
# v16.1.0
- Remove support for iOS 11.
- Update to Starscream 4.0.6
# v16.0.0
- Removed Objective-C support. It's time for you to embrace Swift.

View File

@ -1 +1 @@
github "daltoniam/Starscream" ~> 4.0.8
github "daltoniam/Starscream" ~> 4.0

View File

@ -1 +1 @@
github "daltoniam/Starscream" "4.0.8"
github "daltoniam/Starscream" "4.0.4"

View File

@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/daltoniam/Starscream",
"state": {
"branch": null,
"revision": "c6bfd1af48efcc9a9ad203665db12375ba6b145a",
"version": "4.0.8"
"revision": "df8d82047f6654d8e4b655d1b1525c64e1059d21",
"version": "4.0.4"
}
}
]

View File

@ -1,4 +1,4 @@
// swift-tools-version:5.4
// swift-tools-version:5.3
import PackageDescription
@ -8,7 +8,7 @@ let package = Package(
.library(name: "SocketIO", targets: ["SocketIO"])
],
dependencies: [
.package(url: "https://github.com/daltoniam/Starscream", .upToNextMajor(from: "4.0.8")),
.package(url: "https://github.com/daltoniam/Starscream", .upToNextMinor(from: "4.0.0")),
],
targets: [
.target(name: "SocketIO", dependencies: ["Starscream"]),

View File

@ -18,7 +18,7 @@ socket.on("currentAmount") {data, ack in
guard let cur = data[0] as? Double else { return }
socket.emitWithAck("canUpdate", cur).timingOut(after: 0) {data in
if data.first as? String ?? "passed" == SocketAckStatus.noAck {
if data.first as? String ?? "passed" == SocketAckValue.noAck {
// Handle ack timeout
}
@ -61,7 +61,7 @@ let package = Package(
.executable(name: "socket.io-test", targets: ["YourTargetName"])
],
dependencies: [
.package(url: "https://github.com/socketio/socket.io-client-swift", .upToNextMinor(from: "16.1.1"))
.package(url: "https://github.com/socketio/socket.io-client-swift", .upToNextMinor(from: "15.0.0"))
],
targets: [
.target(name: "YourTargetName", dependencies: ["SocketIO"], path: "./Path/To/Your/Sources")
@ -74,7 +74,7 @@ Then import `import SocketIO`.
### Carthage
Add this line to your `Cartfile`:
```
github "socketio/socket.io-client-swift" ~> 16.1.1
github "socketio/socket.io-client-swift" ~> 15.2.0
```
Run `carthage update --platform ios,macosx`.
@ -88,7 +88,7 @@ Create `Podfile` and add `pod 'Socket.IO-Client-Swift'`:
use_frameworks!
target 'YourApp' do
pod 'Socket.IO-Client-Swift', '~> 16.1.1'
pod 'Socket.IO-Client-Swift', '~> 15.2.0'
end
```

View File

@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "Socket.IO-Client-Swift"
s.module_name = "SocketIO"
s.version = "16.1.1"
s.version = "16.0.1"
s.summary = "Socket.IO-client for iOS and OS X"
s.description = <<-DESC
Socket.IO-client for iOS and OS X.
@ -11,21 +11,21 @@ Pod::Spec.new do |s|
s.homepage = "https://github.com/socketio/socket.io-client-swift"
s.license = { :type => 'MIT' }
s.author = { "Erik" => "nuclear.ace@gmail.com" }
s.ios.deployment_target = '12.0'
s.ios.deployment_target = '10.0'
s.osx.deployment_target = '10.13'
s.tvos.deployment_target = '12.0'
s.tvos.deployment_target = '10.0'
s.watchos.deployment_target = '5.0'
s.requires_arc = true
s.source = {
:git => "https://github.com/socketio/socket.io-client-swift.git",
:tag => 'v16.1.1',
:tag => 'v16.0.1',
:submodules => true
}
s.swift_version = "5"
s.pod_target_xcconfig = {
'SWIFT_VERSION' => '5.4'
'SWIFT_VERSION' => '5.0'
}
s.source_files = "Source/SocketIO/**/*.swift", "Source/SocketIO/*.swift"
s.dependency "Starscream", "~> 4.0.8"
s.dependency "Starscream", "~> 4.0"
end

View File

@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 54;
objectVersion = 52;
objects = {
/* Begin PBXBuildFile section */
@ -511,6 +511,7 @@
572EF2121B51F12F00EEBB58 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BITCODE_GENERATION_MODE = bitcode;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
@ -530,6 +531,8 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
ENABLE_BITCODE = YES;
"ENABLE_BITCODE[sdk=macosx*]" = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
FRAMEWORK_SEARCH_PATHS = (
@ -548,7 +551,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.14;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = SocketIO;
SUPPORTED_PLATFORMS = "macosx appletvsimulator appletvos iphonesimulator iphoneos watchos watchsimulator xrsimulator xros";
SUPPORTED_PLATFORMS = "macosx appletvsimulator appletvos iphonesimulator iphoneos watchos watchsimulator";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TVOS_DEPLOYMENT_TARGET = 10.0;
@ -560,6 +563,7 @@
572EF2131B51F12F00EEBB58 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BITCODE_GENERATION_MODE = bitcode;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
@ -579,6 +583,8 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
ENABLE_BITCODE = YES;
"ENABLE_BITCODE[sdk=macosx*]" = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@ -594,7 +600,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MACOSX_DEPLOYMENT_TARGET = 10.14;
PRODUCT_NAME = SocketIO;
SUPPORTED_PLATFORMS = "macosx appletvsimulator appletvos iphonesimulator iphoneos watchos watchsimulator xrsimulator xros";
SUPPORTED_PLATFORMS = "macosx appletvsimulator appletvos iphonesimulator iphoneos watchos watchsimulator";
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 5.0;
@ -607,7 +613,6 @@
572EF24C1B51F18A00EEBB58 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES;
ALWAYS_SEARCH_USER_PATHS = NO;
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
@ -632,6 +637,8 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_BITCODE = NO;
"ENABLE_BITCODE[arch=*]" = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
@ -652,7 +659,6 @@
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = SocketIO/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@ -672,14 +678,12 @@
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "$(inherited)";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_INCLUDE_PATHS = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4,7";
TVOS_DEPLOYMENT_TARGET = 12.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4";
TVOS_DEPLOYMENT_TARGET = 10.0;
VALID_ARCHS = "$(inherited)";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
@ -689,7 +693,6 @@
572EF24D1B51F18A00EEBB58 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES;
ALWAYS_SEARCH_USER_PATHS = NO;
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
@ -714,6 +717,8 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_BITCODE = YES;
"ENABLE_BITCODE[arch=*]" = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
@ -729,7 +734,6 @@
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = SocketIO/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@ -748,13 +752,11 @@
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "$(inherited)";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_INCLUDE_PATHS = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4,7";
TVOS_DEPLOYMENT_TARGET = 12.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4";
TVOS_DEPLOYMENT_TARGET = 10.0;
VALID_ARCHS = "$(inherited)";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
@ -782,6 +784,7 @@
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_BITCODE = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(DEVELOPER_FRAMEWORKS_DIR)",
@ -834,7 +837,7 @@
"@loader_path/../Frameworks",
);
LIBRARY_SEARCH_PATHS = "$(inherited)";
MACOSX_DEPLOYMENT_TARGET = 10.13;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "io.socket.$(PRODUCT_NAME:rfc1034identifier)";
@ -844,7 +847,7 @@
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
TVOS_DEPLOYMENT_TARGET = 12.0;
TVOS_DEPLOYMENT_TARGET = 10.0;
VALID_ARCHS = "$(inherited)";
};
name = Debug;
@ -870,6 +873,7 @@
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_BITCODE = NO;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_SEARCH_PATHS = (
@ -916,7 +920,7 @@
"@loader_path/../Frameworks",
);
LIBRARY_SEARCH_PATHS = "$(inherited)";
MACOSX_DEPLOYMENT_TARGET = 10.13;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = "io.socket.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
@ -924,7 +928,7 @@
SUPPORTED_PLATFORMS = "$(inherited)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
TVOS_DEPLOYMENT_TARGET = 12.0;
TVOS_DEPLOYMENT_TARGET = 10.0;
VALID_ARCHS = "$(inherited)";
};
name = Release;

View File

@ -136,8 +136,8 @@ public final class OnAckCallback: NSObject {
guard seconds != 0 else { return }
socket.manager?.handleQueue.asyncAfter(deadline: DispatchTime.now() + seconds) {[weak socket] in
guard let socket = socket else { return }
socket.manager?.handleQueue.asyncAfter(deadline: DispatchTime.now() + seconds) {[weak socket, weak self] in
guard let socket = socket, let `self` = self else { return }
socket.ackHandlers.timeoutAck(self.ackNumber)
}

View File

@ -150,8 +150,7 @@ open class SocketIOClient: NSObject, SocketIOClientSpec {
manager.handleQueue.asyncAfter(deadline: DispatchTime.now() + timeoutAfter) {[weak self] in
guard let this = self, this.status == .connecting || this.status == .notConnected else { return }
DefaultSocketLogger.Logger.log("Timeout: Socket not connected, so setting to disconnected", type: this.logType)
this.status = .disconnected
this.leaveNamespace()

View File

@ -28,10 +28,8 @@ import Starscream
/// The class that handles the engine.io protocol and transports.
/// See `SocketEnginePollable` and `SocketEngineWebsocket` for transport specific methods.
open class SocketEngine: NSObject, WebSocketDelegate, URLSessionDelegate,
SocketEnginePollable, SocketEngineWebsocket, ConfigSettable {
open class SocketEngine:
NSObject, WebSocketDelegate, URLSessionDelegate, SocketEnginePollable, SocketEngineWebsocket, ConfigSettable {
// MARK: Properties
private static let logType = "SocketEngine"
@ -749,11 +747,11 @@ extension SocketEngine {
/// - Parameters:
/// - event: WS Event
/// - _:
public func didReceive(event: Starscream.WebSocketEvent, client: Starscream.WebSocketClient) {
public func didReceive(event: WebSocketEvent, client _: WebSocket) {
switch event {
case let .connected(headers):
wsConnected = true
self.client?.engineDidWebsocketUpgrade(headers: headers)
client?.engineDidWebsocketUpgrade(headers: headers)
websocketDidConnect()
case .cancelled:
wsConnected = false
@ -761,12 +759,6 @@ extension SocketEngine {
case .disconnected(_, _):
wsConnected = false
websocketDidDisconnect(error: nil)
case .viabilityChanged(false):
wsConnected = false
websocketDidDisconnect(error: nil)
case .peerClosed:
wsConnected = false
websocketDidDisconnect(error: nil)
case let .text(msg):
parseEngineMessage(msg)
case let .binary(data):

View File

@ -132,7 +132,7 @@ open class SocketManager: NSObject, SocketManagerSpec, SocketParsable, SocketDat
private(set) var reconnectAttempts = -1
private var _config: SocketIOClientConfiguration
internal var currentReconnectAttempt = 0
private var currentReconnectAttempt = 0
private var reconnecting = false
// MARK: Initializers
@ -186,8 +186,9 @@ open class SocketManager: NSObject, SocketManagerSpec, SocketParsable, SocketDat
///
/// Override if you wish to attach a custom `SocketEngineSpec`.
open func connect() {
if status == .connected || (status == .connecting && currentReconnectAttempt == 0) {
guard !status.active else {
DefaultSocketLogger.Logger.log("Tried connecting an already active socket", type: SocketManager.logType)
return
}

View File

@ -28,6 +28,7 @@ class SocketAckManagerTest : XCTestCase {
func testManagerTimeoutAck() {
let callbackExpection = expectation(description: "Manager should timeout ack with noAck status")
let itemsArray = ["Hi", "ho"]
func callback(_ items: [Any]) {
XCTAssertEqual(items.count, 1, "Timed out ack should have one value")

View File

@ -60,44 +60,6 @@ class SocketMangerTest : XCTestCase {
waitForExpectations(timeout: 0.3)
}
func testManagerDoesNotCallConnectWhenConnectingWithLessThanOneReconnect() {
setUpSockets()
let expect = expectation(description: "The manager should not call connect on the engine")
expect.isInverted = true
let engine = TestEngine(client: manager, url: manager.socketURL, options: nil)
engine.onConnect = {
expect.fulfill()
}
manager.setTestStatus(.connecting)
manager.setCurrentReconnect(currentReconnect: 0)
manager.engine = engine
manager.connect()
waitForExpectations(timeout: 0.3)
}
func testManagerCallConnectWhenConnectingAndMoreThanOneReconnect() {
setUpSockets()
let expect = expectation(description: "The manager should call connect on the engine")
let engine = TestEngine(client: manager, url: manager.socketURL, options: nil)
engine.onConnect = {
expect.fulfill()
}
manager.setTestStatus(.connecting)
manager.setCurrentReconnect(currentReconnect: 1)
manager.engine = engine
manager.connect()
waitForExpectations(timeout: 0.8)
}
func testManagerCallsDisconnect() {
setUpSockets()
@ -192,10 +154,6 @@ public enum ManagerExpectation: String {
}
public class TestManager: SocketManager {
public func setCurrentReconnect(currentReconnect: Int) {
self.currentReconnectAttempt = currentReconnect
}
public override func disconnect() {
setTestStatus(.disconnected)
}

View File

@ -487,7 +487,7 @@ class TestEngine: SocketEngineSpec {
private(set) var ws: WebSocket? = nil
private(set) var version = SocketIOVersion.three
internal var onConnect: (() -> ())?
fileprivate var onConnect: (() -> ())?
required init(client: SocketEngineClient, url: URL, options: [String: Any]?) {
self.client = client