diff --git a/.circleci/config.yml b/.circleci/config.yml index e4eb360b..a350e304 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -79,9 +79,6 @@ jobs: - run: | xcodebuild clean -workspace ParseLiveQuery.xcworkspace -scheme LiveQueryDemo | xcpretty -c; xcodebuild build -workspace ParseLiveQuery.xcworkspace -scheme LiveQueryDemo -configuration Debug | xcpretty -c; - - run: | - xcodebuild clean -workspace ParseLiveQuery.xcworkspace -scheme LiveQueryDemo-ObjC | xcpretty -c; - xcodebuild build -workspace ParseLiveQuery.xcworkspace -scheme LiveQueryDemo-ObjC -configuration Debug | xcpretty -c; carthage: <<: *defaults steps: @@ -89,7 +86,7 @@ jobs: - restore_cache: *cache-pull - run: *prepare - save_cache: *cache-push - - run: carthage build --no-skip-current --platform macos,ios + - run: carthage build --no-skip-current --platform macos,ios,tvos,watchos workflows: version: 2 diff --git a/.travis.yml b/.travis.yml index e604b90a..b4ecb1ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ jobs: deploy: provider: script skip_cleanup: true - script: travis_wait bundle exec pod trunk push ParseLiveQuery.podspec --allow-warnings + script: bundle exec pod trunk push ParseLiveQuery.podspec --allow-warnings on: tags: true all_branches: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 791ee72d..5b5363e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,15 @@ ### Master -[Full Changelog](https://github.com/parse-community/ParseLiveQuery-iOS-OSX/compare/2.7.3...master) +[Full Changelog](https://github.com/parse-community/ParseLiveQuery-iOS-OSX/compare/2.8.0...master) + +### 2.8.0 + +[Full Changelog](https://github.com/parse-community/ParseLiveQuery-iOS-OSX/compare/2.7.3...2.8.0) + +- Bump Starscream dependency to >= 4.0.4 ([#236](https://github.com/parse-community/ParseLiveQuery-iOS-OSX/pull/236)), thanks to [Corey Baker](https://github.com/cbaker6). +- Bump Parse SDK to v.1.19.1 ([#236](https://github.com/parse-community/ParseLiveQuery-iOS-OSX/pull/236)), thanks to [Corey Baker](https://github.com/cbaker6). +- Minimum support due to Xcode 12 and dependencies (iOS 9) ([#236](https://github.com/parse-community/ParseLiveQuery-iOS-OSX/pull/236)), thanks to [Corey Baker](https://github.com/cbaker6). ### 2.7.3 diff --git a/Cartfile b/Cartfile index 62665176..4a573c7e 100644 --- a/Cartfile +++ b/Cartfile @@ -1,3 +1,3 @@ github "BoltsFramework/Bolts-Swift" >= 1.5.0 github "ParsePlatform/Parse-SDK-iOS-OSX" >= 1.19.1 -github "daltoniam/Starscream" == 3.1.1 +github "daltoniam/Starscream" >= 4.0.4 diff --git a/Cartfile.resolved b/Cartfile.resolved index 53bf59e0..f1caa86f 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,5 +1,5 @@ github "BoltsFramework/Bolts-ObjC" "1.9.1" github "BoltsFramework/Bolts-Swift" "1.5.0" github "ParsePlatform/Parse-SDK-iOS-OSX" "1.19.1" -github "daltoniam/Starscream" "3.1.1" +github "daltoniam/Starscream" "4.0.4" github "facebook/facebook-objc-sdk" "v6.5.2" diff --git a/Carthage/Checkouts/Starscream b/Carthage/Checkouts/Starscream index e6b65c6d..df8d8204 160000 --- a/Carthage/Checkouts/Starscream +++ b/Carthage/Checkouts/Starscream @@ -1 +1 @@ -Subproject commit e6b65c6d9077ea48b4a7bdda8994a1d3c6969c8d +Subproject commit df8d82047f6654d8e4b655d1b1525c64e1059d21 diff --git a/ParseLiveQuery.podspec b/ParseLiveQuery.podspec index 9fbd4cf3..3c9cc511 100644 --- a/ParseLiveQuery.podspec +++ b/ParseLiveQuery.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'ParseLiveQuery' - s.version = '2.7.3' + s.version = '2.8.0' s.license = { :type => 'BSD' } s.summary = 'Allows for subscriptions to queries in conjunction with parse-server.' s.homepage = 'http://parseplatform.org' @@ -15,7 +15,7 @@ Pod::Spec.new do |s| s.swift_version = '5.0' s.cocoapods_version = '>= 1.4' - s.ios.deployment_target = '8.0' + s.ios.deployment_target = '9.0' s.tvos.deployment_target = '10.0' s.watchos.deployment_target = '2.0' s.osx.deployment_target = '10.10' @@ -25,6 +25,6 @@ Pod::Spec.new do |s| s.dependency 'Parse', '~> 1.19.0' s.dependency 'Bolts-Swift', '~> 1.5.0' - s.dependency 'Starscream', '3.1.0' + s.dependency 'Starscream', '~> 4.0.4' end diff --git a/Sources/ParseLiveQuery-tvOS/Info.plist b/Sources/ParseLiveQuery-tvOS/Info.plist index 9bcb2444..c0701c6d 100644 --- a/Sources/ParseLiveQuery-tvOS/Info.plist +++ b/Sources/ParseLiveQuery-tvOS/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType $(PRODUCT_BUNDLE_PACKAGE_TYPE) CFBundleShortVersionString - 1.0 + $(MARKETING_VERSION) CFBundleVersion $(CURRENT_PROJECT_VERSION) diff --git a/Sources/ParseLiveQuery-watchOS/Info.plist b/Sources/ParseLiveQuery-watchOS/Info.plist index 9bcb2444..c0701c6d 100644 --- a/Sources/ParseLiveQuery-watchOS/Info.plist +++ b/Sources/ParseLiveQuery-watchOS/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType $(PRODUCT_BUNDLE_PACKAGE_TYPE) CFBundleShortVersionString - 1.0 + $(MARKETING_VERSION) CFBundleVersion $(CURRENT_PROJECT_VERSION) diff --git a/Sources/ParseLiveQuery.xcodeproj/project.pbxproj b/Sources/ParseLiveQuery.xcodeproj/project.pbxproj index 060266a3..cbf21b25 100644 --- a/Sources/ParseLiveQuery.xcodeproj/project.pbxproj +++ b/Sources/ParseLiveQuery.xcodeproj/project.pbxproj @@ -1064,6 +1064,7 @@ INFOPLIST_FILE = "ParseLiveQuery-watchOS/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MARKETING_VERSION = 2.8.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.parse.livequery.watchos.ParseLiveQuery-watchOS"; @@ -1111,6 +1112,7 @@ INFOPLIST_FILE = "ParseLiveQuery-watchOS/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MARKETING_VERSION = 2.8.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.parse.livequery.watchos.ParseLiveQuery-watchOS"; @@ -1161,6 +1163,7 @@ INFOPLIST_FILE = "ParseLiveQuery-tvOS/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MARKETING_VERSION = 2.8.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.parse.livequery.tvos.ParseLiveQuery-tvOS"; @@ -1207,6 +1210,7 @@ INFOPLIST_FILE = "ParseLiveQuery-tvOS/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MARKETING_VERSION = 2.8.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.parse.livequery.tvos.ParseLiveQuery-tvOS"; @@ -1252,7 +1256,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MACOSX_DEPLOYMENT_TARGET = 10.12; ONLY_ACTIVE_ARCH = YES; SWIFT_OBJC_BRIDGING_HEADER = ""; @@ -1289,7 +1293,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MACOSX_DEPLOYMENT_TARGET = 10.12; SWIFT_OBJC_BRIDGING_HEADER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; @@ -1314,7 +1318,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.10; - MARKETING_VERSION = 2.7.3; + MARKETING_VERSION = 2.8.0; PRODUCT_BUNDLE_IDENTIFIER = com.parse.livequery.osx; PRODUCT_NAME = ParseLiveQuery; SDKROOT = macosx; @@ -1341,7 +1345,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.10; - MARKETING_VERSION = 2.7.3; + MARKETING_VERSION = 2.8.0; PRODUCT_BUNDLE_IDENTIFIER = com.parse.livequery.osx; PRODUCT_NAME = ParseLiveQuery; SDKROOT = macosx; @@ -1364,10 +1368,10 @@ FRAMEWORK_VERSION = A; INFOPLIST_FILE = ParseLiveQuery/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; LIBRARY_SEARCH_PATHS = "$(inherited)"; - MARKETING_VERSION = 2.7.3; + MARKETING_VERSION = 2.8.0; PRODUCT_BUNDLE_IDENTIFIER = com.parse.livequery.ios; PRODUCT_NAME = ParseLiveQuery; SDKROOT = iphoneos; @@ -1393,10 +1397,10 @@ FRAMEWORK_VERSION = A; INFOPLIST_FILE = ParseLiveQuery/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; LIBRARY_SEARCH_PATHS = "$(inherited)"; - MARKETING_VERSION = 2.7.3; + MARKETING_VERSION = 2.8.0; PRODUCT_BUNDLE_IDENTIFIER = com.parse.livequery.ios; PRODUCT_NAME = ParseLiveQuery; SDKROOT = iphoneos; diff --git a/Sources/ParseLiveQuery/Client.swift b/Sources/ParseLiveQuery/Client.swift index f24331bf..a61a8175 100644 --- a/Sources/ParseLiveQuery/Client.swift +++ b/Sources/ParseLiveQuery/Client.swift @@ -152,17 +152,18 @@ extension Client { requestId: requestIdGenerator(), handler: handler ) - subscriptions.append(subscriptionRecord) + + self.subscriptions.append(subscriptionRecord) - if let socket = socket, socket.isConnected == true { - _ = sendOperationAsync(.subscribe(requestId: subscriptionRecord.requestId, query: query as! PFQuery, + if socket != nil { + _ = self.sendOperationAsync(.subscribe(requestId: subscriptionRecord.requestId, query: query as! PFQuery, sessionToken: PFUser.current()?.sessionToken)) + } else if !self.userDisconnected { + self.reconnect() + self.subscriptions.removeLast() + return self.subscribe(query, handler: handler) } else { - if !userDisconnected { - reconnect() - } else { - NSLog("ParseLiveQuery: Warning: The client was explicitly disconnected! You must explicitly call .reconnect() in order to process your subscriptions.") - } + NSLog("ParseLiveQuery: Warning: The client was explicitly disconnected! You must explicitly call .reconnect() in order to process your subscriptions.") } return handler @@ -233,7 +234,7 @@ extension Client { guard socket == nil || !isConnecting else { return } socket?.disconnect() socket = { - let socket = WebSocket(url: host) + let socket = WebSocket(request: .init(url: host)) socket.delegate = self socket.callbackQueue = queue socket.connect() diff --git a/Sources/ParseLiveQuery/Internal/ClientPrivate.swift b/Sources/ParseLiveQuery/Internal/ClientPrivate.swift index ad19610d..df3075b1 100644 --- a/Sources/ParseLiveQuery/Internal/ClientPrivate.swift +++ b/Sources/ParseLiveQuery/Internal/ClientPrivate.swift @@ -115,32 +115,33 @@ func == (first: Client.RequestId, second: Client.RequestId) -> Bool { // --------------- extension Client: WebSocketDelegate { - - public func websocketDidReceiveData(socket: WebSocketClient, data: Data) { - if shouldPrintWebSocketLog { NSLog("ParseLiveQuery: Received binary data but we don't handle it...") } - } - - public func websocketDidReceiveMessage(socket: WebSocketClient, text: String) { - handleOperationAsync(text).continueWith { [weak self] task in - if let error = task.error, self?.shouldPrintWebSocketLog == true { - NSLog("ParseLiveQuery: Error processing message: \(error)") + public func didReceive(event: WebSocketEvent, client: WebSocket) { + switch event { + + case .connected(_): + isConnecting = false + let sessionToken = PFUser.current()?.sessionToken ?? "" + _ = self.sendOperationAsync(.connect(applicationId: applicationId, sessionToken: sessionToken, clientKey: clientKey)) + case .disconnected(let reason, let code): + isConnecting = false + if shouldPrintWebSocketLog { NSLog("ParseLiveQuery: WebSocket did disconnect with error: \(reason) code:\(code)") } + + // TODO: Better retry logic, unless `disconnect()` was explicitly called + if !userDisconnected { + reconnect() } - } - } - - public func websocketDidConnect(socket: WebSocketClient) { - isConnecting = false - let sessionToken = PFUser.current()?.sessionToken ?? "" - _ = self.sendOperationAsync(.connect(applicationId: applicationId, sessionToken: sessionToken, clientKey: clientKey)) - } - - public func websocketDidDisconnect(socket: WebSocketClient, error: Error?) { - isConnecting = false - if shouldPrintWebSocketLog { NSLog("ParseLiveQuery: WebSocket did disconnect with error: \(String(describing: error))") } - - // TODO: Better retry logic, unless `disconnect()` was explicitly called - if !userDisconnected { - reconnect() + case .text(let text): + handleOperationAsync(text).continueWith { [weak self] task in + if let error = task.error, self?.shouldPrintWebSocketLog == true { + NSLog("ParseLiveQuery: Error processing message: \(error)") + } + } + case .binary(_): + if shouldPrintWebSocketLog { NSLog("ParseLiveQuery: Received binary data but we don't handle it...") } + case .error(let error): + NSLog("ParseLiveQuery: Error processing message: \(String(describing: error))") + default: + break } } }