From 3e28c9417981b4105aa9fa67cce86cc7258bcdb7 Mon Sep 17 00:00:00 2001 From: benshutt Date: Tue, 21 Sep 2021 13:18:19 +0100 Subject: [PATCH 1/6] Bump version, run Xcode suggested changes, iOS 12 fixes --- ThunderRequest.xcodeproj/project.pbxproj | 108 ++++++++++-------- .../xcschemes/ThunderRequest-iOS.xcscheme | 28 ++--- .../xcschemes/ThunderRequest-macOS.xcscheme | 24 ++-- .../xcschemes/ThunderRequest-tvOS.xcscheme | 24 ++-- .../xcschemes/ThunderRequest-watchOS.xcscheme | 6 +- ThunderRequest/CredentialStore.swift | 13 +-- ThunderRequest/RequestCredential.swift | 13 ++- ThunderRequestTests/AuthTests.swift | 16 ++- 8 files changed, 120 insertions(+), 112 deletions(-) diff --git a/ThunderRequest.xcodeproj/project.pbxproj b/ThunderRequest.xcodeproj/project.pbxproj index 390ebe6..aa9c005 100644 --- a/ThunderRequest.xcodeproj/project.pbxproj +++ b/ThunderRequest.xcodeproj/project.pbxproj @@ -729,7 +729,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 1020; - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = threesidedcube; TargetAttributes = { 49084FD01BD13DBD0012F636 = { @@ -740,11 +740,13 @@ }; B1177ED71BBAF18E00372D4D = { CreatedOnToolsVersion = 6.4; - LastSwiftMigration = 0930; - ProvisioningStyle = Manual; + DevelopmentTeam = 25H7BM6YWK; + LastSwiftMigration = 1300; + ProvisioningStyle = Automatic; }; B1177EE11BBAF18E00372D4D = { CreatedOnToolsVersion = 6.4; + ProvisioningStyle = Automatic; }; B120EE3C207B895800A4A7CA = { CreatedOnToolsVersion = 9.3; @@ -754,7 +756,6 @@ }; B190A828228DBA3A00E44821 = { CreatedOnToolsVersion = 10.2.1; - DevelopmentTeam = 5AAUAL6K5G; ProvisioningStyle = Automatic; }; C2E5088119C835A300350F00 = { @@ -765,18 +766,17 @@ }; C2E5088C19C835A300350F00 = { CreatedOnToolsVersion = 6.0; - DevelopmentTeam = 25H7BM6YWK; LastSwiftMigration = 1100; }; }; }; buildConfigurationList = C2E5087C19C835A300350F00 /* Build configuration list for PBXProject "ThunderRequest" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( - English, en, + Base, ); mainGroup = C2E5087819C835A300350F00; productRefGroup = C2E5088319C835A300350F00 /* Products */; @@ -1092,7 +1092,6 @@ buildSettings = { CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "Apple Development"; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; CODE_SIGN_STYLE = Automatic; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; @@ -1105,16 +1104,16 @@ INFOPLIST_FILE = ThunderRequestTV/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 2.3.1; + MARKETING_VERSION = 3.0.0; PRODUCT_BUNDLE_IDENTIFIER = com.3sidedcube.ThunderRequestTV; PRODUCT_NAME = ThunderRequest; PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 10.0; + TVOS_DEPLOYMENT_TARGET = 12.0; }; name = Debug; }; @@ -1123,7 +1122,6 @@ buildSettings = { CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "Apple Development"; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -1137,15 +1135,15 @@ INFOPLIST_FILE = ThunderRequestTV/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 2.3.1; + MARKETING_VERSION = 3.0.0; PRODUCT_BUNDLE_IDENTIFIER = com.3sidedcube.ThunderRequestTV; PRODUCT_NAME = ThunderRequest; PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = appletvos; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 10.0; + TVOS_DEPLOYMENT_TARGET = 12.0; }; name = Release; }; @@ -1154,11 +1152,11 @@ buildSettings = { CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Manual; + CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 25H7BM6YWK; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -1172,15 +1170,15 @@ INFOPLIST_FILE = ThunderRequestMac/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.11; - MARKETING_VERSION = 2.3.1; + MACOSX_DEPLOYMENT_TARGET = 10.13; + MARKETING_VERSION = 3.0.0; PRODUCT_BUNDLE_IDENTIFIER = "com.threesidedcube.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = ThunderRequest; PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = macosx; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -1189,12 +1187,12 @@ buildSettings = { CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Manual; + CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 25H7BM6YWK; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -1204,14 +1202,14 @@ INFOPLIST_FILE = ThunderRequestMac/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.11; - MARKETING_VERSION = 2.3.1; + MACOSX_DEPLOYMENT_TARGET = 10.13; + MARKETING_VERSION = 3.0.0; PRODUCT_BUNDLE_IDENTIFIER = "com.threesidedcube.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = ThunderRequest; PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = macosx; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -1219,8 +1217,11 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; DEBUG_INFORMATION_FORMAT = dwarf; + DEVELOPMENT_TEAM = ""; FRAMEWORK_SEARCH_PATHS = ( "$(DEVELOPER_FRAMEWORKS_DIR)", "$(inherited)", @@ -1233,9 +1234,9 @@ GCC_TREAT_WARNINGS_AS_ERRORS = YES; INFOPLIST_FILE = ThunderRequestMacTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.11; PRODUCT_BUNDLE_IDENTIFIER = "com.threesidedcube.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = macosx; SWIFT_VERSION = 5.0; }; @@ -1245,9 +1246,12 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEVELOPMENT_TEAM = ""; FRAMEWORK_SEARCH_PATHS = ( "$(DEVELOPER_FRAMEWORKS_DIR)", "$(inherited)", @@ -1256,9 +1260,9 @@ GCC_TREAT_WARNINGS_AS_ERRORS = YES; INFOPLIST_FILE = ThunderRequestMacTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.11; PRODUCT_BUNDLE_IDENTIFIER = "com.threesidedcube.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = macosx; SWIFT_VERSION = 5.0; }; @@ -1277,7 +1281,7 @@ CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = ""; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; @@ -1289,15 +1293,16 @@ INFOPLIST_FILE = ThunderRequestWatch/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 2.3.1; + MARKETING_VERSION = 3.0.0; PRODUCT_BUNDLE_IDENTIFIER = com.3sidedcube.ThunderRequestWatch; PRODUCT_NAME = ThunderRequest; + PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = watchos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 4; - WATCHOS_DEPLOYMENT_TARGET = 2.0; + WATCHOS_DEPLOYMENT_TARGET = 4.0; }; name = Debug; }; @@ -1314,7 +1319,7 @@ CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = ""; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -1327,14 +1332,15 @@ INFOPLIST_FILE = ThunderRequestWatch/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 2.3.1; + MARKETING_VERSION = 3.0.0; PRODUCT_BUNDLE_IDENTIFIER = com.3sidedcube.ThunderRequestWatch; PRODUCT_NAME = ThunderRequest; + PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = watchos; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 4; - WATCHOS_DEPLOYMENT_TARGET = 2.0; + WATCHOS_DEPLOYMENT_TARGET = 4.0; }; name = Release; }; @@ -1349,7 +1355,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; DEBUG_INFORMATION_FORMAT = dwarf; - DEVELOPMENT_TEAM = 5AAUAL6K5G; + DEVELOPMENT_TEAM = ""; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "ThunderRequestTests-tvOS/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -1377,7 +1383,7 @@ CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DEVELOPMENT_TEAM = 5AAUAL6K5G; + DEVELOPMENT_TEAM = ""; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "ThunderRequestTests-tvOS/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -1395,6 +1401,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -1413,6 +1420,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -1438,7 +1446,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -1453,6 +1461,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -1471,6 +1480,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -1489,7 +1499,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; @@ -1504,8 +1514,9 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = 25H7BM6YWK; @@ -1515,13 +1526,14 @@ GCC_TREAT_WARNINGS_AS_ERRORS = YES; INFOPLIST_FILE = ThunderRequest/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 2.3.1; + MARKETING_VERSION = 3.0.0; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.threesidedcube.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = ThunderRequest; PROVISIONING_PROFILE_SPECIFIER = ""; + "PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = ""; SKIP_INSTALL = YES; SUPPORTS_MACCATALYST = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -1534,8 +1546,9 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = 25H7BM6YWK; @@ -1545,12 +1558,13 @@ GCC_TREAT_WARNINGS_AS_ERRORS = YES; INFOPLIST_FILE = ThunderRequest/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 2.3.1; + MARKETING_VERSION = 3.0.0; PRODUCT_BUNDLE_IDENTIFIER = "com.threesidedcube.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = ThunderRequest; PROVISIONING_PROFILE_SPECIFIER = ""; + "PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = ""; SKIP_INSTALL = YES; SUPPORTS_MACCATALYST = YES; SWIFT_TREAT_WARNINGS_AS_ERRORS = YES; @@ -1561,7 +1575,7 @@ C2E5089919C835A300350F00 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - DEVELOPMENT_TEAM = 25H7BM6YWK; + DEVELOPMENT_TEAM = ""; FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", @@ -1584,7 +1598,7 @@ C2E5089A19C835A300350F00 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - DEVELOPMENT_TEAM = 25H7BM6YWK; + DEVELOPMENT_TEAM = ""; FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", diff --git a/ThunderRequest.xcodeproj/xcshareddata/xcschemes/ThunderRequest-iOS.xcscheme b/ThunderRequest.xcodeproj/xcshareddata/xcschemes/ThunderRequest-iOS.xcscheme index 158e9de..4a01ecd 100644 --- a/ThunderRequest.xcodeproj/xcshareddata/xcschemes/ThunderRequest-iOS.xcscheme +++ b/ThunderRequest.xcodeproj/xcshareddata/xcschemes/ThunderRequest-iOS.xcscheme @@ -1,6 +1,6 @@ + shouldUseLaunchSchemeArgsEnv = "YES" + codeCoverageEnabled = "YES"> + + + + @@ -40,17 +49,6 @@ - - - - - - - - + + + + @@ -39,17 +48,6 @@ - - - - - - - - + + + + @@ -39,17 +48,6 @@ - - - - - - - - - - - - Data { + return try NSKeyedArchiver.archivedData( + withRootObject: self, + requiringSecureCoding: false + ) } /// Creates a new username/password based credential diff --git a/ThunderRequestTests/AuthTests.swift b/ThunderRequestTests/AuthTests.swift index 04819dd..c448bbc 100644 --- a/ThunderRequestTests/AuthTests.swift +++ b/ThunderRequestTests/AuthTests.swift @@ -16,7 +16,7 @@ class DummyAuthenticator: Authenticator { } var keychainAccessibility: CredentialStore.Accessibility { - return .always + return .afterFirstUnlock } func reAuthenticate(credential: RequestCredential?, completion: (RequestCredential?, Error?, Bool) -> Void) { @@ -74,7 +74,12 @@ class AuthTests: XCTestCase { let credential = RequestCredential(authorizationToken: "token", refreshToken: "refresh", expiryDate: Date(timeIntervalSinceNow: 1600)) - CredentialStore.store(credential: credential, identifier: "dummyauthenticator", accessibility: .always, in: store) + CredentialStore.store( + credential: credential, + identifier: "dummyauthenticator", + accessibility: .afterFirstUnlock, + in: store + ) let authenticator = DummyAuthenticator() requestController.authenticator = authenticator @@ -90,7 +95,12 @@ class AuthTests: XCTestCase { let store = KeychainMockStore() - CredentialStore.store(credential: credential, identifier: "thundertable.com.threesidedcube-https://httpbin.org/", accessibility: .always, in: store) + CredentialStore.store( + credential: credential, + identifier: "thundertable.com.threesidedcube-https://httpbin.org/", + accessibility: .afterFirstUnlock, + in: store + ) let requestController = RequestController(baseURL: requestBaseURL, dataStore: store) From bcbf03bd88e61aa495366ee752b1ebff4a326715 Mon Sep 17 00:00:00 2001 From: benshutt Date: Tue, 21 Sep 2021 14:10:11 +0100 Subject: [PATCH 2/6] Update README.md --- README.md | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 6b2be72..af27a3a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Thunder Request -[![Build Status](https://travis-ci.org/3sidedcube/ThunderRequest.svg)](https://travis-ci.org/3sidedcube/ThunderRequest) [![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Swift 5.3.2](http://img.shields.io/badge/swift-5.3.2-brightgreen.svg)](https://swift.org/blog/swift-5-3-released/) [![Apache 2](https://img.shields.io/badge/license-Apache%202-brightgreen.svg)](LICENSE.md) +[![Build Status](https://travis-ci.org/3sidedcube/ThunderRequest.svg)](https://travis-ci.org/3sidedcube/ThunderRequest) [![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Swift 5.5](http://img.shields.io/badge/swift-5.5-brightgreen.svg)](https://swift.org/blog/swift-5-5-released/) [![Apache 2](https://img.shields.io/badge/license-Apache%202-brightgreen.svg)](LICENSE.md) Thunder Request is a Framework used to simplify making http and https web requests. @@ -10,9 +10,9 @@ Setting up your app to use ThunderBasics is a simple and quick process. You can ## Carthage -- Add `github "3sidedcube/ThunderRequest" == 2.3.1` to your Cartfile. -- Run `carthage update --platform ios` to fetch the framework. -- Drag `ThunderRequest` into your project's _Linked Frameworks and Libraries_ section from the `Carthage/Build` folder. +- Add `github "3sidedcube/ThunderRequest" == 3.0.0` to your Cartfile. +- Run `carthage update --platform ios --use-xcframeworks` to fetch the framework. +- Drag `ThunderRequest` into your project's _Frameworks and Libraries_ section from the `Carthage/Build` folder (Embed). - Add the Build Phases script step as defined [here](https://github.com/Carthage/Carthage#if-youre-building-for-ios-tvos-or-watchos). ## Manual @@ -186,12 +186,6 @@ requestController.uploadFile(fileURL, to: "post", progress: { (progress, totalBy } ``` -# Building Binaries for Carthage - -Since Xcode 12 there has been issues with building Carthage binaries caused by the inclusion of a secondary arm64 slice in the generated binary needed for Apple Silicon on macOS. This means that rather than simply using `carthage build --archive` you need to use the `./carthage-build build --archive` command which uses the script included with this repo. For more information, see the issue on Carthage's github [here](https://github.com/Carthage/Carthage/issues/3019) - -We will be investigating moving over to use SPM as an agency soon, and will also look into migrating to use .xcframeworks as soon as Carthage have support for it. - # Code level documentation Documentation is available for the entire library in AppleDoc format. This is available in the framework itself or in the [Hosted Version](http://3sidedcube.github.io/iOS-ThunderRequest/) From 4c1375b297b103a9e4949a668f127792c4b5eefd Mon Sep 17 00:00:00 2001 From: benshutt Date: Tue, 21 Sep 2021 14:14:38 +0100 Subject: [PATCH 3/6] Update .travis.yml --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index fc9b3e5..7486499 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: swift xcode_project: ThunderRequest.xcodeproj # path to your xcodeproj folder -osx_image: xcode12 +osx_image: xcode13 env: global: - LC_CTYPE=en_US.UTF-8 @@ -8,8 +8,8 @@ env: matrix: include: - xcode_scheme: ThunderRequest-iOS - xcode_destination: platform=iOS Simulator,OS=14.0,name=iPhone 11 Pro Max + xcode_destination: platform=iOS Simulator,OS=15.0,name=iPhone 13 - xcode_scheme: ThunderRequest-macOS xcode_destination: platform=macOS - xcode_scheme: ThunderRequest-tvOS - xcode_destination: platform=tvOS Simulator,OS=14.0,name=Apple TV 4K + xcode_destination: platform=tvOS Simulator,OS=15.0,name=Apple TV 4K From d338e71bf5f4a335d2b763ca267ad663f8cc07fe Mon Sep 17 00:00:00 2001 From: benshutt Date: Tue, 21 Sep 2021 14:15:18 +0100 Subject: [PATCH 4/6] Delete carthage.sh --- carthage.sh | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100755 carthage.sh diff --git a/carthage.sh b/carthage.sh deleted file mode 100755 index adffae8..0000000 --- a/carthage.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -# carthage.sh -# Usage example: ./carthage.sh build --platform iOS - -set -euo pipefail - -xcconfig=$(mktemp /tmp/static.xcconfig.XXXXXX) -trap 'rm -f "$xcconfig"' INT TERM HUP EXIT - -# For Xcode 12 make sure EXCLUDED_ARCHS is set to arm architectures otherwise -# the build will fail on lipo due to duplicate architectures. -echo 'EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1200 = arm64 arm64e armv7 armv7s armv6 armv8' >> $xcconfig -echo 'EXCLUDED_ARCHS = $(inherited) $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_$(EFFECTIVE_PLATFORM_SUFFIX)__NATIVE_ARCH_64_BIT_$(NATIVE_ARCH_64_BIT)__XCODE_$(XCODE_VERSION_MAJOR))' >> $xcconfig - -export XCODE_XCCONFIG_FILE="$xcconfig" -carthage "$@" From ee28ef400af4ff4778c9a34621a6235c7bc9169a Mon Sep 17 00:00:00 2001 From: Ben Shutt Date: Tue, 19 Apr 2022 12:33:47 +0100 Subject: [PATCH 5/6] Conform `RequestCredential` to `NSSecureCoding` and remove encoding and decoding of `URLCredential` property --- ThunderRequest/CredentialStore.swift | 2 +- ThunderRequest/RequestCredential.swift | 71 +++++++++++++++----------- 2 files changed, 42 insertions(+), 31 deletions(-) diff --git a/ThunderRequest/CredentialStore.swift b/ThunderRequest/CredentialStore.swift index 4aa07e6..3acd280 100644 --- a/ThunderRequest/CredentialStore.swift +++ b/ThunderRequest/CredentialStore.swift @@ -184,7 +184,7 @@ public struct CredentialStore { return nil } - return RequestCredential.init(keychainData: data) + return try? RequestCredential(keychainData: data) } /// Deletes an entry for a certain identifier from the keychain diff --git a/ThunderRequest/RequestCredential.swift b/ThunderRequest/RequestCredential.swift index f7befad..7d4bd06 100644 --- a/ThunderRequest/RequestCredential.swift +++ b/ThunderRequest/RequestCredential.swift @@ -21,47 +21,52 @@ public let kTSCAuthServiceName = "TSCAuthCredential" /// A class used to store authentication information and return the `URLCredential` object when required @objc(TSCRequestCredential) -public final class RequestCredential: NSObject, NSCoding { - +public final class RequestCredential: NSObject, NSSecureCoding { + /// Returns the url credential which can be used to authenticate a request - public var credential: URLCredential? - + public var credential: URLCredential? { + guard let username = username else { return nil } + guard let password = password else { return nil } + return URLCredential(user: username, password: password, persistence: .none) + } + /// The username to auth the user with public var username: String? - + /// The password to auth the user with public var password: String? - + /// The auth token to auth the user with public var authorizationToken: String? - + /// The type of the token public var tokenType: String = Authentication.TokenType.bearer - + /// The date on which the authorization token expires public var expirationDate: Date? - + /// The refresh token to be sent back to the authenticating endpoint for certain auth methods public var refreshToken: String? - + /// Init method for re-constructing from data stored in the user's keychain /// /// - Parameter keychainData: The data which was retrieved from the keychain - init?(keychainData: Data) { - guard let credential = try? NSKeyedUnarchiver.unarchivedObject( - ofClass: RequestCredential.self, + init(keychainData: Data) throws { + let requestCredential = try NSKeyedUnarchiver.unarchivedObject( + ofClasses: [RequestCredential.self, NSString.self], from: keychainData - ) else { - return nil + ) + + guard let credential = requestCredential as? RequestCredential else { + throw RequestCredentialError.invalidType } - + self.authorizationToken = credential.authorizationToken - self.credential = credential.credential self.username = credential.username self.password = credential.password self.tokenType = credential.tokenType } - + /// Whether the credential has expired. Where expiryDate is missing this will return as false, as it is /// assumed the credential doesn't have an expiry date in this case public var hasExpired: Bool { @@ -70,7 +75,7 @@ public final class RequestCredential: NSObject, NSCoding { } return Date() > expiry } - + /// The data to store in the keychain public func keychainData() throws -> Data { return try NSKeyedArchiver.archivedData( @@ -78,7 +83,7 @@ public final class RequestCredential: NSObject, NSCoding { requiringSecureCoding: false ) } - + /// Creates a new username/password based credential /// /// - Parameters: @@ -86,11 +91,10 @@ public final class RequestCredential: NSObject, NSCoding { /// - password: The password of the authorization object public init(username: String, password: String) { super.init() - credential = URLCredential(user: username, password: password, persistence: .none) self.username = username self.password = password } - + /// Initialises a new OAuth2 credential with given parameters /// /// - Parameters: @@ -99,14 +103,14 @@ public final class RequestCredential: NSObject, NSCoding { /// - expiryDate: The date upon which the credential will expire for the user. /// - tokenType: The token type of the credential (Defaults to Bearer) public init(authorizationToken: String, refreshToken: String?, expiryDate: Date, tokenType: String = "Bearer") { - + self.refreshToken = refreshToken self.expirationDate = expiryDate self.authorizationToken = authorizationToken self.tokenType = tokenType super.init() } - + /// Creates a new auth token based credential /// /// - Parameter authorizationToken: The authorization token to use @@ -114,35 +118,42 @@ public final class RequestCredential: NSObject, NSCoding { super.init() self.authorizationToken = authorizationToken } - + private enum CodingKeys: String { case username case password case authToken = "authtoken" - case credential case tokenType = "tokentype" case expiration case refreshToken = "refreshtoken" } - + public func encode(with aCoder: NSCoder) { aCoder.encode(username, forKey: CodingKeys.username.rawValue) aCoder.encode(password, forKey: CodingKeys.password.rawValue) aCoder.encode(authorizationToken, forKey: CodingKeys.authToken.rawValue) - aCoder.encode(credential, forKey: CodingKeys.credential.rawValue) aCoder.encode(tokenType, forKey: CodingKeys.tokenType.rawValue) aCoder.encode(expirationDate, forKey: CodingKeys.expiration.rawValue) aCoder.encode(refreshToken, forKey: CodingKeys.refreshToken.rawValue) } - + required public init?(coder aDecoder: NSCoder) { super.init() username = aDecoder.decodeObject(forKey: CodingKeys.username.rawValue) as? String password = aDecoder.decodeObject(forKey: CodingKeys.password.rawValue) as? String authorizationToken = aDecoder.decodeObject(forKey: CodingKeys.authToken.rawValue) as? String - credential = aDecoder.decodeObject(forKey: CodingKeys.credential.rawValue) as? URLCredential tokenType = aDecoder.decodeObject(forKey: CodingKeys.tokenType.rawValue) as? String ?? Authentication.TokenType.bearer refreshToken = aDecoder.decodeObject(forKey: CodingKeys.refreshToken.rawValue) as? String expirationDate = aDecoder.decodeObject(forKey: CodingKeys.expiration.rawValue) as? Date } + + // MARK: - NSSecureCoding + + public static var supportsSecureCoding: Bool { + return true + } +} + +enum RequestCredentialError: Error { + case invalidType } From 2fc6991131a994388647c1665f4a28b6dad1ff7d Mon Sep 17 00:00:00 2001 From: Ben Shutt Date: Tue, 19 Apr 2022 14:58:11 +0100 Subject: [PATCH 6/6] Also encode `NSDate` in `RequestCredential` --- ThunderRequest/RequestCredential.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ThunderRequest/RequestCredential.swift b/ThunderRequest/RequestCredential.swift index 7d4bd06..b0a4156 100644 --- a/ThunderRequest/RequestCredential.swift +++ b/ThunderRequest/RequestCredential.swift @@ -52,8 +52,9 @@ public final class RequestCredential: NSObject, NSSecureCoding { /// /// - Parameter keychainData: The data which was retrieved from the keychain init(keychainData: Data) throws { + // Root object RequestCredential and other encoded types let requestCredential = try NSKeyedUnarchiver.unarchivedObject( - ofClasses: [RequestCredential.self, NSString.self], + ofClasses: [RequestCredential.self, NSString.self, NSDate.self], from: keychainData )