From 8044897fff59ffa257719d33bf719f612da97ea7 Mon Sep 17 00:00:00 2001 From: Britney Smith Date: Mon, 17 Apr 2023 11:27:57 -0400 Subject: [PATCH] Addresses most Xcode warnings outside of signature configurations and localization exporting Unit tests pass, integration tests fail --- .tool-versions | 1 + Spreedly/Internal/JSON.swift | 1 - Spreedly/Internal/SpreedlyClientImpl.swift | 2 +- Spreedly/Models/BankAccountInfo.swift | 2 +- Spreedly/Models/CreditCardInfo.swift | 2 +- .../Controls/CreditCardNumberTextField.swift | 4 +-- SpreedlyCocoa/Controls/SecureForm.swift | 10 ++++-- SpreedlyCocoa/Express/ApplePay.swift | 2 +- .../Express/ExpirationDateProvider.swift | 2 +- SpreedlySdk.xcodeproj/project.pbxproj | 34 ++++--------------- .../xcshareddata/IDEWorkspaceChecks.plist | 8 +++++ 11 files changed, 29 insertions(+), 39 deletions(-) create mode 100644 .tool-versions create mode 100644 SpreedlySdk.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..306ab33 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +ruby 3.1.4 diff --git a/Spreedly/Internal/JSON.swift b/Spreedly/Internal/JSON.swift index 9553ca6..4923e98 100644 --- a/Spreedly/Internal/JSON.swift +++ b/Spreedly/Internal/JSON.swift @@ -3,7 +3,6 @@ // import Foundation -import Spreedly enum JSONError: Error, Equatable { case keyNotFound(key: String) diff --git a/Spreedly/Internal/SpreedlyClientImpl.swift b/Spreedly/Internal/SpreedlyClientImpl.swift index 3ad9a1b..fa18832 100644 --- a/Spreedly/Internal/SpreedlyClientImpl.swift +++ b/Spreedly/Internal/SpreedlyClientImpl.swift @@ -166,7 +166,7 @@ class SpreedlyClientImpl: NSObject, SpreedlyClient { "platform": "apple", "locale": Locale.current.languageCode ?? "unknown", "os": [ - "name": proc.operatingSystemName(), + "name": proc.operatingSystemVersion, "arch": arch, "version": proc.operatingSystemVersionString, ] as [String : Any], diff --git a/Spreedly/Models/BankAccountInfo.swift b/Spreedly/Models/BankAccountInfo.swift index 3b87648..dea0a5e 100644 --- a/Spreedly/Models/BankAccountInfo.swift +++ b/Spreedly/Models/BankAccountInfo.swift @@ -94,7 +94,7 @@ public class BankAccountInfo: PaymentMethodInfo { "metadata": metadata ?? Metadata(), "bank_account": try self.toJson(), "retained": self.retained ?? false - ] + ] as [String : Any] ] } } diff --git a/Spreedly/Models/CreditCardInfo.swift b/Spreedly/Models/CreditCardInfo.swift index 237fb51..75e217c 100644 --- a/Spreedly/Models/CreditCardInfo.swift +++ b/Spreedly/Models/CreditCardInfo.swift @@ -70,7 +70,7 @@ public class CreditCardInfo: PaymentMethodInfo { "allow_blank_date": allowBlankDate, "allow_expired_date": allowExpiredDate, "retained": self.retained ?? false - ] + ] as [String : Any] ] } } diff --git a/SpreedlyCocoa/Controls/CreditCardNumberTextField.swift b/SpreedlyCocoa/Controls/CreditCardNumberTextField.swift index 7fd6841..c33fa69 100644 --- a/SpreedlyCocoa/Controls/CreditCardNumberTextField.swift +++ b/SpreedlyCocoa/Controls/CreditCardNumberTextField.swift @@ -6,7 +6,7 @@ import Foundation import UIKit import Spreedly -public protocol CreditCardNumberTextFieldDelegate: class { +public protocol CreditCardNumberTextFieldDelegate: AnyObject { /// Called whenever the card brand is determined based on the `CreditCardNumberTextField` content. May be /// called many times. func cardBrandDetermined(brand: CardBrand) @@ -115,7 +115,7 @@ extension CreditCardNumberTextField { } /// Masks all digits except the last four with `maskCharacter`. - open func generateMasked(from string: String) -> String { + public func generateMasked(from string: String) -> String { let cardNumber = string.onlyNumbers() let maskCharacterCount = max(cardNumber.count - 4, 0) diff --git a/SpreedlyCocoa/Controls/SecureForm.swift b/SpreedlyCocoa/Controls/SecureForm.swift index 21de5cb..806d4f0 100644 --- a/SpreedlyCocoa/Controls/SecureForm.swift +++ b/SpreedlyCocoa/Controls/SecureForm.swift @@ -9,7 +9,7 @@ import Spreedly /// A set of methods that you use to receive successfully created payment methods from Spreedly and provide /// client configuration for that communication. @objc(SPRSecureFormDelegate) -public protocol SecureFormDelegate: class { +public protocol SecureFormDelegate: AnyObject { /// Tells the delegate that a payment methods was successfully created. func spreedly(secureForm: SecureForm, success: Transaction) @@ -213,7 +213,7 @@ public class SecureForm: UIView { maybeSetShippingAddress(on: &info.shippingAddress, fallbackOn: info.address) let client = getClientOrDieTrying() - _ = client.createPaymentMethodFrom(creditCard: info).subscribe(onSuccess: { transaction in + client.createPaymentMethodFrom(creditCard: info).subscribe(onSuccess: { transaction in DispatchQueue.main.async { self.delegate?.didCallSpreedly?(secureForm: self) if let errors = transaction.errors, errors.count > 0 { @@ -260,7 +260,7 @@ public class SecureForm: UIView { maybeSetShippingAddress(on: &info.shippingAddress, fallbackOn: info.address) let client = getClientOrDieTrying() - _ = client.createPaymentMethodFrom(bankAccount: info).subscribe(onSuccess: { transaction in + client.createPaymentMethodFrom(bankAccount: info).subscribe(onSuccess: { transaction in DispatchQueue.main.async { self.delegate?.didCallSpreedly?(secureForm: self) if let errors = transaction.errors, errors.count > 0 { @@ -291,6 +291,8 @@ public class SecureForm: UIView { bankAccountHolderType?.selectedSegmentIndex = 0 case .business: bankAccountHolderType?.selectedSegmentIndex = 1 + @unknown default: + bankAccountHolderType?.selectedSegmentIndex = 0 } } } @@ -314,6 +316,8 @@ public class SecureForm: UIView { bankAccountType?.selectedSegmentIndex = 0 case .savings: bankAccountType?.selectedSegmentIndex = 1 + @unknown default: + bankAccountType?.selectedSegmentIndex = 0 } } } diff --git a/SpreedlyCocoa/Express/ApplePay.swift b/SpreedlyCocoa/Express/ApplePay.swift index 42869ae..1324b93 100644 --- a/SpreedlyCocoa/Express/ApplePay.swift +++ b/SpreedlyCocoa/Express/ApplePay.swift @@ -70,7 +70,7 @@ extension ApplePayHandler: PKPaymentAuthorizationControllerDelegate { let info = ApplePayInfo(copyFrom: defaults, payment: payment) if let client = client { - _ = client.createPaymentMethodFrom(applePay: info).subscribe(onSuccess: onSuccess, onError: onError) + client.createPaymentMethodFrom(applePay: info).subscribe(onSuccess: onSuccess, onError: onError) } else if let objcClient = objcClient { objcClient._objCCreatePaymentMethod(from: info).subscribe(onSuccess: onSuccess, onError: onError) } diff --git a/SpreedlyCocoa/Express/ExpirationDateProvider.swift b/SpreedlyCocoa/Express/ExpirationDateProvider.swift index 1821eb2..eab450d 100644 --- a/SpreedlyCocoa/Express/ExpirationDateProvider.swift +++ b/SpreedlyCocoa/Express/ExpirationDateProvider.swift @@ -3,7 +3,7 @@ // @objc(SPRExpirationDateProvider) -public protocol ExpirationDateProvider: class { +public protocol ExpirationDateProvider: AnyObject { func expirationDate() -> ExpirationDate? } diff --git a/SpreedlySdk.xcodeproj/project.pbxproj b/SpreedlySdk.xcodeproj/project.pbxproj index 0574aa7..d4374a5 100644 --- a/SpreedlySdk.xcodeproj/project.pbxproj +++ b/SpreedlySdk.xcodeproj/project.pbxproj @@ -48,7 +48,6 @@ 442A286A0A671222E369442C /* SpreedlyClientImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442A2FFB6CFF85B8207B2668 /* SpreedlyClientImpl.swift */; }; 442A2975DBA6BA44D577E271 /* Spreedly-env.plist in Resources */ = {isa = PBXBuildFile; fileRef = 442A21723181F2D5F72F5B71 /* Spreedly-env.plist */; }; 442A2C50F647133D4E48C7FF /* Secrets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442A21244C58460DB48ED6B3 /* Secrets.swift */; }; - 442A2D2E48133A09DBBD9299 /* Package.swift.template in Sources */ = {isa = PBXBuildFile; fileRef = 442A257AA5C4556A468C6045 /* Package.swift.template */; }; 442A2D788057F47D67D550E6 /* RecacheTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442A2E6D7CB97F55DF7DE5F6 /* RecacheTests.swift */; }; 442A2E09E5707DA5C0EC5A6D /* SecureForm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442A2BB20D7CBBCE9E4DD568 /* SecureForm.swift */; }; 442A2E1EB4A7C7F18EBAB464 /* SecureStringTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 442A218D2C643E6C4141E9D2 /* SecureStringTest.swift */; }; @@ -801,7 +800,6 @@ F076C6D90DB36BC555C246AC /* BankAccountInfo.swift in Sources */, A60A0240278796000044BD69 /* SpreedlyVersion.swift in Sources */, F076CD7FF9E8D8C63D808B1A /* CreditCardInfo.swift in Sources */, - 442A2D2E48133A09DBBD9299 /* Package.swift.template in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1007,10 +1005,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Frameworks", - ); + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -1084,11 +1079,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Frameworks", - "$(PROJECT_DIR)/Carthage/Build/iOS", - ); + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -1165,10 +1156,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Frameworks", - ); + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -1282,10 +1270,7 @@ DEVELOPMENT_TEAM = 6FBAK4HRQ7; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Frameworks", - ); + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -1356,11 +1341,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Frameworks", - "$(PROJECT_DIR)/Carthage/Build/iOS", - ); + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -1438,10 +1419,7 @@ DEVELOPMENT_TEAM = 6FBAK4HRQ7; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Frameworks", - ); + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; diff --git a/SpreedlySdk.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/SpreedlySdk.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/SpreedlySdk.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + +