Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ECO-4999] Preparing for use with Xcode 16 #1978

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Source/ARTDataEncoder.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ - (ARTDataEncoderOutput *)encode:(id)data {
encoded = [data dataUsingEncoding:NSUTF8StringEncoding];
encoding = [NSString artAddEncoding:@"utf-8" toString:encoding];
}
if (encoded == nil) {
return [[ARTDataEncoderOutput alloc] initWithData:data encoding:nil errorInfo:[ARTErrorInfo createWithCode:0 message:@"must be NSString, NSData, NSArray or NSDictionary."]];
}
ARTStatus *status = [_cipher encrypt:encoded output:&toBase64];
if (status.state != ARTStateOk) {
ARTErrorInfo *errorInfo = status.errorInfo ? status.errorInfo : [ARTErrorInfo createWithCode:0 message:@"encrypt failed"];
Expand Down Expand Up @@ -181,7 +184,7 @@ - (ARTDataEncoderOutput *)decode:(id)data identifier:(NSString *)identifier enco
if (status.state != ARTStateOk) {
errorInfo = status.errorInfo ? status.errorInfo : [ARTErrorInfo createWithCode:ARTErrorInvalidMessageDataOrEncoding message:@"decrypt failed"];
}
} else if ([encoding isEqualToString:@"vcdiff"] && _deltaCodec) {
} else if ([encoding isEqualToString:@"vcdiff"] && _deltaCodec && [data isKindOfClass:[NSData class]]) {
NSError *decodeError;
data = [_deltaCodec applyDelta:data deltaId:identifier baseId:_baseId error:&decodeError];

Expand Down
40 changes: 40 additions & 0 deletions Test/Test Utilities/TestUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1777,6 +1777,44 @@ extension ARTMessage {
}

}
#if hasFeature(RetroactiveAttribute)
extension ARTRealtimeConnectionState : @retroactive CustomStringConvertible {
public var description : String {
return ARTRealtimeConnectionStateToStr(self)
}
}

extension ARTRealtimeConnectionEvent : @retroactive CustomStringConvertible {
public var description : String {
return ARTRealtimeConnectionEventToStr(self)
}
}

extension ARTProtocolMessageAction : @retroactive CustomStringConvertible {
public var description : String {
return ARTProtocolMessageActionToStr(self)
}
}

extension ARTRealtimeChannelState : @retroactive CustomStringConvertible {
public var description : String {
return ARTRealtimeChannelStateToStr(self)
}
}

extension ARTChannelEvent : @retroactive CustomStringConvertible {
public var description : String {
return ARTChannelEventToStr(self)
}
}

extension ARTPresenceAction : @retroactive CustomStringConvertible {
public var description : String {
return ARTPresenceActionToStr(self)
}
}

#else

extension ARTRealtimeConnectionState : CustomStringConvertible {
public var description : String {
Expand Down Expand Up @@ -1814,6 +1852,8 @@ extension ARTPresenceAction : CustomStringConvertible {
}
}

#endif

// MARK: - Custom Nimble Matchers

/// A Nimble matcher that succeeds when two dates are quite the same.
Expand Down
9 changes: 9 additions & 0 deletions Test/Tests/RealtimeClientChannelsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@ import Ably
import Nimble
import XCTest

#if hasFeature(RetroactiveAttribute)
// Swift isn't yet smart enough to do this automatically when bridging Objective-C APIs
extension ARTRealtimeChannels: @retroactive Sequence {
public func makeIterator() -> NSFastEnumerationIterator {
return NSFastEnumerationIterator(iterate())
}
}
#else
// Swift isn't yet smart enough to do this automatically when bridging Objective-C APIs
extension ARTRealtimeChannels: Sequence {
public func makeIterator() -> NSFastEnumerationIterator {
return NSFastEnumerationIterator(iterate())
}
}
#endif

class RealtimeClientChannelsTests: XCTestCase {
// RTS2
Expand Down
8 changes: 8 additions & 0 deletions Test/Tests/RestClientChannelsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@ import Ably
import Nimble
import XCTest

#if hasFeature(RetroactiveAttribute)
// Swift isn't yet smart enough to do this automatically when bridging Objective-C APIs
extension ARTRestChannels: @retroactive Sequence {
public func makeIterator() -> NSFastEnumerationIterator {
return NSFastEnumerationIterator(iterate())
}
}
#else
extension ARTRestChannels: Sequence {
public func makeIterator() -> NSFastEnumerationIterator {
return NSFastEnumerationIterator(iterate())
}
}
#endif

private func beAChannel(named expectedValue: String) -> Nimble.Predicate<ARTChannel> {
return Predicate.define("be a channel with name \"\(expectedValue)\"") { actualExpression, msg -> PredicateResult in
Expand Down
Loading