From c6085fb111475183388f48233c516e441d249835 Mon Sep 17 00:00:00 2001 From: Andy Uhnak Date: Fri, 15 Jul 2022 15:34:57 +0100 Subject: [PATCH 1/3] Resolve warnings --- MatrixSDK.xcodeproj/project.pbxproj | 14 +++++-- MatrixSDK/Contrib/Swift/MXRestClient.swift | 35 ----------------- MatrixSDK/Contrib/Swift/MXSession.swift | 4 +- MatrixSDK/Data/MXRoom.h | 4 ++ MatrixSDK/Data/MXRoomAccountData.h | 4 ++ MatrixSDK/JSONModels/MXEvent.h | 5 +++ MatrixSDK/JSONModels/MXJSONModels.h | 5 +++ MatrixSDK/MXRestClient.h | 4 +- MatrixSDK/MatrixSDK.h | 1 + MatrixSDK/Space/MXSpaceFileStore.swift | 14 ++----- MatrixSDK/Utils/MXBugReportRestClient.h | 5 +++ MatrixSDK/Utils/MXTools.h | 4 ++ MatrixSDK/Utils/MXWarnings.h | 39 +++++++++++++++++++ MatrixSDK/VoIP/MXCall.m | 3 ++ MatrixSDKTests/MXAggregatedReactionTests.m | 4 +- MatrixSDKTests/MXCryptoKeyVerificationTests.m | 1 + MatrixSDKTests/MXCryptoSecretStorageTests.m | 7 +++- MatrixSDKTests/MXRestClientTests.m | 1 + MatrixSDKTests/MXRoomStateTests.m | 1 + MatrixSDKTests/MXRoomSummaryTests.m | 3 ++ MatrixSDKTests/MXStoreTests.m | 5 +++ MatrixSDKTests/MXVoIPTests.m | 5 +++ MatrixSDKTests/Mocks/MXMockCallStackCall.m | 4 ++ Podfile | 8 ++++ Podfile.lock | 4 +- 25 files changed, 126 insertions(+), 58 deletions(-) create mode 100644 MatrixSDK/Utils/MXWarnings.h diff --git a/MatrixSDK.xcodeproj/project.pbxproj b/MatrixSDK.xcodeproj/project.pbxproj index 16c2b27d91..abfac02851 100644 --- a/MatrixSDK.xcodeproj/project.pbxproj +++ b/MatrixSDK.xcodeproj/project.pbxproj @@ -309,7 +309,7 @@ 325AF3E324897D9400EF937D /* MXSecretRecoveryResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 325AF3E024897D9400EF937D /* MXSecretRecoveryResult.m */; }; 325AF3E424897D9400EF937D /* MXSecretRecoveryResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 325AF3E024897D9400EF937D /* MXSecretRecoveryResult.m */; }; 325D1C261DFECE0D0070B8BF /* MXCrypto_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 325D1C251DFECE0D0070B8BF /* MXCrypto_Private.h */; }; - 326056851C76FDF2009D44AD /* MXRoomEventTimeline.h in Headers */ = {isa = PBXBuildFile; fileRef = 326056831C76FDF1009D44AD /* MXRoomEventTimeline.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 326056851C76FDF2009D44AD /* MXRoomEventTimeline.h in Headers */ = {isa = PBXBuildFile; fileRef = 326056831C76FDF1009D44AD /* MXRoomEventTimeline.h */; }; 326056861C76FDF2009D44AD /* MXRoomEventTimeline.m in Sources */ = {isa = PBXBuildFile; fileRef = 326056841C76FDF1009D44AD /* MXRoomEventTimeline.m */; }; 32618E7120ED2DF500E1D2EA /* MXFilterJSONModel.h in Headers */ = {isa = PBXBuildFile; fileRef = 32618E6F20ED2DF500E1D2EA /* MXFilterJSONModel.h */; settings = {ATTRIBUTES = (Public, ); }; }; 32618E7220ED2DF500E1D2EA /* MXFilterJSONModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 32618E7020ED2DF500E1D2EA /* MXFilterJSONModel.m */; }; @@ -1200,7 +1200,7 @@ B14EF3402397E90400758AF0 /* MXKeyBackupVersionTrust.h in Headers */ = {isa = PBXBuildFile; fileRef = 328BCB3121947BE200A976D3 /* MXKeyBackupVersionTrust.h */; settings = {ATTRIBUTES = (Public, ); }; }; B14EF3412397E90400758AF0 /* MXOutgoingRoomKeyRequestManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 32FA10BF1FA1C9EE00E54233 /* MXOutgoingRoomKeyRequestManager.h */; }; B14EF3422397E90400758AF0 /* MXPeekingRoomSummary.h in Headers */ = {isa = PBXBuildFile; fileRef = 3293C6FE214BBA4F009B3DDB /* MXPeekingRoomSummary.h */; }; - B14EF3432397E90400758AF0 /* MXRoomEventTimeline.h in Headers */ = {isa = PBXBuildFile; fileRef = 326056831C76FDF1009D44AD /* MXRoomEventTimeline.h */; settings = {ATTRIBUTES = (Public, ); }; }; + B14EF3432397E90400758AF0 /* MXRoomEventTimeline.h in Headers */ = {isa = PBXBuildFile; fileRef = 326056831C76FDF1009D44AD /* MXRoomEventTimeline.h */; }; B14EF3442397E90400758AF0 /* NSArray+MatrixSDK.h in Headers */ = {isa = PBXBuildFile; fileRef = 321CFDEC225264C4004D31DF /* NSArray+MatrixSDK.h */; }; B14EF3452397E90400758AF0 /* MXReplyEventParser.h in Headers */ = {isa = PBXBuildFile; fileRef = B11BD44622CB56790064D8B0 /* MXReplyEventParser.h */; settings = {ATTRIBUTES = (Public, ); }; }; B14EF3462397E90400758AF0 /* MXIncomingSASTransaction.h in Headers */ = {isa = PBXBuildFile; fileRef = 321CFDE822525DED004D31DF /* MXIncomingSASTransaction.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -1542,8 +1542,8 @@ EC383BC02542F1E4002FBBE6 /* MXBackgroundSyncServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC383BBD2542F141002FBBE6 /* MXBackgroundSyncServiceTests.swift */; }; EC51019D26C41981007D6D88 /* MXSyncResponseUnitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC51019C26C41981007D6D88 /* MXSyncResponseUnitTests.swift */; }; EC51019E26C41981007D6D88 /* MXSyncResponseUnitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC51019C26C41981007D6D88 /* MXSyncResponseUnitTests.swift */; }; - EC5C560A2798CEA00014CBE9 /* NSDictionary+MutableDeepCopy.h in Headers */ = {isa = PBXBuildFile; fileRef = EC5C56082798CEA00014CBE9 /* NSDictionary+MutableDeepCopy.h */; settings = {ATTRIBUTES = (Public, ); }; }; - EC5C560B2798CEA00014CBE9 /* NSDictionary+MutableDeepCopy.h in Headers */ = {isa = PBXBuildFile; fileRef = EC5C56082798CEA00014CBE9 /* NSDictionary+MutableDeepCopy.h */; settings = {ATTRIBUTES = (Public, ); }; }; + EC5C560A2798CEA00014CBE9 /* NSDictionary+MutableDeepCopy.h in Headers */ = {isa = PBXBuildFile; fileRef = EC5C56082798CEA00014CBE9 /* NSDictionary+MutableDeepCopy.h */; }; + EC5C560B2798CEA00014CBE9 /* NSDictionary+MutableDeepCopy.h in Headers */ = {isa = PBXBuildFile; fileRef = EC5C56082798CEA00014CBE9 /* NSDictionary+MutableDeepCopy.h */; }; EC5C560C2798CEA00014CBE9 /* NSDictionary+MutableDeepCopy.m in Sources */ = {isa = PBXBuildFile; fileRef = EC5C56092798CEA00014CBE9 /* NSDictionary+MutableDeepCopy.m */; }; EC5C560D2798CEA00014CBE9 /* NSDictionary+MutableDeepCopy.m in Sources */ = {isa = PBXBuildFile; fileRef = EC5C56092798CEA00014CBE9 /* NSDictionary+MutableDeepCopy.m */; }; EC5C562827A36EDB0014CBE9 /* MXInReplyTo.h in Headers */ = {isa = PBXBuildFile; fileRef = EC5C562627A36EDB0014CBE9 /* MXInReplyTo.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -1779,6 +1779,8 @@ ECF29BDF264195320053E6D6 /* MXAssertedIdentityModel.h in Headers */ = {isa = PBXBuildFile; fileRef = ECF29BDD264195320053E6D6 /* MXAssertedIdentityModel.h */; settings = {ATTRIBUTES = (Public, ); }; }; ECF29BE52641953C0053E6D6 /* MXAssertedIdentityModel.m in Sources */ = {isa = PBXBuildFile; fileRef = ECF29BE42641953C0053E6D6 /* MXAssertedIdentityModel.m */; }; ECF29BE62641953C0053E6D6 /* MXAssertedIdentityModel.m in Sources */ = {isa = PBXBuildFile; fileRef = ECF29BE42641953C0053E6D6 /* MXAssertedIdentityModel.m */; }; + ED1AE92A2881AC7500D3432A /* MXWarnings.h in Headers */ = {isa = PBXBuildFile; fileRef = ED1AE9292881AC7100D3432A /* MXWarnings.h */; settings = {ATTRIBUTES = (Public, ); }; }; + ED1AE92B2881AC7500D3432A /* MXWarnings.h in Headers */ = {isa = PBXBuildFile; fileRef = ED1AE9292881AC7100D3432A /* MXWarnings.h */; settings = {ATTRIBUTES = (Public, ); }; }; ED21F68528104DA2002FF83D /* MXMegolmEncryptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED21F68428104DA2002FF83D /* MXMegolmEncryptionTests.swift */; }; ED21F68628104DA2002FF83D /* MXMegolmEncryptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED21F68428104DA2002FF83D /* MXMegolmEncryptionTests.swift */; }; ED2DD114286C450600F06731 /* MXCryptoMachine.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED2DD111286C450600F06731 /* MXCryptoMachine.swift */; }; @@ -2816,6 +2818,7 @@ ECF29BD2264194BB0053E6D6 /* MXCallAssertedIdentityEventContent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXCallAssertedIdentityEventContent.m; sourceTree = ""; }; ECF29BDD264195320053E6D6 /* MXAssertedIdentityModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXAssertedIdentityModel.h; sourceTree = ""; }; ECF29BE42641953C0053E6D6 /* MXAssertedIdentityModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXAssertedIdentityModel.m; sourceTree = ""; }; + ED1AE9292881AC7100D3432A /* MXWarnings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXWarnings.h; sourceTree = ""; }; ED21F68428104DA2002FF83D /* MXMegolmEncryptionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MXMegolmEncryptionTests.swift; sourceTree = ""; }; ED2DD111286C450600F06731 /* MXCryptoMachine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MXCryptoMachine.swift; sourceTree = ""; }; ED2DD112286C450600F06731 /* MXEventDecryptionResult+DecryptedEvent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "MXEventDecryptionResult+DecryptedEvent.swift"; sourceTree = ""; }; @@ -3108,6 +3111,7 @@ B17B2BDA2369FC81009D6650 /* MXUIKitBackgroundTask.h */, B17B2BDB2369FC81009D6650 /* MXUIKitBackgroundTask.m */, EDF1B68F2876CD2C00BBBCEE /* MXTaskQueue.swift */, + ED1AE9292881AC7100D3432A /* MXWarnings.h */, ); path = Utils; sourceTree = ""; @@ -5156,6 +5160,7 @@ 91F0685D2767CA420079F8FA /* MXTaskProfileName.h in Headers */, B1798D0624091A0100308A8F /* MXBase64Tools.h in Headers */, 32133015228AF4EF0070BA9B /* MXRealmAggregationsStore.h in Headers */, + ED1AE92A2881AC7500D3432A /* MXWarnings.h in Headers */, 32CE6FB81A409B1F00317F1E /* MXFileStoreMetaData.h in Headers */, B19A30C82404268600FB6F35 /* MXQRCodeDataBuilder.h in Headers */, 32A31BC820D401FC005916C7 /* MXRoomFilter.h in Headers */, @@ -5503,6 +5508,7 @@ 323F8774255460B5009E9E67 /* MXProfiler.h in Headers */, EC8A53B425B1BC77004E0802 /* MXUserModel.h in Headers */, 32CEEF4423AD2A6C0039BA98 /* MXCrossSigningKey.h in Headers */, + ED1AE92B2881AC7500D3432A /* MXWarnings.h in Headers */, B14EF29E2397E90400758AF0 /* MXMediaScanStoreDelegate.h in Headers */, B14EF29F2397E90400758AF0 /* MXAllowedCertificates.h in Headers */, B14EF2A02397E90400758AF0 /* MXRealmAggregationsMapper.h in Headers */, diff --git a/MatrixSDK/Contrib/Swift/MXRestClient.swift b/MatrixSDK/Contrib/Swift/MXRestClient.swift index 898d5c3ed9..50ebcacc67 100644 --- a/MatrixSDK/Contrib/Swift/MXRestClient.swift +++ b/MatrixSDK/Contrib/Swift/MXRestClient.swift @@ -699,27 +699,6 @@ public extension MXRestClient { return __historyVisibility(ofRoom: roomId, success: currySuccess(transform: MXRoomHistoryVisibility.init, completion), failure: curryFailure(completion)) } - - - - - - - /** - Set the join rule of a room. - - - parameters: - - roomId: the id of the room. - - joinRule: the rule to set. - - completion: A block object called when the operation completes. - - response: Indicates whether the operation was successful. - - - returns: a `MXHTTPOperation` instance. - */ - @nonobjc @discardableResult func setJoinRule(ofRoom roomId: String, joinRule: MXRoomJoinRule, completion: @escaping (_ response: MXResponse) -> Void) -> MXHTTPOperation { - return __setRoomJoinRule(roomId, joinRule: joinRule.identifier, success: currySuccess(completion), failure: curryFailure(completion)) - } - /** Set the join rule of a room. @@ -736,20 +715,6 @@ public extension MXRestClient { return __setRoomJoinRule(joinRule.identifier, forRoomWithId: roomId, allowedParentIds: allowedParentIds, success: currySuccess(completion), failure: curryFailure(completion)) } - /** - Get the join rule of a room. - - - parameters: - - roomId: the id of the room. - - completion: A block object called when the operation completes. - - response: Provides the room join rule on success. - - - returns: a `MXHTTPOperation` instance. - */ - @nonobjc @discardableResult func joinRule(ofRoom roomId: String, completion: @escaping (_ response: MXResponse) -> Void) -> MXHTTPOperation { - return __joinRule(ofRoom: roomId, success: currySuccess(transform: MXRoomJoinRule.init, completion), failure: curryFailure(completion)) - } - /** Get the enhanced join rule of a room. diff --git a/MatrixSDK/Contrib/Swift/MXSession.swift b/MatrixSDK/Contrib/Swift/MXSession.swift index fcd8fc5d3b..0116312e6f 100644 --- a/MatrixSDK/Contrib/Swift/MXSession.swift +++ b/MatrixSDK/Contrib/Swift/MXSession.swift @@ -368,9 +368,9 @@ public extension MXSession { if let types = types { let typeStrings = types.map({ return $0.identifier }) - return __listen(toEventsOfTypes: typeStrings, onEvent: legacyBlock) + return __listen(toEventsOfTypes: typeStrings, onEvent: legacyBlock) as Any } else { - return __listen(toEvents: legacyBlock) + return __listen(toEvents: legacyBlock) as Any } } diff --git a/MatrixSDK/Data/MXRoom.h b/MatrixSDK/Data/MXRoom.h index abc12cde89..e7b31172a9 100644 --- a/MatrixSDK/Data/MXRoom.h +++ b/MatrixSDK/Data/MXRoom.h @@ -47,6 +47,8 @@ @class MXSession; @class MXUsersTrustLevelSummary; +MX_ASSUME_MISSING_NULLABILITY_BEGIN + #pragma mark - Notifications /** @@ -1343,3 +1345,5 @@ Remove a tag applied on an event of the room - (void)membersTrustLevelSummaryWithForceDownload:(BOOL)forceDownload success:(void (^)(MXUsersTrustLevelSummary *usersTrustLevelSummary))success failure:(void (^)(NSError *error))failure; @end + +MX_ASSUME_MISSING_NULLABILITY_END diff --git a/MatrixSDK/Data/MXRoomAccountData.h b/MatrixSDK/Data/MXRoomAccountData.h index 70e970de0e..aeb7f0b977 100644 --- a/MatrixSDK/Data/MXRoomAccountData.h +++ b/MatrixSDK/Data/MXRoomAccountData.h @@ -22,6 +22,8 @@ #import "MXEvent.h" #import "MXVirtualRoomInfo.h" +MX_ASSUME_MISSING_NULLABILITY_BEGIN + /** `MXRoomAccountData` represents private data that the user has defined for a room. */ @@ -80,3 +82,5 @@ - (NSArray *)getTaggedEventsIds:(NSString*)tag; @end + +MX_ASSUME_MISSING_NULLABILITY_END diff --git a/MatrixSDK/JSONModels/MXEvent.h b/MatrixSDK/JSONModels/MXEvent.h index f236c0f84f..675c34d6c1 100644 --- a/MatrixSDK/JSONModels/MXEvent.h +++ b/MatrixSDK/JSONModels/MXEvent.h @@ -19,11 +19,14 @@ #import "MXEventUnsignedData.h" #import "MXEventContentRelatesTo.h" +#import "MXWarnings.h" @class MXEventDecryptionResult; @class MXEncryptedContentFile; @class MXEventContentLocation; +MX_ASSUME_MISSING_NULLABILITY_BEGIN + /** Types of Matrix events @@ -732,3 +735,5 @@ extern NSString *const kMXEventIdentifierKey; - (NSArray*)getEncryptedContentFiles; @end + +MX_ASSUME_MISSING_NULLABILITY_END diff --git a/MatrixSDK/JSONModels/MXJSONModels.h b/MatrixSDK/JSONModels/MXJSONModels.h index 801e69177d..5784d4a213 100644 --- a/MatrixSDK/JSONModels/MXJSONModels.h +++ b/MatrixSDK/JSONModels/MXJSONModels.h @@ -26,6 +26,9 @@ #import "MXWellKnown.h" #import "MXCrossSigningInfo.h" #import "MXEnumConstants.h" +#import "MXWarnings.h" + +MX_ASSUME_MISSING_NULLABILITY_BEGIN @class MXEvent, MXDeviceInfo, MXKey, MXUser; @@ -1510,3 +1513,5 @@ FOUNDATION_EXPORT NSString *const kMXPushRuleScopeStringDevice; @property (nonatomic, nullable) MXRoomVersionCapabilities *roomVersions; @end + +MX_ASSUME_MISSING_NULLABILITY_END diff --git a/MatrixSDK/MXRestClient.h b/MatrixSDK/MXRestClient.h index 3531e6cef7..ac23d09747 100644 --- a/MatrixSDK/MXRestClient.h +++ b/MatrixSDK/MXRestClient.h @@ -1046,7 +1046,7 @@ NS_REFINED_FOR_SWIFT; - (MXHTTPOperation*)setRoomJoinRule:(NSString*)roomId joinRule:(MXRoomJoinRule)joinRule success:(void (^)(void))success - failure:(void (^)(NSError *error))failure NS_REFINED_FOR_SWIFT __deprecated_msg("Use [setRoomJoinRule:forRoomWithId:allowedParentIds:success:failure:] instead"); + failure:(void (^)(NSError *error))failure __deprecated_msg("Use [setRoomJoinRule:forRoomWithId:allowedParentIds:success:failure:] instead"); /** Set the join rule of a room. @@ -1078,7 +1078,7 @@ NS_REFINED_FOR_SWIFT; */ - (MXHTTPOperation*)joinRuleOfRoom:(NSString*)roomId success:(void (^)(MXRoomJoinRule joinRule))success - failure:(void (^)(NSError *error))failure NS_REFINED_FOR_SWIFT __deprecated_msg("Use [joinRuleOfRoomWithId:success:failure:] instead"); + failure:(void (^)(NSError *error))failure __deprecated_msg("Use [joinRuleOfRoomWithId:success:failure:] instead"); /** Get the enhanced join rule of a room. diff --git a/MatrixSDK/MatrixSDK.h b/MatrixSDK/MatrixSDK.h index fe2278571f..d9a130bb09 100644 --- a/MatrixSDK/MatrixSDK.h +++ b/MatrixSDK/MatrixSDK.h @@ -26,6 +26,7 @@ FOUNDATION_EXPORT NSString *MatrixSDKVersion; #import "MXRestClient.h" #import "MXSession.h" #import "MXError.h" +#import "MXWarnings.h" #import "MXStore.h" #import "MXNoStore.h" diff --git a/MatrixSDK/Space/MXSpaceFileStore.swift b/MatrixSDK/Space/MXSpaceFileStore.swift index e7bfdf4822..b936371820 100644 --- a/MatrixSDK/Space/MXSpaceFileStore.swift +++ b/MatrixSDK/Space/MXSpaceFileStore.swift @@ -78,18 +78,12 @@ class MXSpaceFileStore: MXSpaceStore { let fileUrl = storeUrl.appendingPathComponent(Constants.fileStoreGraphFile) - do { - guard let graph = try? NSKeyedUnarchiver.unarchiveObject(withFile: fileUrl.path) as? MXSpaceGraphData else { - MXLog.warning("[MXSpaceStore] loadSpaceGraphData: found no archived graph") - return nil - } - - return graph - } catch { - MXLog.warning("[MXSpaceStore] loadSpaceGraphData: failed with error: \(error)") + guard let graph = NSKeyedUnarchiver.unarchiveObject(withFile: fileUrl.path) as? MXSpaceGraphData else { + MXLog.warning("[MXSpaceStore] loadSpaceGraphData: found no archived graph") + return nil } - return nil + return graph } // MARK - Private diff --git a/MatrixSDK/Utils/MXBugReportRestClient.h b/MatrixSDK/Utils/MXBugReportRestClient.h index 0e0e294baf..50da58158c 100644 --- a/MatrixSDK/Utils/MXBugReportRestClient.h +++ b/MatrixSDK/Utils/MXBugReportRestClient.h @@ -15,6 +15,9 @@ */ #import +#import "MXWarnings.h" + +MX_ASSUME_MISSING_NULLABILITY_BEGIN /** Call states. @@ -123,3 +126,5 @@ typedef enum : NSUInteger @property (nonatomic) NSDictionary *others; @end + +MX_ASSUME_MISSING_NULLABILITY_END diff --git a/MatrixSDK/Utils/MXTools.h b/MatrixSDK/Utils/MXTools.h index d00ec96f5a..a1551e4aca 100644 --- a/MatrixSDK/Utils/MXTools.h +++ b/MatrixSDK/Utils/MXTools.h @@ -31,6 +31,8 @@ #import "MXCallSessionDescription.h" #import "MXCallRejectReplacementEventContent.h" +MX_ASSUME_MISSING_NULLABILITY_BEGIN + @interface MXTools : NSObject + (MXEventTypeString)eventTypeString:(MXEventType)eventType; @@ -354,3 +356,5 @@ FOUNDATION_EXPORT NSString *const kMXToolsRegexStringForMatrixGroupIdentifier; + (BOOL)isRunningUnitTests; @end + +MX_ASSUME_MISSING_NULLABILITY_END diff --git a/MatrixSDK/Utils/MXWarnings.h b/MatrixSDK/Utils/MXWarnings.h new file mode 100644 index 0000000000..1e44c1f12a --- /dev/null +++ b/MatrixSDK/Utils/MXWarnings.h @@ -0,0 +1,39 @@ +// +// Copyright 2022 The Matrix.org Foundation C.I.C +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef MXWarnings_h +#define MXWarnings_h + +/** + Mark the beginning of code chunk that will ignore nullability warnings + (counterpart to `NS_ASSUME_NONNULL_BEGIN`) + */ +#ifndef MX_ASSUME_MISSING_NULLABILITY_BEGIN +#define MX_ASSUME_MISSING_NULLABILITY_BEGIN \ +_Pragma("clang diagnostic push")\ +_Pragma("clang diagnostic ignored \"-Wnullability-completeness\"") +#endif + +/** + Mark the end of code chunk that will ignore nullability warnings + (counterpart to `NS_ASSUME_NONNULL_END`) + */ +#ifndef MX_ASSUME_MISSING_NULLABILITY_END +#define MX_ASSUME_MISSING_NULLABILITY_END \ +_Pragma("clang diagnostic pop") +#endif + +#endif /* MXWarnings_h */ diff --git a/MatrixSDK/VoIP/MXCall.m b/MatrixSDK/VoIP/MXCall.m index b5d238e441..f1d946a675 100644 --- a/MatrixSDK/VoIP/MXCall.m +++ b/MatrixSDK/VoIP/MXCall.m @@ -1635,6 +1635,9 @@ - (void)terminateWithReason:(MXEvent *)event case MXCallHangupReasonInviteTimeout: _endReason = MXCallEndReasonMissed; break; + case MXCallHangupReasonUserBusy: + _endReason = MXCallEndReasonBusy; + break; } break; } diff --git a/MatrixSDKTests/MXAggregatedReactionTests.m b/MatrixSDKTests/MXAggregatedReactionTests.m index 8d955f81e9..5b281ef9b9 100644 --- a/MatrixSDKTests/MXAggregatedReactionTests.m +++ b/MatrixSDKTests/MXAggregatedReactionTests.m @@ -649,12 +649,12 @@ - (void)checkGappySyncScenarionReactions:(MXAggregatedReactions*)reactions XCTAssertEqual(reactionCount.count, 1); if ([reactionCount.reaction isEqualToString: @"👍"]) { - #warning Not implemented yet - https://github.com/vector-im/riot-ios/issues/2452 + // TODO: Not implemented yet - https://github.com/vector-im/riot-ios/issues/2452 // XCTAssertTrue(reactionCount.myUserHasReacted, @"We must know reaction made by our user"); } else if ([reactionCount.reaction isEqualToString: @"🙂"]) { - #warning Not implemented yet - https://github.com/vector-im/riot-ios/issues/2452 + // TODO: Not implemented yet - https://github.com/vector-im/riot-ios/issues/2452 // XCTAssertFalse(reactionCount.myUserHasReacted); } else diff --git a/MatrixSDKTests/MXCryptoKeyVerificationTests.m b/MatrixSDKTests/MXCryptoKeyVerificationTests.m index b0dae66bd2..c2325ad3d0 100644 --- a/MatrixSDKTests/MXCryptoKeyVerificationTests.m +++ b/MatrixSDKTests/MXCryptoKeyVerificationTests.m @@ -29,6 +29,7 @@ // Do not bother with retain cycles warnings in tests #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-retain-cycles" +#pragma clang diagnostic ignored "-Wdeprecated" @interface MXKeyVerificationManager (Testing) diff --git a/MatrixSDKTests/MXCryptoSecretStorageTests.m b/MatrixSDKTests/MXCryptoSecretStorageTests.m index 890b651f52..3d1901d8ea 100644 --- a/MatrixSDKTests/MXCryptoSecretStorageTests.m +++ b/MatrixSDKTests/MXCryptoSecretStorageTests.m @@ -23,6 +23,9 @@ #import "MatrixSDKTestsData.h" #import "MatrixSDKTestsE2EData.h" +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-retain-cycles" +#pragma clang diagnostic ignored "-Wdeprecated" // Secret for the qkEmh7mHZBySbXqroxiz7fM18fJuXnnt SSSS key NSString *jsSDKDataPassphrase = @"ILoveMatrix&Riot"; @@ -273,7 +276,7 @@ - (void)testSecretStorageKeyDeletion [matrixSDKTestsE2EData doE2ETestWithAliceInARoom:self readyToTest:^(MXSession *aliceSession, NSString *roomId, XCTestExpectation *expectation) { // - Create a new secret storage key - MXSecretStorage *secretStorage = aliceSession.crypto.secretStorage; + __weak MXSecretStorage *secretStorage = aliceSession.crypto.secretStorage; [secretStorage createKeyWithKeyId:nil keyName:nil passphrase:nil success:^(MXSecretStorageKeyCreationInfo * _Nonnull keyCreationInfo) { // - Set it as default @@ -605,3 +608,5 @@ - (void)testDeleteSecret } @end + +#pragma clang diagnostic pop diff --git a/MatrixSDKTests/MXRestClientTests.m b/MatrixSDKTests/MXRestClientTests.m index a3111d7dd8..d9961314bf 100644 --- a/MatrixSDKTests/MXRestClientTests.m +++ b/MatrixSDKTests/MXRestClientTests.m @@ -28,6 +28,7 @@ // Do not bother with retain cycles warnings in tests #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-retain-cycles" +#pragma clang diagnostic ignored "-Wdeprecated" @interface MXRestClientTests : XCTestCase diff --git a/MatrixSDKTests/MXRoomStateTests.m b/MatrixSDKTests/MXRoomStateTests.m index 82bf535da4..e4cc4d95d3 100644 --- a/MatrixSDKTests/MXRoomStateTests.m +++ b/MatrixSDKTests/MXRoomStateTests.m @@ -26,6 +26,7 @@ // Do not bother with retain cycles warnings in tests #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-retain-cycles" +#pragma clang diagnostic ignored "-Wdeprecated" @interface MXRoomStateTests : XCTestCase { diff --git a/MatrixSDKTests/MXRoomSummaryTests.m b/MatrixSDKTests/MXRoomSummaryTests.m index 395ed09a9b..bc60ad6f71 100644 --- a/MatrixSDKTests/MXRoomSummaryTests.m +++ b/MatrixSDKTests/MXRoomSummaryTests.m @@ -1173,7 +1173,10 @@ - (void)testDoNotStoreDecryptedData [store openWithCredentials:aliceRestClient.credentials onComplete:^{ // A hack to directly read the file built by MXFileStore + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wundeclared-selector" NSString *roomSummaryFile = [store performSelector:@selector(summaryFileForRoom:forBackup:) withObject:roomId withObject:NSNull.null]; + #pragma clang diagnostic pop XCTAssert(roomSummaryFile.length); XCTAssertGreaterThan(roomSummaryFile.length, 0); [store close]; diff --git a/MatrixSDKTests/MXStoreTests.m b/MatrixSDKTests/MXStoreTests.m index e1d9a15535..58db85b98f 100644 --- a/MatrixSDKTests/MXStoreTests.m +++ b/MatrixSDKTests/MXStoreTests.m @@ -783,6 +783,11 @@ - (void)checkLastMessageEventTypesAllowList:(MXRoom*)room }]; } +- (void)checkLastMessageIgnoreProfileChange:(MXRoom *)room +{ + // Not implemented +} + - (void)checkPaginateWhenJoiningAgainAfterLeft:(MXRoom*)room { [matrixSDKTestsData doMXRestClientTestWithAlice:nil readyToTest:^(MXRestClient *aliceRestClient, XCTestExpectation *expectation2) { diff --git a/MatrixSDKTests/MXVoIPTests.m b/MatrixSDKTests/MXVoIPTests.m index 5ce95dd431..bda0e86394 100644 --- a/MatrixSDKTests/MXVoIPTests.m +++ b/MatrixSDKTests/MXVoIPTests.m @@ -22,6 +22,9 @@ #import "MXMockCallStack.h" #import "MXMockCallStackCall.h" +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnonnull" + @interface MXVoIPTests : XCTestCase { MatrixSDKTestsData *matrixSDKTestsData; @@ -136,3 +139,5 @@ - (void)testNoVoIPStackOnCallInvite @end + +#pragma clang diagnostic pop diff --git a/MatrixSDKTests/Mocks/MXMockCallStackCall.m b/MatrixSDKTests/Mocks/MXMockCallStackCall.m index 18266edb9a..b17fbd7517 100644 --- a/MatrixSDKTests/Mocks/MXMockCallStackCall.m +++ b/MatrixSDKTests/Mocks/MXMockCallStackCall.m @@ -100,6 +100,10 @@ - (void)hold:(BOOL)hold success:(nonnull void (^)(NSString * _Nonnull))success f }); } +- (BOOL)sendDTMF:(NSString * _Nonnull)tones { + return YES; +} + - (BOOL)sendDTMF:(NSString * _Nonnull)tones duration:(NSUInteger)duration interToneGap:(NSUInteger)interToneGap { return YES; diff --git a/Podfile b/Podfile index b15f2f71e5..41374eff39 100644 --- a/Podfile +++ b/Podfile @@ -37,3 +37,11 @@ abstract_target 'MatrixSDK' do end end end + +post_install do |installer| + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0' + end + end +end diff --git a/Podfile.lock b/Podfile.lock index 46611ac76a..c5e5f7f341 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -71,6 +71,6 @@ SPEC CHECKSUMS: Realm: 9ca328bd7e700cc19703799785e37f77d1a130f2 SwiftyBeaver: 84069991dd5dca07d7069100985badaca7f0ce82 -PODFILE CHECKSUM: 4b4477c42c0e441efd87a432813467987299753c +PODFILE CHECKSUM: 8a21d32ad6a381e80ea32b6104daee39323c306c -COCOAPODS: 1.11.2 +COCOAPODS: 1.11.3 From 07bc82fa6608119c8218cf34e8fe57e6d1c589fc Mon Sep 17 00:00:00 2001 From: Andy Uhnak Date: Fri, 15 Jul 2022 16:11:07 +0100 Subject: [PATCH 2/3] Changelog --- changelog.d/pr-1527.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/pr-1527.misc diff --git a/changelog.d/pr-1527.misc b/changelog.d/pr-1527.misc new file mode 100644 index 0000000000..697bdeabf1 --- /dev/null +++ b/changelog.d/pr-1527.misc @@ -0,0 +1 @@ +Reduce project warnings From 1a3412b432f5db2bb41f05c9105da7c05edd89f5 Mon Sep 17 00:00:00 2001 From: Andy Uhnak Date: Mon, 18 Jul 2022 09:24:49 +0100 Subject: [PATCH 3/3] Add manual warnings to files that suppress nullability warnings --- MatrixSDK/Data/MXRoom.m | 2 ++ MatrixSDK/Data/MXRoomAccountData.m | 2 ++ MatrixSDK/JSONModels/MXEvent.m | 2 ++ MatrixSDK/JSONModels/MXJSONModels.m | 2 ++ MatrixSDK/Utils/MXBugReportRestClient.m | 2 ++ MatrixSDK/Utils/MXTools.m | 2 ++ 6 files changed, 12 insertions(+) diff --git a/MatrixSDK/Data/MXRoom.m b/MatrixSDK/Data/MXRoom.m index d12e8e97af..fa8ab83c76 100644 --- a/MatrixSDK/Data/MXRoom.m +++ b/MatrixSDK/Data/MXRoom.m @@ -46,6 +46,8 @@ NSInteger const kMXRoomAlreadyJoinedErrorCode = 9001; NSInteger const kMXRoomInvalidInviteSenderErrorCode = 9002; +#warning File has not been annotated with nullability, see MX_ASSUME_MISSING_NULLABILITY_BEGIN + @interface MXRoom () { /** diff --git a/MatrixSDK/Data/MXRoomAccountData.m b/MatrixSDK/Data/MXRoomAccountData.m index a44c514b93..da4a4c351e 100644 --- a/MatrixSDK/Data/MXRoomAccountData.m +++ b/MatrixSDK/Data/MXRoomAccountData.m @@ -19,6 +19,8 @@ #import "MXEvent.h" #import "MXRoomCreateContent.h" +#warning File has not been annotated with nullability, see MX_ASSUME_MISSING_NULLABILITY_BEGIN + @interface MXRoomAccountData () @property (nonatomic, readwrite) MXVirtualRoomInfo *virtualRoomInfo; diff --git a/MatrixSDK/JSONModels/MXEvent.m b/MatrixSDK/JSONModels/MXEvent.m index 5621dd79ee..c1fcd18faa 100644 --- a/MatrixSDK/JSONModels/MXEvent.m +++ b/MatrixSDK/JSONModels/MXEvent.m @@ -24,6 +24,8 @@ #import "MXEventReferenceChunk.h" #import "MXEventContentLocation.h" +#warning File has not been annotated with nullability, see MX_ASSUME_MISSING_NULLABILITY_BEGIN + #pragma mark - Constants definitions NSString *const kMXEventTypeStringRoomName = @"m.room.name"; diff --git a/MatrixSDK/JSONModels/MXJSONModels.m b/MatrixSDK/JSONModels/MXJSONModels.m index 1a4ac0e3f0..639ff6b0d2 100644 --- a/MatrixSDK/JSONModels/MXJSONModels.m +++ b/MatrixSDK/JSONModels/MXJSONModels.m @@ -32,6 +32,8 @@ #pragma mark - Implementation +#warning File has not been annotated with nullability, see MX_ASSUME_MISSING_NULLABILITY_BEGIN + @implementation MXPublicRoom + (id)modelFromJSON:(NSDictionary *)JSONDictionary diff --git a/MatrixSDK/Utils/MXBugReportRestClient.m b/MatrixSDK/Utils/MXBugReportRestClient.m index 51c6e4c5b3..7e09f9c0a3 100644 --- a/MatrixSDK/Utils/MXBugReportRestClient.m +++ b/MatrixSDK/Utils/MXBugReportRestClient.m @@ -37,6 +37,8 @@ #import #endif +#warning File has not been annotated with nullability, see MX_ASSUME_MISSING_NULLABILITY_BEGIN + @interface MXBugReportRestClient () { // The bug report API server URL. diff --git a/MatrixSDK/Utils/MXTools.m b/MatrixSDK/Utils/MXTools.m index 633be962c3..e17e7134cb 100644 --- a/MatrixSDK/Utils/MXTools.m +++ b/MatrixSDK/Utils/MXTools.m @@ -27,6 +27,8 @@ #import #endif +#warning File has not been annotated with nullability, see MX_ASSUME_MISSING_NULLABILITY_BEGIN + #pragma mark - Constant definition NSString *const kMXToolsRegexStringForEmailAddress = @"[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}";