diff --git a/MatrixSDK.xcodeproj/project.pbxproj b/MatrixSDK.xcodeproj/project.pbxproj index 1743458fdc..3b48760ca2 100644 --- a/MatrixSDK.xcodeproj/project.pbxproj +++ b/MatrixSDK.xcodeproj/project.pbxproj @@ -7882,7 +7882,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.15; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; - OTHER_SWIFT_FLAGS = "-D DEBUG"; + OTHER_SWIFT_FLAGS = "-D DEBUG -D IS_TEST_RUN"; SDKROOT = ""; SWIFT_SWIFT3_OBJC_INFERENCE = On; SWIFT_VERSION = 5.0; diff --git a/MatrixSDK/Aggregations/LocationSharing/Store/Realm/MXBeaconInfoSummaryRealmStore.swift b/MatrixSDK/Aggregations/LocationSharing/Store/Realm/MXBeaconInfoSummaryRealmStore.swift index a67ca8d1d5..5545ad8478 100644 --- a/MatrixSDK/Aggregations/LocationSharing/Store/Realm/MXBeaconInfoSummaryRealmStore.swift +++ b/MatrixSDK/Aggregations/LocationSharing/Store/Realm/MXBeaconInfoSummaryRealmStore.swift @@ -15,7 +15,7 @@ // import Foundation -import Realm +@_implementationOnly import Realm @objcMembers public class MXBeaconInfoSummaryRealmStore: NSObject { @@ -155,10 +155,11 @@ public class MXBeaconInfoSummaryRealmStore: NSObject { private func beaconInfoSummaries(from realmBeaconInfoSummaryResults: RLMResults) -> [MXBeaconInfoSummary] { var summaries: [MXBeaconInfoSummary] = [] - - for realmSummary in realmBeaconInfoSummaryResults { + + var iterator = NSFastEnumerationIterator(realmBeaconInfoSummaryResults) + while let realmSummary = iterator.next() as? MXRealmBeaconInfoSummary { - if let realmBeaconInfoSummary = realmSummary as? MXRealmBeaconInfoSummary, let summary = self.mapper.beaconInfoSummary(from: realmBeaconInfoSummary) { + if let summary = self.mapper.beaconInfoSummary(from: realmSummary) { summaries.append(summary) } } diff --git a/MatrixSDK/Aggregations/LocationSharing/Store/Realm/MXRealmBeacon.swift b/MatrixSDK/Aggregations/LocationSharing/Store/Realm/MXRealmBeacon.swift index df77263b9b..e31e3efd66 100644 --- a/MatrixSDK/Aggregations/LocationSharing/Store/Realm/MXRealmBeacon.swift +++ b/MatrixSDK/Aggregations/LocationSharing/Store/Realm/MXRealmBeacon.swift @@ -15,7 +15,7 @@ // import Foundation -import Realm +@_implementationOnly import Realm class MXRealmBeacon: RLMObject { diff --git a/MatrixSDK/Aggregations/LocationSharing/Store/Realm/MXRealmBeaconInfo.swift b/MatrixSDK/Aggregations/LocationSharing/Store/Realm/MXRealmBeaconInfo.swift index 5774fa584b..0ffc19fcb8 100644 --- a/MatrixSDK/Aggregations/LocationSharing/Store/Realm/MXRealmBeaconInfo.swift +++ b/MatrixSDK/Aggregations/LocationSharing/Store/Realm/MXRealmBeaconInfo.swift @@ -15,7 +15,7 @@ // import Foundation -import Realm +@_implementationOnly import Realm class MXRealmBeaconInfo: RLMObject { diff --git a/MatrixSDK/Aggregations/LocationSharing/Store/Realm/MXRealmBeaconInfoSummary.swift b/MatrixSDK/Aggregations/LocationSharing/Store/Realm/MXRealmBeaconInfoSummary.swift index 74a23a7974..f57a9ede9e 100644 --- a/MatrixSDK/Aggregations/LocationSharing/Store/Realm/MXRealmBeaconInfoSummary.swift +++ b/MatrixSDK/Aggregations/LocationSharing/Store/Realm/MXRealmBeaconInfoSummary.swift @@ -15,7 +15,7 @@ // import Foundation -import Realm +@_implementationOnly import Realm class MXRealmBeaconInfoSummary: RLMObject { diff --git a/MatrixSDK/Background/Crypto/MXBackgroundCryptoV2.swift b/MatrixSDK/Background/Crypto/MXBackgroundCryptoV2.swift index a785fb0168..c3a22a8b0d 100644 --- a/MatrixSDK/Background/Crypto/MXBackgroundCryptoV2.swift +++ b/MatrixSDK/Background/Crypto/MXBackgroundCryptoV2.swift @@ -16,7 +16,7 @@ import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto /// An implementation of `MXBackgroundCrypto` which uses [matrix-rust-sdk](https://github.com/matrix-org/matrix-rust-sdk/tree/main/crates/matrix-sdk-crypto) /// under the hood. diff --git a/MatrixSDK/ContentScan/PKMessageWrapper.swift b/MatrixSDK/ContentScan/PKMessageWrapper.swift index 05aa716b0f..7c31613bd6 100644 --- a/MatrixSDK/ContentScan/PKMessageWrapper.swift +++ b/MatrixSDK/ContentScan/PKMessageWrapper.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto @objc public class PKMessageWrapper: NSObject { private let pkMessage: PkMessage diff --git a/MatrixSDK/Crypto/Algorithms/RoomEvent/MXRoomEventDecryption.swift b/MatrixSDK/Crypto/Algorithms/RoomEvent/MXRoomEventDecryption.swift index 624afbeee4..580913bf8d 100644 --- a/MatrixSDK/Crypto/Algorithms/RoomEvent/MXRoomEventDecryption.swift +++ b/MatrixSDK/Crypto/Algorithms/RoomEvent/MXRoomEventDecryption.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto /// Object responsible for decrypting room events and dealing with undecryptable events protocol MXRoomEventDecrypting: Actor { diff --git a/MatrixSDK/Crypto/Algorithms/RoomEvent/MXRoomEventEncryption.swift b/MatrixSDK/Crypto/Algorithms/RoomEvent/MXRoomEventEncryption.swift index 108fdc45a2..e809a375f4 100644 --- a/MatrixSDK/Crypto/Algorithms/RoomEvent/MXRoomEventEncryption.swift +++ b/MatrixSDK/Crypto/Algorithms/RoomEvent/MXRoomEventEncryption.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto /// Object responsible for encrypting room events and ensuring that room keys are distributed to room members protocol MXRoomEventEncrypting { diff --git a/MatrixSDK/Crypto/CrossSigning/Data/MXCryptoUserIdentityWrapper.swift b/MatrixSDK/Crypto/CrossSigning/Data/MXCryptoUserIdentityWrapper.swift index afa583e537..be5f048823 100644 --- a/MatrixSDK/Crypto/CrossSigning/Data/MXCryptoUserIdentityWrapper.swift +++ b/MatrixSDK/Crypto/CrossSigning/Data/MXCryptoUserIdentityWrapper.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto /// Convenience wrapper around `MatrixSDKCrypto`'s `UserIdentity` /// which can be used to create `MatrixSDK`s `MXCrossSigningInfo` diff --git a/MatrixSDK/Crypto/CryptoMachine/Extensions/EventEncryptionAlgorithm+String.swift b/MatrixSDK/Crypto/CryptoMachine/Extensions/EventEncryptionAlgorithm+String.swift index 21f5919733..f022605b4c 100644 --- a/MatrixSDK/Crypto/CryptoMachine/Extensions/EventEncryptionAlgorithm+String.swift +++ b/MatrixSDK/Crypto/CryptoMachine/Extensions/EventEncryptionAlgorithm+String.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto extension EventEncryptionAlgorithm { enum Error: Swift.Error { diff --git a/MatrixSDK/Crypto/CryptoMachine/Extensions/MXDeviceVerification+LocalTrust.swift b/MatrixSDK/Crypto/CryptoMachine/Extensions/MXDeviceVerification+LocalTrust.swift index e5287ce91d..ffae8e5323 100644 --- a/MatrixSDK/Crypto/CryptoMachine/Extensions/MXDeviceVerification+LocalTrust.swift +++ b/MatrixSDK/Crypto/CryptoMachine/Extensions/MXDeviceVerification+LocalTrust.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto extension MXDeviceVerification { var localTrust: LocalTrust { diff --git a/MatrixSDK/Crypto/CryptoMachine/Extensions/MXEventDecryptionResult+DecryptedEvent.swift b/MatrixSDK/Crypto/CryptoMachine/Extensions/MXEventDecryptionResult+DecryptedEvent.swift index b7d0249262..8f715e6bb6 100644 --- a/MatrixSDK/Crypto/CryptoMachine/Extensions/MXEventDecryptionResult+DecryptedEvent.swift +++ b/MatrixSDK/Crypto/CryptoMachine/Extensions/MXEventDecryptionResult+DecryptedEvent.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto extension MXEventDecryptionResult { enum Error: Swift.Error { diff --git a/MatrixSDK/Crypto/CryptoMachine/Extensions/MXRoomHistoryVisibility+HistoryVisibility.swift b/MatrixSDK/Crypto/CryptoMachine/Extensions/MXRoomHistoryVisibility+HistoryVisibility.swift index a073deddb6..4a92183a32 100644 --- a/MatrixSDK/Crypto/CryptoMachine/Extensions/MXRoomHistoryVisibility+HistoryVisibility.swift +++ b/MatrixSDK/Crypto/CryptoMachine/Extensions/MXRoomHistoryVisibility+HistoryVisibility.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto extension MXRoomHistoryVisibility { var visibility: HistoryVisibility { diff --git a/MatrixSDK/Crypto/CryptoMachine/MXCryptoMachine.swift b/MatrixSDK/Crypto/CryptoMachine/MXCryptoMachine.swift index bbbf4c521d..50972ff155 100644 --- a/MatrixSDK/Crypto/CryptoMachine/MXCryptoMachine.swift +++ b/MatrixSDK/Crypto/CryptoMachine/MXCryptoMachine.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto typealias GetRoomAction = (String) -> MXRoom? diff --git a/MatrixSDK/Crypto/CryptoMachine/MXCryptoProtocols.swift b/MatrixSDK/Crypto/CryptoMachine/MXCryptoProtocols.swift index 384b2aca2b..86547c8480 100644 --- a/MatrixSDK/Crypto/CryptoMachine/MXCryptoProtocols.swift +++ b/MatrixSDK/Crypto/CryptoMachine/MXCryptoProtocols.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto /// A set of protocols defining the functionality in `MatrixSDKCrypto` and separating them into logical units diff --git a/MatrixSDK/Crypto/CryptoMachine/MXCryptoRequests.swift b/MatrixSDK/Crypto/CryptoMachine/MXCryptoRequests.swift index a721e00972..15926b7f72 100644 --- a/MatrixSDK/Crypto/CryptoMachine/MXCryptoRequests.swift +++ b/MatrixSDK/Crypto/CryptoMachine/MXCryptoRequests.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto /// Convenience class to delegate network requests originating in Rust crypto module /// to the native REST API client diff --git a/MatrixSDK/Crypto/CryptoMachine/MXCryptoSDKLogger.swift b/MatrixSDK/Crypto/CryptoMachine/MXCryptoSDKLogger.swift index 9c84ce7d78..57fff5b941 100644 --- a/MatrixSDK/Crypto/CryptoMachine/MXCryptoSDKLogger.swift +++ b/MatrixSDK/Crypto/CryptoMachine/MXCryptoSDKLogger.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto /// Redirects logs originating in `MatrixSDKCrypto` into `MXLog` class MXCryptoSDKLogger: Logger { diff --git a/MatrixSDK/Crypto/Dehydration/DehydrationService.swift b/MatrixSDK/Crypto/Dehydration/DehydrationService.swift index d1a894dac9..35252dfdc0 100644 --- a/MatrixSDK/Crypto/Dehydration/DehydrationService.swift +++ b/MatrixSDK/Crypto/Dehydration/DehydrationService.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto enum DehydrationServiceError: Error { case failedDehydration(Error) diff --git a/MatrixSDK/Crypto/Devices/Data/MXCryptoDeviceWrapper.swift b/MatrixSDK/Crypto/Devices/Data/MXCryptoDeviceWrapper.swift index d85be87c63..28c432f35f 100644 --- a/MatrixSDK/Crypto/Devices/Data/MXCryptoDeviceWrapper.swift +++ b/MatrixSDK/Crypto/Devices/Data/MXCryptoDeviceWrapper.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto /// Convenience wrapper around `MatrixSDKCrypto`'s `Device` /// which can be used to create `MatrixSDK`s `MXDeviceInfo` diff --git a/MatrixSDK/Crypto/KeyBackup/Engine/MXCryptoKeyBackupEngine.swift b/MatrixSDK/Crypto/KeyBackup/Engine/MXCryptoKeyBackupEngine.swift index c7338e8bdc..8d62a63630 100644 --- a/MatrixSDK/Crypto/KeyBackup/Engine/MXCryptoKeyBackupEngine.swift +++ b/MatrixSDK/Crypto/KeyBackup/Engine/MXCryptoKeyBackupEngine.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto class MXCryptoKeyBackupEngine: NSObject, MXKeyBackupEngine { // Batch size chosen arbitrarily, will be moved to CryptoSDK diff --git a/MatrixSDK/Crypto/MXCryptoV2.swift b/MatrixSDK/Crypto/MXCryptoV2.swift index 007260146b..a9a32b545f 100644 --- a/MatrixSDK/Crypto/MXCryptoV2.swift +++ b/MatrixSDK/Crypto/MXCryptoV2.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto /// An implementation of `MXCrypto` which uses [matrix-rust-sdk](https://github.com/matrix-org/matrix-rust-sdk/tree/main/crates/matrix-sdk-crypto) /// under the hood. diff --git a/MatrixSDK/Crypto/SecretStorage/MXCryptoSecretStoreV2.swift b/MatrixSDK/Crypto/SecretStorage/MXCryptoSecretStoreV2.swift index 7e2e9774b4..3fcb7899e7 100644 --- a/MatrixSDK/Crypto/SecretStorage/MXCryptoSecretStoreV2.swift +++ b/MatrixSDK/Crypto/SecretStorage/MXCryptoSecretStoreV2.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto enum MXCryptoError: Error { case secretDoesNotMatch diff --git a/MatrixSDK/Crypto/Verification/MXKeyVerificationManagerV2.swift b/MatrixSDK/Crypto/Verification/MXKeyVerificationManagerV2.swift index 42291c59a5..e68978e205 100644 --- a/MatrixSDK/Crypto/Verification/MXKeyVerificationManagerV2.swift +++ b/MatrixSDK/Crypto/Verification/MXKeyVerificationManagerV2.swift @@ -6,7 +6,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto class MXKeyVerificationManagerV2: NSObject, MXKeyVerificationManager { enum Error: Swift.Error { diff --git a/MatrixSDK/Crypto/Verification/Requests/MXKeyVerificationRequestV2.swift b/MatrixSDK/Crypto/Verification/Requests/MXKeyVerificationRequestV2.swift index 24c701fc8d..9f54c3d5a9 100644 --- a/MatrixSDK/Crypto/Verification/Requests/MXKeyVerificationRequestV2.swift +++ b/MatrixSDK/Crypto/Verification/Requests/MXKeyVerificationRequestV2.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto /// Verification request originating from `MatrixSDKCrypto` class MXKeyVerificationRequestV2: NSObject, MXKeyVerificationRequest { diff --git a/MatrixSDK/Crypto/Verification/Transactions/QRCode/MXQRCodeTransactionV2.swift b/MatrixSDK/Crypto/Verification/Transactions/QRCode/MXQRCodeTransactionV2.swift index 183c75504e..3750802965 100644 --- a/MatrixSDK/Crypto/Verification/Transactions/QRCode/MXQRCodeTransactionV2.swift +++ b/MatrixSDK/Crypto/Verification/Transactions/QRCode/MXQRCodeTransactionV2.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto /// QR transaction originating from `MatrixSDKCrypto` class MXQRCodeTransactionV2: NSObject, MXQRCodeTransaction { diff --git a/MatrixSDK/Crypto/Verification/Transactions/SAS/MXSASTransactionV2.swift b/MatrixSDK/Crypto/Verification/Transactions/SAS/MXSASTransactionV2.swift index a196f87802..3005a19a51 100644 --- a/MatrixSDK/Crypto/Verification/Transactions/SAS/MXSASTransactionV2.swift +++ b/MatrixSDK/Crypto/Verification/Transactions/SAS/MXSASTransactionV2.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto /// SAS transaction originating from `MatrixSDKCrypto` class MXSASTransactionV2: NSObject, MXSASTransaction { diff --git a/MatrixSDK/Utils/Logs/MXAnalyticsDestination.swift b/MatrixSDK/Utils/Logs/MXAnalyticsDestination.swift index e3615dc3ce..601ad5b00e 100644 --- a/MatrixSDK/Utils/Logs/MXAnalyticsDestination.swift +++ b/MatrixSDK/Utils/Logs/MXAnalyticsDestination.swift @@ -6,7 +6,11 @@ // import Foundation +#if IS_TEST_RUN import SwiftyBeaver +#else +@_implementationOnly import SwiftyBeaver +#endif /// SwiftyBeaver log destination that sends errors to analytics tracker class MXAnalyticsDestination: BaseDestination { diff --git a/MatrixSDK/Utils/Logs/MXLog.swift b/MatrixSDK/Utils/Logs/MXLog.swift index 615d1caa8d..5a2fd4f5c2 100644 --- a/MatrixSDK/Utils/Logs/MXLog.swift +++ b/MatrixSDK/Utils/Logs/MXLog.swift @@ -15,7 +15,11 @@ // import Foundation +#if IS_TEST_RUN import SwiftyBeaver +#else +@_implementationOnly import SwiftyBeaver +#endif /// Various MXLog configuration options. Used in conjunction with `MXLog.configure()` @objc public class MXLogConfiguration: NSObject { diff --git a/MatrixSDK/Utils/Realm/RLMSupport.swift b/MatrixSDK/Utils/Realm/RLMSupport.swift index ab3c840ab9..e855317795 100644 --- a/MatrixSDK/Utils/Realm/RLMSupport.swift +++ b/MatrixSDK/Utils/Realm/RLMSupport.swift @@ -16,7 +16,7 @@ // //////////////////////////////////////////////////////////////////////////// -import Realm +@_implementationOnly import Realm extension RLMRealm { /** @@ -24,7 +24,7 @@ extension RLMRealm { - see: `+ [RLMRealm schemaVersionAtURL:encryptionKey:error:]` */ - @nonobjc public class func schemaVersion(at url: URL, usingEncryptionKey key: Data? = nil) throws -> UInt64 { + @nonobjc class func schemaVersion(at url: URL, usingEncryptionKey key: Data? = nil) throws -> UInt64 { var error: NSError? let version = __schemaVersion(at: url, encryptionKey: key, error: &error) guard version != RLMNotVersioned else { throw error! } @@ -38,7 +38,7 @@ extension RLMRealm { - see `- [RLMRealm resolveThreadSafeReference:]` */ - @nonobjc public func resolve(reference: RLMThreadSafeReference) -> Confined? { + @nonobjc func resolve(reference: RLMThreadSafeReference) -> Confined? { return __resolve(reference as! RLMThreadSafeReference) as! Confined? } } @@ -49,7 +49,7 @@ extension RLMObject { - see `+ [RLMObject objectsWithPredicate:]` */ - public class func objects(where predicateFormat: String, _ args: CVarArg...) -> RLMResults { + class func objects(where predicateFormat: String, _ args: CVarArg...) -> RLMResults { return objects(with: NSPredicate(format: predicateFormat, arguments: getVaList(args))) as! RLMResults } @@ -58,7 +58,7 @@ extension RLMObject { - see `+ [RLMObject objectsInRealm:withPredicate:]` */ - public class func objects(in realm: RLMRealm, + class func objects(in realm: RLMRealm, where predicateFormat: String, _ args: CVarArg...) -> RLMResults { return objects(in: realm, with: NSPredicate(format: predicateFormat, arguments: getVaList(args))) as! RLMResults @@ -66,7 +66,7 @@ extension RLMObject { } /// A protocol defining iterator support for RLMArray, RLMSet & RLMResults. -public protocol _RLMCollectionIterator { +protocol _RLMCollectionIterator { /** Returns a `RLMCollectionIterator` that yields successive elements in the collection. This enables support for sequence-style enumeration of `RLMObject` subclasses in Swift. @@ -76,43 +76,44 @@ public protocol _RLMCollectionIterator { extension _RLMCollectionIterator where Self: RLMCollection { /// :nodoc: - public func makeIterator() -> RLMCollectionIterator { + func makeIterator() -> RLMCollectionIterator { return RLMCollectionIterator(self) } } /// :nodoc: -public typealias RLMDictionarySingleEntry = (key: String, value: RLMObject) +typealias RLMDictionarySingleEntry = (key: String, value: RLMObject) /// A protocol defining iterator support for RLMDictionary -public protocol _RLMDictionaryIterator { +protocol _RLMDictionaryIterator { /// :nodoc: func makeIterator() -> RLMDictionaryIterator } extension _RLMDictionaryIterator where Self: RLMCollection { /// :nodoc: - public func makeIterator() -> RLMDictionaryIterator { + func makeIterator() -> RLMDictionaryIterator { return RLMDictionaryIterator(self) } } // Sequence conformance for RLMArray, RLMDictionary, RLMSet and RLMResults is provided by RLMCollection's // `makeIterator()` implementation. -extension RLMArray: Sequence, _RLMCollectionIterator { } -extension RLMDictionary: Sequence, _RLMDictionaryIterator {} -extension RLMSet: Sequence, _RLMCollectionIterator {} -extension RLMResults: Sequence, _RLMCollectionIterator {} +// Disabled since `@_implementationOnly`-importing Realm prevents these extensions. Note that this makes this whole file basically useless. +//extension RLMArray: Sequence, _RLMCollectionIterator { } +//extension RLMDictionary: Sequence, _RLMDictionaryIterator {} +//extension RLMSet: Sequence, _RLMCollectionIterator {} +//extension RLMResults: Sequence, _RLMCollectionIterator {} /** This struct enables sequence-style enumeration for RLMObjects in Swift via `RLMCollection.makeIterator` */ -public struct RLMCollectionIterator: IteratorProtocol { +struct RLMCollectionIterator: IteratorProtocol { private var iteratorBase: NSFastEnumerationIterator internal init(_ collection: RLMCollection) { iteratorBase = NSFastEnumerationIterator(collection) } - public mutating func next() -> RLMObject? { + mutating func next() -> RLMObject? { return iteratorBase.next() as! RLMObject? } } @@ -120,7 +121,7 @@ public struct RLMCollectionIterator: IteratorProtocol { /** This struct enables sequence-style enumeration for RLMDictionary in Swift via `RLMDictionary.makeIterator` */ -public struct RLMDictionaryIterator: IteratorProtocol { +struct RLMDictionaryIterator: IteratorProtocol { private var iteratorBase: NSFastEnumerationIterator private let dictionary: RLMDictionary @@ -129,7 +130,7 @@ public struct RLMDictionaryIterator: IteratorProtocol { iteratorBase = NSFastEnumerationIterator(collection) } - public mutating func next() -> RLMDictionarySingleEntry? { + mutating func next() -> RLMDictionarySingleEntry? { let key = iteratorBase.next() if let key = key { return (key: key as Any, value: dictionary[key as AnyObject]) as? RLMDictionarySingleEntry @@ -146,7 +147,7 @@ extension RLMCollection { /** Returns the index of the first object in the collection matching the predicate. */ - public func indexOfObject(where predicateFormat: String, _ args: CVarArg...) -> UInt { + func indexOfObject(where predicateFormat: String, _ args: CVarArg...) -> UInt { guard let index = indexOfObject?(with: NSPredicate(format: predicateFormat, arguments: getVaList(args))) else { fatalError("This RLMCollection does not support indexOfObject(where:)") } @@ -156,14 +157,14 @@ extension RLMCollection { /** Returns all objects matching the given predicate in the collection. */ - public func objects(where predicateFormat: String, _ args: CVarArg...) -> RLMResults { + func objects(where predicateFormat: String, _ args: CVarArg...) -> RLMResults { return objects(with: NSPredicate(format: predicateFormat, arguments: getVaList(args))) as! RLMResults } } extension RLMCollection { /// Allows for subscript support with RLMDictionary. - public subscript(_ key: String) -> AnyObject? { + subscript(_ key: String) -> AnyObject? { get { (self as! RLMDictionary).object(forKey: key as NSString) } diff --git a/MatrixSDK/Utils/Realm/Realm+MatrixSDK.swift b/MatrixSDK/Utils/Realm/Realm+MatrixSDK.swift index 434aa6782d..45e1f18678 100644 --- a/MatrixSDK/Utils/Realm/Realm+MatrixSDK.swift +++ b/MatrixSDK/Utils/Realm/Realm+MatrixSDK.swift @@ -14,7 +14,7 @@ // limitations under the License. // -import Realm +@_implementationOnly import Realm extension RLMRealm { diff --git a/MatrixSDKTests/Crypto/Algorithms/RoomEvents/MXRoomEventDecryptionUnitTests.swift b/MatrixSDKTests/Crypto/Algorithms/RoomEvents/MXRoomEventDecryptionUnitTests.swift index f2eb25723b..d28626cef2 100644 --- a/MatrixSDKTests/Crypto/Algorithms/RoomEvents/MXRoomEventDecryptionUnitTests.swift +++ b/MatrixSDKTests/Crypto/Algorithms/RoomEvents/MXRoomEventDecryptionUnitTests.swift @@ -17,7 +17,7 @@ import Foundation @testable import MatrixSDK -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto class MXRoomEventDecryptionUnitTests: XCTestCase { class DecryptorStub: CryptoIdentityStub, MXCryptoRoomEventDecrypting { diff --git a/MatrixSDKTests/Crypto/Algorithms/RoomEvents/MXRoomEventEncryptionUnitTests.swift b/MatrixSDKTests/Crypto/Algorithms/RoomEvents/MXRoomEventEncryptionUnitTests.swift index 8dc292a901..5812aa554b 100644 --- a/MatrixSDKTests/Crypto/Algorithms/RoomEvents/MXRoomEventEncryptionUnitTests.swift +++ b/MatrixSDKTests/Crypto/Algorithms/RoomEvents/MXRoomEventEncryptionUnitTests.swift @@ -16,7 +16,7 @@ import Foundation @testable import MatrixSDK -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto class MXRoomEventEncryptionUnitTests: XCTestCase { class StateStub: MXRoomState { diff --git a/MatrixSDKTests/Crypto/CrossSigning/Data/MXCrossSigningInfoUnitTests.swift b/MatrixSDKTests/Crypto/CrossSigning/Data/MXCrossSigningInfoUnitTests.swift index 8d3e1e8fa7..56b1a57561 100644 --- a/MatrixSDKTests/Crypto/CrossSigning/Data/MXCrossSigningInfoUnitTests.swift +++ b/MatrixSDKTests/Crypto/CrossSigning/Data/MXCrossSigningInfoUnitTests.swift @@ -17,7 +17,7 @@ import Foundation import XCTest @testable import MatrixSDK -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto class MXCrossSigningInfoUnitTests: XCTestCase { func makeKey(type: String, user: String) -> MXCrossSigningKey { diff --git a/MatrixSDKTests/Crypto/CrossSigning/MXCrossSigningInfoSourceUnitTests.swift b/MatrixSDKTests/Crypto/CrossSigning/MXCrossSigningInfoSourceUnitTests.swift index fd8ff9966a..3ffab2f397 100644 --- a/MatrixSDKTests/Crypto/CrossSigning/MXCrossSigningInfoSourceUnitTests.swift +++ b/MatrixSDKTests/Crypto/CrossSigning/MXCrossSigningInfoSourceUnitTests.swift @@ -17,7 +17,7 @@ import Foundation import XCTest @testable import MatrixSDK -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto class MXCrossSigningInfoSourceUnitTests: XCTestCase { var cryptoSource: UserIdentitySourceStub! diff --git a/MatrixSDKTests/Crypto/CrossSigning/MXCrossSigningV2UnitTests.swift b/MatrixSDKTests/Crypto/CrossSigning/MXCrossSigningV2UnitTests.swift index ae28eab697..ffe60a26c1 100644 --- a/MatrixSDKTests/Crypto/CrossSigning/MXCrossSigningV2UnitTests.swift +++ b/MatrixSDKTests/Crypto/CrossSigning/MXCrossSigningV2UnitTests.swift @@ -17,7 +17,7 @@ import Foundation import XCTest @testable import MatrixSDK -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto class MXCrossSigningV2UnitTests: XCTestCase { diff --git a/MatrixSDKTests/Crypto/CryptoMachine/DecryptedEvent+Stub.swift b/MatrixSDKTests/Crypto/CryptoMachine/DecryptedEvent+Stub.swift index 81e476d9bf..9c62007cc6 100644 --- a/MatrixSDKTests/Crypto/CryptoMachine/DecryptedEvent+Stub.swift +++ b/MatrixSDKTests/Crypto/CryptoMachine/DecryptedEvent+Stub.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto extension DecryptedEvent { static func stub( diff --git a/MatrixSDKTests/Crypto/CryptoMachine/Device+Stub.swift b/MatrixSDKTests/Crypto/CryptoMachine/Device+Stub.swift index 1f38015198..4ec5877c5d 100644 --- a/MatrixSDKTests/Crypto/CryptoMachine/Device+Stub.swift +++ b/MatrixSDKTests/Crypto/CryptoMachine/Device+Stub.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto extension Device { static func stub( diff --git a/MatrixSDKTests/Crypto/CryptoMachine/Extensions/EventEncryptionAlgorithmUnitTests.swift b/MatrixSDKTests/Crypto/CryptoMachine/Extensions/EventEncryptionAlgorithmUnitTests.swift index 8bcae0ddf4..f26a068c15 100644 --- a/MatrixSDKTests/Crypto/CryptoMachine/Extensions/EventEncryptionAlgorithmUnitTests.swift +++ b/MatrixSDKTests/Crypto/CryptoMachine/Extensions/EventEncryptionAlgorithmUnitTests.swift @@ -16,7 +16,7 @@ import Foundation import XCTest -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto @testable import MatrixSDK class EventEncryptionAlgorithmUnitTests: XCTestCase { diff --git a/MatrixSDKTests/Crypto/CryptoMachine/MXCryptoMachineUnitTests.swift b/MatrixSDKTests/Crypto/CryptoMachine/MXCryptoMachineUnitTests.swift index e466cfbe40..b875369dce 100644 --- a/MatrixSDKTests/Crypto/CryptoMachine/MXCryptoMachineUnitTests.swift +++ b/MatrixSDKTests/Crypto/CryptoMachine/MXCryptoMachineUnitTests.swift @@ -15,7 +15,7 @@ // import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto @testable import MatrixSDK class MXCryptoMachineUnitTests: XCTestCase { diff --git a/MatrixSDKTests/Crypto/CryptoMachine/MXCryptoProtocolStubs.swift b/MatrixSDKTests/Crypto/CryptoMachine/MXCryptoProtocolStubs.swift index 4b95ebf8e6..b93e6a7f2d 100644 --- a/MatrixSDKTests/Crypto/CryptoMachine/MXCryptoProtocolStubs.swift +++ b/MatrixSDKTests/Crypto/CryptoMachine/MXCryptoProtocolStubs.swift @@ -16,7 +16,7 @@ import Foundation @testable import MatrixSDK -@testable import MatrixSDKCrypto +@_implementationOnly @testable import MatrixSDKCrypto class CryptoIdentityStub: MXCryptoIdentity { var userId: String = "Alice" diff --git a/MatrixSDKTests/Crypto/CryptoMachine/MXCryptoRequestsUnitTests.swift b/MatrixSDKTests/Crypto/CryptoMachine/MXCryptoRequestsUnitTests.swift index 16d697fe4a..384d9346d8 100644 --- a/MatrixSDKTests/Crypto/CryptoMachine/MXCryptoRequestsUnitTests.swift +++ b/MatrixSDKTests/Crypto/CryptoMachine/MXCryptoRequestsUnitTests.swift @@ -16,7 +16,7 @@ import Foundation @testable import MatrixSDK -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto class MXCryptoRequestsUnitTests: XCTestCase { func test_canCreateToDeviceRequest() { diff --git a/MatrixSDKTests/Crypto/Devices/Data/MXDeviceInfoUnitTests.swift b/MatrixSDKTests/Crypto/Devices/Data/MXDeviceInfoUnitTests.swift index abdf3ba911..44e0c1a5cd 100644 --- a/MatrixSDKTests/Crypto/Devices/Data/MXDeviceInfoUnitTests.swift +++ b/MatrixSDKTests/Crypto/Devices/Data/MXDeviceInfoUnitTests.swift @@ -17,7 +17,7 @@ import Foundation import XCTest @testable import MatrixSDK -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto class MXDeviceInfoUnitTests: XCTestCase { func test_canCreateInfo_withDevice() { diff --git a/MatrixSDKTests/Crypto/Devices/MXDeviceInfoSourceUnitTests.swift b/MatrixSDKTests/Crypto/Devices/MXDeviceInfoSourceUnitTests.swift index 163ce55228..1a65e652d2 100644 --- a/MatrixSDKTests/Crypto/Devices/MXDeviceInfoSourceUnitTests.swift +++ b/MatrixSDKTests/Crypto/Devices/MXDeviceInfoSourceUnitTests.swift @@ -17,7 +17,7 @@ import Foundation import XCTest @testable import MatrixSDK -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto class MXDeviceInfoSourceUnitTests: XCTestCase { var cryptoSource: DevicesSourceStub! diff --git a/MatrixSDKTests/Crypto/KeyBackup/Engine/MXCryptoKeyBackupEngineUnitTests.swift b/MatrixSDKTests/Crypto/KeyBackup/Engine/MXCryptoKeyBackupEngineUnitTests.swift index 828bb989ce..966a015d75 100644 --- a/MatrixSDKTests/Crypto/KeyBackup/Engine/MXCryptoKeyBackupEngineUnitTests.swift +++ b/MatrixSDKTests/Crypto/KeyBackup/Engine/MXCryptoKeyBackupEngineUnitTests.swift @@ -16,7 +16,7 @@ import Foundation @testable import MatrixSDK -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto class MXCryptoKeyBackupEngineUnitTests: XCTestCase { actor DecryptorSpy: MXRoomEventDecrypting { diff --git a/MatrixSDKTests/Crypto/Trust/MXTrustLevelSourceUnitTests.swift b/MatrixSDKTests/Crypto/Trust/MXTrustLevelSourceUnitTests.swift index dc53091a9f..04e704c52c 100644 --- a/MatrixSDKTests/Crypto/Trust/MXTrustLevelSourceUnitTests.swift +++ b/MatrixSDKTests/Crypto/Trust/MXTrustLevelSourceUnitTests.swift @@ -17,7 +17,7 @@ import Foundation import XCTest @testable import MatrixSDK -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto class MXTrustLevelSourceUnitTests: XCTestCase { var userIdentitySource: UserIdentitySourceStub! diff --git a/MatrixSDKTests/Crypto/Verification/Requests/MXKeyVerificationRequestV2UnitTests.swift b/MatrixSDKTests/Crypto/Verification/Requests/MXKeyVerificationRequestV2UnitTests.swift index 1af4801107..6e8c94a416 100644 --- a/MatrixSDKTests/Crypto/Verification/Requests/MXKeyVerificationRequestV2UnitTests.swift +++ b/MatrixSDKTests/Crypto/Verification/Requests/MXKeyVerificationRequestV2UnitTests.swift @@ -16,7 +16,7 @@ import Foundation import XCTest -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto @testable import MatrixSDK class MXKeyVerificationRequestV2UnitTests: XCTestCase { diff --git a/MatrixSDKTests/Crypto/Verification/Requests/VerificationRequestStub.swift b/MatrixSDKTests/Crypto/Verification/Requests/VerificationRequestStub.swift index 730eaeb6d9..5a48049af1 100644 --- a/MatrixSDKTests/Crypto/Verification/Requests/VerificationRequestStub.swift +++ b/MatrixSDKTests/Crypto/Verification/Requests/VerificationRequestStub.swift @@ -16,7 +16,7 @@ import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto class VerificationRequestStub: VerificationRequestProtocol { diff --git a/MatrixSDKTests/Crypto/Verification/Transactions/QRCode/MXQRCodeTransactionV2UnitTests.swift b/MatrixSDKTests/Crypto/Verification/Transactions/QRCode/MXQRCodeTransactionV2UnitTests.swift index 1ed48469fd..6ae7e0ed2c 100644 --- a/MatrixSDKTests/Crypto/Verification/Transactions/QRCode/MXQRCodeTransactionV2UnitTests.swift +++ b/MatrixSDKTests/Crypto/Verification/Transactions/QRCode/MXQRCodeTransactionV2UnitTests.swift @@ -16,7 +16,7 @@ import Foundation import XCTest -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto @testable import MatrixSDK class MXQRCodeTransactionV2UnitTests: XCTestCase { diff --git a/MatrixSDKTests/Crypto/Verification/Transactions/QRCode/QrCodeStub.swift b/MatrixSDKTests/Crypto/Verification/Transactions/QRCode/QrCodeStub.swift index d263d29eaa..ca013da1d8 100644 --- a/MatrixSDKTests/Crypto/Verification/Transactions/QRCode/QrCodeStub.swift +++ b/MatrixSDKTests/Crypto/Verification/Transactions/QRCode/QrCodeStub.swift @@ -16,7 +16,7 @@ import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto class QrCodeStub: QrCodeProtocol { private let _otherUserId: String diff --git a/MatrixSDKTests/Crypto/Verification/Transactions/SAS/MXSASTransactionV2UnitTests.swift b/MatrixSDKTests/Crypto/Verification/Transactions/SAS/MXSASTransactionV2UnitTests.swift index a88bf42420..9076142b19 100644 --- a/MatrixSDKTests/Crypto/Verification/Transactions/SAS/MXSASTransactionV2UnitTests.swift +++ b/MatrixSDKTests/Crypto/Verification/Transactions/SAS/MXSASTransactionV2UnitTests.swift @@ -16,7 +16,7 @@ import Foundation import XCTest -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto @testable import MatrixSDK class MXSASTransactionV2UnitTests: XCTestCase { diff --git a/MatrixSDKTests/Crypto/Verification/Transactions/SAS/SasStub.swift b/MatrixSDKTests/Crypto/Verification/Transactions/SAS/SasStub.swift index b08a960700..25c20c9022 100644 --- a/MatrixSDKTests/Crypto/Verification/Transactions/SAS/SasStub.swift +++ b/MatrixSDKTests/Crypto/Verification/Transactions/SAS/SasStub.swift @@ -16,7 +16,7 @@ import Foundation -import MatrixSDKCrypto +@_implementationOnly import MatrixSDKCrypto class SasStub: SasProtocol { diff --git a/Podfile b/Podfile index 77ddd65582..4cdb653390 100644 --- a/Podfile +++ b/Podfile @@ -36,7 +36,30 @@ abstract_target 'MatrixSDK' do end end +# from here: https://juejin.cn/post/7621018086649430025 +def patch_afnetworking_private_header(installer) + # 扫描并移除 AFNetworking 对私有 IPv6 头文件的直接引用,兼容新版 Xcode 的模块校验。 + afnetworking_dir = File.join(installer.sandbox.pod_dir('AFNetworking'), 'AFNetworking') + return unless Dir.exist?(afnetworking_dir) + + private_header_import = '#import ' + Dir.glob(File.join(afnetworking_dir, '**', '*.{h,m}')).each do |file_path| + #next unless mcs_file_exists(file_path) + + file_content = File.read(file_path) + next unless file_content.include?(private_header_import) + + original_mode = File.stat(file_path).mode + File.chmod(original_mode | 0o200, file_path) + File.write(file_path, file_content.gsub(private_header_import, '')) + File.chmod(original_mode, file_path) + puts "patched AFNetworking private header import: #{File.basename(file_path)}" + end +end + post_install do |installer| + patch_afnetworking_private_header(installer) + installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0' diff --git a/Podfile.lock b/Podfile.lock index 48f3238e97..840b2616c2 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -63,6 +63,6 @@ SPEC CHECKSUMS: Realm: 9ca328bd7e700cc19703799785e37f77d1a130f2 SwiftyBeaver: 84069991dd5dca07d7069100985badaca7f0ce82 -PODFILE CHECKSUM: 43b5fd9b5489fc93ff6f9121742d30463242345f +PODFILE CHECKSUM: 6ae14a373709e4d335bf93c3aaaff569bed7fce0 COCOAPODS: 1.16.2 diff --git a/changelog.d/sdk-1497.build b/changelog.d/sdk-1497.build new file mode 100644 index 0000000000..2f7fc863ad --- /dev/null +++ b/changelog.d/sdk-1497.build @@ -0,0 +1 @@ +Build: Makes distributing the SDK as a binary Swift package possible again. Contributed by Christopher Kobusch (@Topheee).