diff --git a/.swiftlint.yml b/.swiftlint.yml index 86fc1ea4..352d86c7 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -9,14 +9,17 @@ opt_in_rules: - closure_spacing - conditional_returns_on_newline - contains_over_first_not_nil + - convenience_type - discouraged_object_literal - discouraged_optional_boolean - discouraged_optional_collection - empty_count - empty_string + - empty_xctest_method - explicit_enum_raw_value - explicit_init - extension_access_modifier + - fallthrough - fatal_error_message - file_header - first_where @@ -26,28 +29,33 @@ opt_in_rules: - let_var_whitespace - literal_expression_end_indentation - lower_acl_than_parent + - modifier_order + - multiline_function_chains - multiline_parameters - nimble_operator - operator_usage_whitespace - overridden_super_call - override_in_extension - pattern_matching_keywords + - private_action - private_outlet - prohibited_super_call - redundant_nil_coalescing - single_test_class - sorted_first_last - switch_case_on_newline + - unavailable_function - unneeded_parentheses_in_closure_argument - untyped_error_in_catch - vertical_parameter_alignment_on_call - yoda_condition disabled_rules: - - colon - - comma - cyclomatic_complexity - identifier_name +colon: + flexible_right_spacing: true + trailing_comma: mandatory_comma: true diff --git a/.travis.yml b/.travis.yml index cddaa703..49d3b663 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,12 +5,12 @@ language: objective-c xcode_workspace: OneTimePassword.xcworkspace xcode_scheme: OneTimePassword (iOS) -osx_image: xcode9.3 +osx_image: xcode10 env: - - RUNTIME="iOS 9.3" DEVICE="iPhone 6s" - RUNTIME="iOS 10.3" DEVICE="iPhone 7 Plus" - RUNTIME="iOS 11.3" DEVICE="iPhone X" + - RUNTIME="iOS 12.0" DEVICE="iPhone XS Max" # Include builds for watchOS matrix: @@ -21,13 +21,19 @@ matrix: # Include an Xcode 9.2 build to test on iOS 8.x, because Xcode 9.3's iOS 8 simulator fails to launch - osx_image: xcode9.2 env: RUNTIME="iOS 8.4" DEVICE="iPhone 4s" + # Include an Xcode 9.4 build to ensure compatibility until Xcode 10 is in widespread use + - osx_image: xcode9.4 + env: RUNTIME="iOS 9.3" DEVICE="iPhone 6s" # Include several build-only jobs for watchOS - xcode_scheme: OneTimePassword (watchOS) + env: BUILD_ONLY="YES" RUNTIME="watchOS 5.0" DEVICE="Apple Watch Series 4 - 44mm" + - xcode_scheme: OneTimePassword (watchOS) + osx_image: xcode9.4 env: BUILD_ONLY="YES" RUNTIME="watchOS 4.3" DEVICE="Apple Watch Series 3 - 38mm" - xcode_scheme: OneTimePassword (watchOS) env: BUILD_ONLY="YES" RUNTIME="watchOS 3.2" DEVICE="Apple Watch Series 2 - 42mm" - xcode_scheme: OneTimePassword (watchOS) - env: BUILD_ONLY="YES" RUNTIME="watchOS 2.2" DEVICE="Apple Watch - 38mm" + env: BUILD_ONLY="YES" RUNTIME="watchOS 2.0" DEVICE="Apple Watch - 38mm" # Check out nested dependencies before_install: git submodule update --init --recursive diff --git a/CHANGELOG.md b/CHANGELOG.md index 775cc84c..bc7f723b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ +## [3.1.4][] (2018-09-15) +- Fix compilation errors and add CI testing for Xcode 10. +([#182](https://github.com/mattrubin/OneTimePassword/pull/182), +[#186](https://github.com/mattrubin/OneTimePassword/pull/186)) +- Enable several new SwiftLint opt-in rules. ([#187](https://github.com/mattrubin/OneTimePassword/pull/187)) + + ## [3.1.3][] (2018-04-29) - Ignore un-deserializable tokens in `allPersistentTokens()`. ([#179](https://github.com/mattrubin/OneTimePassword/pull/179)) @@ -159,8 +166,9 @@ Changes between prerelease versions of OneTimePassword version 2 can be found be ## [1.0.0][] (2014-07-17) -[develop]: https://github.com/mattrubin/OneTimePassword/compare/3.1.3...develop +[develop]: https://github.com/mattrubin/OneTimePassword/compare/3.1.4...develop +[3.1.4]: https://github.com/mattrubin/OneTimePassword/compare/3.1.3...3.1.4 [3.1.3]: https://github.com/mattrubin/OneTimePassword/compare/3.1.2...3.1.3 [3.1.2]: https://github.com/mattrubin/OneTimePassword/compare/3.1.1...3.1.2 [3.1.1]: https://github.com/mattrubin/OneTimePassword/compare/3.1...3.1.1 diff --git a/CommonCrypto/appletvos/module.modulemap b/CommonCrypto/appletvos/module.modulemap index c4fac3a1..5289f57e 100644 --- a/CommonCrypto/appletvos/module.modulemap +++ b/CommonCrypto/appletvos/module.modulemap @@ -1,4 +1,4 @@ -module CommonCrypto [system] { +module CommonCryptoShim [system] { header "/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/CommonCrypto/CommonCrypto.h" export * } diff --git a/CommonCrypto/appletvsimulator/module.modulemap b/CommonCrypto/appletvsimulator/module.modulemap index d1728b66..a0c4f03b 100644 --- a/CommonCrypto/appletvsimulator/module.modulemap +++ b/CommonCrypto/appletvsimulator/module.modulemap @@ -1,4 +1,4 @@ -module CommonCrypto [system] { +module CommonCryptoShim [system] { header "/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/include/CommonCrypto/CommonCrypto.h" export * } diff --git a/CommonCrypto/iphoneos/module.modulemap b/CommonCrypto/iphoneos/module.modulemap index 125b7720..0d53e895 100644 --- a/CommonCrypto/iphoneos/module.modulemap +++ b/CommonCrypto/iphoneos/module.modulemap @@ -1,4 +1,4 @@ -module CommonCrypto [system] { +module CommonCryptoShim [system] { header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/CommonCrypto/CommonCrypto.h" export * } diff --git a/CommonCrypto/iphonesimulator/module.modulemap b/CommonCrypto/iphonesimulator/module.modulemap index 835d6863..787e5f16 100644 --- a/CommonCrypto/iphonesimulator/module.modulemap +++ b/CommonCrypto/iphonesimulator/module.modulemap @@ -1,4 +1,4 @@ -module CommonCrypto [system] { +module CommonCryptoShim [system] { header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/CommonCrypto/CommonCrypto.h" export * } diff --git a/CommonCrypto/macosx/module.modulemap b/CommonCrypto/macosx/module.modulemap index 9ceb81cc..40b7cfc9 100644 --- a/CommonCrypto/macosx/module.modulemap +++ b/CommonCrypto/macosx/module.modulemap @@ -1,4 +1,4 @@ -module CommonCrypto [system] { +module CommonCryptoShim [system] { header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/CommonCrypto/CommonCrypto.h" export * } diff --git a/CommonCrypto/watchos/module.modulemap b/CommonCrypto/watchos/module.modulemap index e81b2c61..152f247a 100644 --- a/CommonCrypto/watchos/module.modulemap +++ b/CommonCrypto/watchos/module.modulemap @@ -1,4 +1,4 @@ -module CommonCrypto [system] { +module CommonCryptoShim [system] { header "/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/usr/include/CommonCrypto/CommonCrypto.h" export * } diff --git a/CommonCrypto/watchsimulator/module.modulemap b/CommonCrypto/watchsimulator/module.modulemap index e1cfc7f9..2e6e21b1 100644 --- a/CommonCrypto/watchsimulator/module.modulemap +++ b/CommonCrypto/watchsimulator/module.modulemap @@ -1,4 +1,4 @@ -module CommonCrypto [system] { +module CommonCryptoShim [system] { header "/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/usr/include/CommonCrypto/CommonCrypto.h" export * } diff --git a/OneTimePassword.podspec b/OneTimePassword.podspec index 0d0fc894..01c5ae37 100644 --- a/OneTimePassword.podspec +++ b/OneTimePassword.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "OneTimePassword" - s.version = "3.1.3" + s.version = "3.1.4" s.summary = "A small library for generating TOTP and HOTP one-time passwords." s.homepage = "https://github.com/mattrubin/OneTimePassword" s.license = "MIT" diff --git a/OneTimePasswordLegacyTests/OTPToken.swift b/OneTimePasswordLegacyTests/OTPToken.swift index 195bf2cb..70d09abd 100644 --- a/OneTimePasswordLegacyTests/OTPToken.swift +++ b/OneTimePasswordLegacyTests/OTPToken.swift @@ -30,7 +30,7 @@ import OneTimePassword /// information about its properties and methods, consult the underlying `OneTimePassword` /// documentation. public final class OTPToken: NSObject { - required public override init() {} + override public required init() {} @objc public var name: String = OTPToken.defaultName @objc public var issuer: String = OTPToken.defaultIssuer diff --git a/Sources/Crypto.swift b/Sources/Crypto.swift index d2e7c84f..3a154099 100644 --- a/Sources/Crypto.swift +++ b/Sources/Crypto.swift @@ -24,7 +24,15 @@ // import Foundation -import CommonCrypto +#if swift(>=4.1) + #if canImport(CommonCrypto) + import CommonCrypto + #else + import CommonCryptoShim + #endif +#else + import CommonCryptoShim +#endif func HMAC(algorithm: Generator.Algorithm, key: Data, data: Data) -> Data { let (hashFunction, hashLength) = algorithm.hashInfo diff --git a/Sources/Info.plist b/Sources/Info.plist index fa3725f0..78223678 100644 --- a/Sources/Info.plist +++ b/Sources/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 3.1.3 + 3.1.4 CFBundleSignature ???? CFBundleVersion - 3.1.3 + 3.1.4 NSPrincipalClass diff --git a/Sources/Keychain.swift b/Sources/Keychain.swift index ff1637b8..b2c9d1a8 100644 --- a/Sources/Keychain.swift +++ b/Sources/Keychain.swift @@ -52,7 +52,7 @@ public final class Keychain { // tokens as possible. // TODO: Restore deserialization error handling, in a way that provides info on the failure reason and allows // the caller to choose whether to fail completely or recover some data. - return Set(allItems.flatMap({ try? PersistentToken.init(keychainDictionary:$0) })) + return Set(allItems.flatMap({ try? PersistentToken(keychainDictionary: $0) })) } // MARK: Write @@ -180,7 +180,7 @@ private func addKeychainItem(withAttributes attributes: [String: AnyObject]) thr private func updateKeychainItem(forPersistentRef persistentRef: Data, withAttributes attributesToUpdate: [String: AnyObject]) throws { - let queryDict: [String : AnyObject] = [ + let queryDict: [String: AnyObject] = [ kSecClass as String: kSecClassGenericPassword, kSecValuePersistentRef as String: persistentRef as NSData, ] @@ -193,7 +193,7 @@ private func updateKeychainItem(forPersistentRef persistentRef: Data, } private func deleteKeychainItem(forPersistentRef persistentRef: Data) throws { - let queryDict: [String : AnyObject] = [ + let queryDict: [String: AnyObject] = [ kSecClass as String: kSecClassGenericPassword, kSecValuePersistentRef as String: persistentRef as NSData, ] @@ -206,7 +206,7 @@ private func deleteKeychainItem(forPersistentRef persistentRef: Data) throws { } private func keychainItem(forPersistentRef persistentRef: Data) throws -> NSDictionary? { - let queryDict: [String : AnyObject] = [ + let queryDict: [String: AnyObject] = [ kSecClass as String: kSecClassGenericPassword, kSecValuePersistentRef as String: persistentRef as NSData, kSecReturnPersistentRef as String: kCFBooleanTrue, @@ -233,7 +233,7 @@ private func keychainItem(forPersistentRef persistentRef: Data) throws -> NSDict } private func allKeychainItems() throws -> [NSDictionary] { - let queryDict: [String : AnyObject] = [ + let queryDict: [String: AnyObject] = [ kSecClass as String: kSecClassGenericPassword, kSecMatchLimit as String: kSecMatchLimitAll, kSecReturnPersistentRef as String: kCFBooleanTrue, diff --git a/Tests/GeneratorTests.swift b/Tests/GeneratorTests.swift index d2449f65..d9e60fa0 100644 --- a/Tests/GeneratorTests.swift +++ b/Tests/GeneratorTests.swift @@ -73,11 +73,13 @@ class GeneratorTests: XCTestCase { func testCounter() { let factors: [(TimeInterval, TimeInterval, UInt64)] = [ + // swiftlint:disable comma (100, 30, 3), (10000, 30, 333), (1000000, 30, 33333), (100000000, 60, 1666666), (10000000000, 90, 111111111), + // swiftlint:enable comma ] for (timeSinceEpoch, period, count) in factors { diff --git a/Tests/KeychainTests.swift b/Tests/KeychainTests.swift index 5d90daa1..e1ede6e2 100644 --- a/Tests/KeychainTests.swift +++ b/Tests/KeychainTests.swift @@ -319,7 +319,7 @@ private func addKeychainItem(withAttributes attributes: [String: AnyObject]) thr } public func deleteKeychainItem(forPersistentRef persistentRef: Data) throws { - let queryDict: [String : AnyObject] = [ + let queryDict: [String: AnyObject] = [ kSecClass as String: kSecClassGenericPassword, kSecValuePersistentRef as String: persistentRef as NSData, ]