From cd73dbf20861b0877abb415c53a32c86b5ab3642 Mon Sep 17 00:00:00 2001 From: Jon Shier Date: Mon, 5 Jun 2023 10:51:35 -0400 Subject: [PATCH 01/19] Add newer platforms, fix build. --- .github/workflows/ci.yml | 33 ++++++++++--- Scripts/build.swift | 46 ++++++++++++++----- .../LegacyValet/VALLegacySecureEnclaveValet.m | 3 ++ ...t watchOS Test Host App Extension.xcscheme | 25 +++------- .../Valet watchOS Test Host App.xcscheme | 25 +++------- 5 files changed, 77 insertions(+), 55 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 30539ab6..9d9491e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: fail-fast: false steps: - name: Checkout Repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Bundle Install run: bundle install - name: Select Xcode Version @@ -42,7 +42,7 @@ jobs: fail-fast: false steps: - name: Checkout Repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Bundle Install run: bundle install - name: Select Xcode Version @@ -52,12 +52,33 @@ jobs: - name: Upload Coverage Reports if: success() run: Scripts/upload-coverage-reports.sh ${{ matrix.platforms }} + xcode-build-14: + name: Xcode 14 Build + runs-on: macOS-13 + strategy: + matrix: + platforms: [ + 'iOS_16,tvOS_16,watchOS_9', + ] + fail-fast: false + steps: + - name: Checkout Repo + uses: actions/checkout@v3 + - name: Bundle Install + run: bundle install + - name: Select Xcode Version + run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app/Contents/Developer + - name: Build and Test Framework + run: Scripts/build.swift ${{ matrix.platforms }} xcode + - name: Upload Coverage Reports + if: success() + run: Scripts/upload-coverage-reports.sh ${{ matrix.platforms }} pod-lint: name: Pod Lint runs-on: macOS-11 steps: - name: Checkout Repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Bundle Install run: bundle install - name: Select Xcode Version @@ -69,7 +90,7 @@ jobs: runs-on: macOS-11 steps: - name: Checkout Repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Bundle Install run: bundle install - name: Select Xcode Version @@ -92,7 +113,7 @@ jobs: fail-fast: false steps: - name: Checkout Repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Bundle Install run: bundle install - name: Select Xcode Version @@ -123,7 +144,7 @@ jobs: fail-fast: false steps: - name: Checkout Repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Bundle Install run: bundle install - name: Select Xcode Version diff --git a/Scripts/build.swift b/Scripts/build.swift index 252872c3..4d742997 100755 --- a/Scripts/build.swift +++ b/Scripts/build.swift @@ -24,15 +24,19 @@ enum Platform: String, CustomStringConvertible { case iOS_13 case iOS_14 case iOS_15 + case iOS_16 case tvOS_13 case tvOS_14 case tvOS_15 + case tvOS_16 case macOS_10_15 case macOS_11 case macOS_12 + case macOS_13 case watchOS_6 case watchOS_7 case watchOS_8 + case watchOS_9 var destination: String { switch self { @@ -42,6 +46,8 @@ enum Platform: String, CustomStringConvertible { return "platform=iOS Simulator,OS=14.4,name=iPad Pro (12.9-inch) (4th generation)" case .iOS_15: return "platform=iOS Simulator,OS=15.5,name=iPad Pro (12.9-inch) (5th generation)" + case .iOS_16: + return "platform=iOS Simulator,OS=16.4,name=iPad Pro (12.9-inch) (6th generation)" case .tvOS_13: return "platform=tvOS Simulator,OS=13.4,name=Apple TV" @@ -49,10 +55,13 @@ enum Platform: String, CustomStringConvertible { return "platform=tvOS Simulator,OS=14.3,name=Apple TV" case .tvOS_15: return "platform=tvOS Simulator,OS=15.4,name=Apple TV" + case .tvOS_16: + return "platform=tvOS Simulator,OS=16.4,name=Apple TV" case .macOS_10_15, .macOS_11, - .macOS_12: + .macOS_12, + .macOS_13: return "platform=OS X" case .watchOS_6: @@ -61,6 +70,8 @@ enum Platform: String, CustomStringConvertible { return "OS=7.2,name=Apple Watch Series 6 - 44mm" case .watchOS_8: return "OS=8.5,name=Apple Watch Series 6 - 44mm" + case .watchOS_9: + return "OS=9.4,name=Apple Watch Series 6 - 44mm" } } @@ -68,12 +79,14 @@ enum Platform: String, CustomStringConvertible { switch self { case .iOS_13, .iOS_14, - .iOS_15: + .iOS_15, + .iOS_16: return "iphonesimulator" case .tvOS_13, .tvOS_14, - .tvOS_15: + .tvOS_15, + .tvOS_16: return "appletvsimulator" case .macOS_10_15: @@ -82,10 +95,13 @@ enum Platform: String, CustomStringConvertible { return "macosx11.1" case .macOS_12: return "macosx12.3" + case .macOS_13: + return "macosx13.3" case .watchOS_6, .watchOS_7, - .watchOS_8: + .watchOS_8, + .watchOS_9: return "watchsimulator" } } @@ -95,17 +111,21 @@ enum Platform: String, CustomStringConvertible { case .iOS_13, .iOS_14, .iOS_15, + .iOS_16, .tvOS_13, .tvOS_14, .tvOS_15, + .tvOS_16, .macOS_10_15, .macOS_11, - .macOS_12: + .macOS_12, + .macOS_13: return true case .watchOS_6, .watchOS_7, - .watchOS_8: + .watchOS_8, + .watchOS_9: // watchOS does not support unit testing (yet?). return false } @@ -119,22 +139,26 @@ enum Platform: String, CustomStringConvertible { switch self { case .iOS_13, .iOS_14, - .iOS_15: + .iOS_15, + .iOS_16: return "Valet iOS" case .tvOS_13, .tvOS_14, - .tvOS_15: + .tvOS_15, + .tvOS_16: return "Valet tvOS" case .macOS_10_15, .macOS_11, - .macOS_12: + .macOS_12, + .macOS_13: return "Valet Mac" case .watchOS_6, .watchOS_7, - .watchOS_8: + .watchOS_8, + .watchOS_9: return "Valet watchOS" } } @@ -203,7 +227,7 @@ enum Task: String, CustomStringConvertible { func shouldTest(on platform: Platform) -> Bool { switch self { case .spm: - // Our Package isn't set up with unit test targets, becuase SPM can't run unit tests in a codesigned environment. + // Our Package isn't set up with unit test targets, because SPM can't run unit tests in a codesigned environment. return false case .xcode: return platform.shouldTest diff --git a/Sources/LegacyValet/VALLegacySecureEnclaveValet.m b/Sources/LegacyValet/VALLegacySecureEnclaveValet.m index 6a8cbe8f..5360f025 100644 --- a/Sources/LegacyValet/VALLegacySecureEnclaveValet.m +++ b/Sources/LegacyValet/VALLegacySecureEnclaveValet.m @@ -264,6 +264,8 @@ - (BOOL)containsObjectForKey:(nonnull NSString *)key; return keyAlreadyInKeychain; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreturn-type" - (nonnull NSSet *)allKeys; { VALCheckCondition(NO, [NSSet new], @"%s is not supported on %@", __PRETTY_FUNCTION__, NSStringFromClass([self class])); @@ -273,6 +275,7 @@ - (BOOL)removeAllObjects; { VALCheckCondition(NO, NO, @"%s is not supported on %@", __PRETTY_FUNCTION__, NSStringFromClass([self class])); } +#pragma clang diagnostic pop - (nullable NSError *)migrateObjectsMatchingQuery:(nonnull NSDictionary *)secItemQuery removeOnCompletion:(BOOL)remove; { diff --git a/Valet.xcodeproj/xcshareddata/xcschemes/Valet watchOS Test Host App Extension.xcscheme b/Valet.xcodeproj/xcshareddata/xcschemes/Valet watchOS Test Host App Extension.xcscheme index a658d37b..07c9e8e5 100644 --- a/Valet.xcodeproj/xcshareddata/xcschemes/Valet watchOS Test Host App Extension.xcscheme +++ b/Valet.xcodeproj/xcshareddata/xcschemes/Valet watchOS Test Host App Extension.xcscheme @@ -77,10 +77,8 @@ debugDocumentVersioning = "YES" debugServiceExtension = "internal" allowLocationSimulation = "YES"> - + - + - + - - - - - + diff --git a/Valet.xcodeproj/xcshareddata/xcschemes/Valet watchOS Test Host App.xcscheme b/Valet.xcodeproj/xcshareddata/xcschemes/Valet watchOS Test Host App.xcscheme index 2da03019..2c0f9743 100644 --- a/Valet.xcodeproj/xcshareddata/xcschemes/Valet watchOS Test Host App.xcscheme +++ b/Valet.xcodeproj/xcshareddata/xcschemes/Valet watchOS Test Host App.xcscheme @@ -63,10 +63,8 @@ debugDocumentVersioning = "YES" debugServiceExtension = "internal" allowLocationSimulation = "YES"> - + - + - + - - - - - + From 0b358f8ebef6e6e14638ab0b72085bcff7785296 Mon Sep 17 00:00:00 2001 From: Jon Shier Date: Mon, 5 Jun 2023 12:57:01 -0400 Subject: [PATCH 02/19] Fix passcode test. --- Tests/ValetIntegrationTests/ValetIntegrationTests.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tests/ValetIntegrationTests/ValetIntegrationTests.swift b/Tests/ValetIntegrationTests/ValetIntegrationTests.swift index 06160d49..365989b3 100644 --- a/Tests/ValetIntegrationTests/ValetIntegrationTests.swift +++ b/Tests/ValetIntegrationTests/ValetIntegrationTests.swift @@ -42,6 +42,8 @@ func testEnvironmentSupportsWhenPasscodeSet() -> Bool { || simulatorVersionInfo.contains("tvOS 13") || simulatorVersionInfo.contains("iOS 15") || simulatorVersionInfo.contains("tvOS 15") + || simulatorVersionInfo.contains("iOS 16") + || simulatorVersionInfo.contains("tvOS 16") { // iOS 13, tvOS 13, iOS 15, and tvOS 15 simulators fail to store items in a Valet that has a // kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly flag. The documentation for this flag says: From 756eb170510ae42c73758f09e03f6fa9503002c6 Mon Sep 17 00:00:00 2001 From: Jon Shier Date: Tue, 6 Jun 2023 15:09:56 -0400 Subject: [PATCH 03/19] New OS versions. --- Scripts/build.swift | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/Scripts/build.swift b/Scripts/build.swift index 4d742997..8e43c1db 100755 --- a/Scripts/build.swift +++ b/Scripts/build.swift @@ -25,18 +25,22 @@ enum Platform: String, CustomStringConvertible { case iOS_14 case iOS_15 case iOS_16 + case iOS_17 case tvOS_13 case tvOS_14 case tvOS_15 case tvOS_16 + case tvOS_17 case macOS_10_15 case macOS_11 case macOS_12 case macOS_13 + case macOS_14 case watchOS_6 case watchOS_7 case watchOS_8 case watchOS_9 + case watchOS_10 var destination: String { switch self { @@ -48,6 +52,8 @@ enum Platform: String, CustomStringConvertible { return "platform=iOS Simulator,OS=15.5,name=iPad Pro (12.9-inch) (5th generation)" case .iOS_16: return "platform=iOS Simulator,OS=16.4,name=iPad Pro (12.9-inch) (6th generation)" + case .iOS_17: + return "platform=iOS Simulator,OS=17.0,name=iPad Pro (12.9-inch) (6th generation)" case .tvOS_13: return "platform=tvOS Simulator,OS=13.4,name=Apple TV" @@ -57,11 +63,14 @@ enum Platform: String, CustomStringConvertible { return "platform=tvOS Simulator,OS=15.4,name=Apple TV" case .tvOS_16: return "platform=tvOS Simulator,OS=16.4,name=Apple TV" + case .tvOS_17: + return "platform=tvOS Simulator,OS=17.0,name=Apple TV" case .macOS_10_15, .macOS_11, .macOS_12, - .macOS_13: + .macOS_13, + .macOS_14: return "platform=OS X" case .watchOS_6: @@ -72,6 +81,8 @@ enum Platform: String, CustomStringConvertible { return "OS=8.5,name=Apple Watch Series 6 - 44mm" case .watchOS_9: return "OS=9.4,name=Apple Watch Series 6 - 44mm" + case .watchOS_10: + return "OS=10.0,name=Apple Watch Series 6 - 44mm" } } @@ -80,13 +91,15 @@ enum Platform: String, CustomStringConvertible { case .iOS_13, .iOS_14, .iOS_15, - .iOS_16: + .iOS_16, + .iOS_17: return "iphonesimulator" case .tvOS_13, .tvOS_14, .tvOS_15, - .tvOS_16: + .tvOS_16 + .tvOS_17: return "appletvsimulator" case .macOS_10_15: @@ -97,11 +110,14 @@ enum Platform: String, CustomStringConvertible { return "macosx12.3" case .macOS_13: return "macosx13.3" + case .macOS_14: + return "macosx14.0" case .watchOS_6, .watchOS_7, .watchOS_8, - .watchOS_9: + .watchOS_9, + .watchOS_10: return "watchsimulator" } } @@ -112,20 +128,24 @@ enum Platform: String, CustomStringConvertible { .iOS_14, .iOS_15, .iOS_16, + .iOS_17, .tvOS_13, .tvOS_14, .tvOS_15, .tvOS_16, + .tvOS_17, .macOS_10_15, .macOS_11, .macOS_12, - .macOS_13: + .macOS_13, + .macOS_14: return true case .watchOS_6, .watchOS_7, .watchOS_8, - .watchOS_9: + .watchOS_9, + .watchOS_10: // watchOS does not support unit testing (yet?). return false } @@ -140,25 +160,29 @@ enum Platform: String, CustomStringConvertible { case .iOS_13, .iOS_14, .iOS_15, - .iOS_16: + .iOS_16, + .iOS_17: return "Valet iOS" case .tvOS_13, .tvOS_14, .tvOS_15, - .tvOS_16: + .tvOS_16, + .tvOS_17: return "Valet tvOS" case .macOS_10_15, .macOS_11, .macOS_12, - .macOS_13: + .macOS_13, + .macOS_14: return "Valet Mac" case .watchOS_6, .watchOS_7, .watchOS_8, - .watchOS_9: + .watchOS_9, + .watchOS_10: return "Valet watchOS" } } From 168a9752667fafed661f2557b79ef7c2e34e4d3c Mon Sep 17 00:00:00 2001 From: Jon Shier Date: Tue, 6 Jun 2023 15:21:59 -0400 Subject: [PATCH 04/19] Update condition to skip tests on newer sims. --- .../ValetIntegrationTests.swift | 10 ++++++- .../xcshareddata/xcschemes/Valet iOS.xcscheme | 26 ++++++++----------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Tests/ValetIntegrationTests/ValetIntegrationTests.swift b/Tests/ValetIntegrationTests/ValetIntegrationTests.swift index 365989b3..ba83ca62 100644 --- a/Tests/ValetIntegrationTests/ValetIntegrationTests.swift +++ b/Tests/ValetIntegrationTests/ValetIntegrationTests.swift @@ -24,6 +24,12 @@ import XCTest /// - The Valet Mac Tests target is left without a host app on master. Mac test host app signing requires CI to have the Developer team credentials down in keychain, which we can't easily accomplish. /// - Note: In order to test changes locally, set the Valet Mac Tests host to Valet macOS Test Host App, delete all VAL_* keychain items in your keychain via Keychain Access.app, and run Mac tests. func testEnvironmentIsSigned() -> Bool { + #if targetEnvironment(simulator) + if #available(iOS 16, tvOS 16, macOS 13, watchOS 9, *) { + return false + } + #endif + // Our test host appsĀ for iOS and Mac are both signed, so testing for a custom bundle identifier is analogous to testing signing. guard Bundle.main.bundleIdentifier != nil && Bundle.main.bundleIdentifier != "com.apple.dt.xctest.tool" else { #if os(iOS) || os(tvOS) @@ -44,8 +50,10 @@ func testEnvironmentSupportsWhenPasscodeSet() -> Bool { || simulatorVersionInfo.contains("tvOS 15") || simulatorVersionInfo.contains("iOS 16") || simulatorVersionInfo.contains("tvOS 16") + || simulatorVersionInfo.contains("iOS 17") + || simulatorVersionInfo.contains("tvOS 17") { - // iOS 13, tvOS 13, iOS 15, and tvOS 15 simulators fail to store items in a Valet that has a + // iOS 13, tvOS 13, iOS 15, tvOS 15, and later simulators fail to store items in a Valet that has a // kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly flag. The documentation for this flag says: // "No items can be stored in this class on devices without a passcode". I currently do not // understand why prior simulators work with this flag, given that no simulators have a passcode. diff --git a/Valet.xcodeproj/xcshareddata/xcschemes/Valet iOS.xcscheme b/Valet.xcodeproj/xcshareddata/xcschemes/Valet iOS.xcscheme index 58e8b4e1..55ea7382 100644 --- a/Valet.xcodeproj/xcshareddata/xcschemes/Valet iOS.xcscheme +++ b/Valet.xcodeproj/xcshareddata/xcschemes/Valet iOS.xcscheme @@ -26,8 +26,17 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - codeCoverageEnabled = "YES" - shouldUseLaunchSchemeArgsEnv = "YES"> + shouldUseLaunchSchemeArgsEnv = "YES" + codeCoverageEnabled = "YES"> + + + + @@ -40,17 +49,6 @@ - - - - - - - - Date: Tue, 6 Jun 2023 15:34:49 -0400 Subject: [PATCH 05/19] Missing , --- Scripts/build.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/build.swift b/Scripts/build.swift index 8e43c1db..a212dbe9 100755 --- a/Scripts/build.swift +++ b/Scripts/build.swift @@ -98,7 +98,7 @@ enum Platform: String, CustomStringConvertible { case .tvOS_13, .tvOS_14, .tvOS_15, - .tvOS_16 + .tvOS_16, .tvOS_17: return "appletvsimulator" From 1807c4f73890cd00442bbc1fdfd05947de369a93 Mon Sep 17 00:00:00 2001 From: Jon Shier Date: Tue, 6 Jun 2023 17:56:03 -0400 Subject: [PATCH 06/19] Add macOS 13 SPM testing. --- .github/workflows/ci.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d9491e6..a9ce87ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,10 @@ on: - master pull_request: +concurrency: + group: ${{ github.ref_name }} + cancel-in-progress: true + jobs: xcode-build-12: name: Xcode 12 Build @@ -153,3 +157,24 @@ jobs: run: Scripts/github/prepare-simulators.sh ${{ matrix.platforms }} - name: Build Framework run: Scripts/build.swift ${{ matrix.platforms }} spm + spm-13: + name: SPM Build macOS 13 + runs-on: macOS-13 + strategy: + matrix: + platforms: [ + 'iOS_16,tvOS_16,watchOS_9', + 'macOS_13', + ] + fail-fast: false + steps: + - name: Checkout Repo + uses: actions/checkout@v3 + - name: Bundle Install + run: bundle install + - name: Select Xcode Version + run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app/Contents/Developer + - name: Prepare Simulator Runtimes + run: Scripts/github/prepare-simulators.sh ${{ matrix.platforms }} + - name: Build Framework + run: Scripts/build.swift ${{ matrix.platforms }} spm From dabeea521f192548f39bdb031a4258a968f97016 Mon Sep 17 00:00:00 2001 From: Jon Shier Date: Wed, 7 Jun 2023 13:50:03 -0400 Subject: [PATCH 07/19] Fix Xcode version selection, add timeout. --- .github/workflows/ci.yml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9ce87ea..9ce0d37e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,7 @@ jobs: 'iOS_13,tvOS_13,watchOS_6', ] fail-fast: false + timeout-minutes: 30 steps: - name: Checkout Repo uses: actions/checkout@v3 @@ -44,6 +45,7 @@ jobs: 'iOS_15,tvOS_15,watchOS_8', ] fail-fast: false + timeout-minutes: 30 steps: - name: Checkout Repo uses: actions/checkout@v3 @@ -65,13 +67,14 @@ jobs: 'iOS_16,tvOS_16,watchOS_9', ] fail-fast: false + timeout-minutes: 30 steps: - name: Checkout Repo uses: actions/checkout@v3 - name: Bundle Install run: bundle install - name: Select Xcode Version - run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app/Contents/Developer + run: sudo xcode-select --switch /Applications/Xcode_14.3.app/Contents/Developer - name: Build and Test Framework run: Scripts/build.swift ${{ matrix.platforms }} xcode - name: Upload Coverage Reports @@ -79,26 +82,28 @@ jobs: run: Scripts/upload-coverage-reports.sh ${{ matrix.platforms }} pod-lint: name: Pod Lint - runs-on: macOS-11 + runs-on: macOS-13 + timeout-minutes: 30 steps: - name: Checkout Repo uses: actions/checkout@v3 - name: Bundle Install run: bundle install - name: Select Xcode Version - run: sudo xcode-select --switch /Applications/Xcode_11.7.app/Contents/Developer + run: sudo xcode-select --switch /Applications/Xcode_14.3.app/Contents/Developer - name: Lint Podspec run: bundle exec pod lib lint --verbose --fail-fast --swift-version=5.0 carthage: name: Carthage - runs-on: macOS-11 + runs-on: macOS-13 + timeout-minutes: 30 steps: - name: Checkout Repo uses: actions/checkout@v3 - name: Bundle Install run: bundle install - name: Select Xcode Version - run: sudo xcode-select --switch /Applications/Xcode_11.7.app/Contents/Developer + run: sudo xcode-select --switch /Applications/Xcode_14.3.app/Contents/Developer - name: Install Carthage run: brew outdated carthage || brew upgrade carthage - name: Build Framework @@ -106,6 +111,7 @@ jobs: spm-11: name: SPM Build macOS 11 runs-on: macOS-11 + timeout-minutes: 30 strategy: matrix: platforms: [ @@ -146,6 +152,7 @@ jobs: 'macOS_12', ] fail-fast: false + timeout-minutes: 30 steps: - name: Checkout Repo uses: actions/checkout@v3 @@ -167,13 +174,14 @@ jobs: 'macOS_13', ] fail-fast: false + timeout-minutes: 30 steps: - name: Checkout Repo uses: actions/checkout@v3 - name: Bundle Install run: bundle install - name: Select Xcode Version - run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app/Contents/Developer + run: sudo xcode-select --switch /Applications/Xcode_14.3.app/Contents/Developer - name: Prepare Simulator Runtimes run: Scripts/github/prepare-simulators.sh ${{ matrix.platforms }} - name: Build Framework From 3e225382fee618f35e3898da2b9e777bcc63e856 Mon Sep 17 00:00:00 2001 From: Jon Shier Date: Wed, 7 Jun 2023 13:50:18 -0400 Subject: [PATCH 08/19] Update test environment condition. --- ...reEnclaveBackwardsCompatibilityTests.swift | 2 +- ...reEnclaveBackwardsCompatibilityTests.swift | 2 +- ...ronizableBackwardsCompatibilityTests.swift | 4 +- .../ValetBackwardsCompatibilityTests.swift | 6 +-- .../CloudIntegrationTests.swift | 4 +- .../KeychainIntegrationTests.swift | 2 +- Tests/ValetIntegrationTests/MacTests.swift | 6 +-- .../SecureEnclaveIntegrationTests.swift | 18 +++---- ...ePromptSecureEnclaveIntegrationTests.swift | 22 ++++---- .../ValetIntegrationTests.swift | 50 +++++++++---------- 10 files changed, 58 insertions(+), 58 deletions(-) diff --git a/Tests/ValetIntegrationTests/BackwardsCompatibilityTests/SecureEnclaveBackwardsCompatibilityTests.swift b/Tests/ValetIntegrationTests/BackwardsCompatibilityTests/SecureEnclaveBackwardsCompatibilityTests.swift index 8abd35ef..5f428b36 100644 --- a/Tests/ValetIntegrationTests/BackwardsCompatibilityTests/SecureEnclaveBackwardsCompatibilityTests.swift +++ b/Tests/ValetIntegrationTests/BackwardsCompatibilityTests/SecureEnclaveBackwardsCompatibilityTests.swift @@ -25,7 +25,7 @@ extension SecureEnclaveIntegrationTests { @available (*, deprecated) func test_backwardsCompatibility_withLegacyValet() throws { - guard testEnvironmentIsSigned() && testEnvironmentSupportsWhenPasscodeSet() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() && testEnvironmentSupportsWhenPasscodeSet() else { return } diff --git a/Tests/ValetIntegrationTests/BackwardsCompatibilityTests/SinglePromptSecureEnclaveBackwardsCompatibilityTests.swift b/Tests/ValetIntegrationTests/BackwardsCompatibilityTests/SinglePromptSecureEnclaveBackwardsCompatibilityTests.swift index 3d86d835..8d394e69 100644 --- a/Tests/ValetIntegrationTests/BackwardsCompatibilityTests/SinglePromptSecureEnclaveBackwardsCompatibilityTests.swift +++ b/Tests/ValetIntegrationTests/BackwardsCompatibilityTests/SinglePromptSecureEnclaveBackwardsCompatibilityTests.swift @@ -26,7 +26,7 @@ extension SinglePromptSecureEnclaveIntegrationTests { @available (*, deprecated) func test_backwardsCompatibility_withLegacyValet() throws { - guard testEnvironmentIsSigned() && testEnvironmentSupportsWhenPasscodeSet() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() && testEnvironmentSupportsWhenPasscodeSet() else { return } diff --git a/Tests/ValetIntegrationTests/BackwardsCompatibilityTests/SynchronizableBackwardsCompatibilityTests.swift b/Tests/ValetIntegrationTests/BackwardsCompatibilityTests/SynchronizableBackwardsCompatibilityTests.swift index f5da7720..0408ef0a 100644 --- a/Tests/ValetIntegrationTests/BackwardsCompatibilityTests/SynchronizableBackwardsCompatibilityTests.swift +++ b/Tests/ValetIntegrationTests/BackwardsCompatibilityTests/SynchronizableBackwardsCompatibilityTests.swift @@ -25,7 +25,7 @@ extension CloudIntegrationTests { // MARK: Backwards Compatibility func test_backwardsCompatibility_withLegacyValet() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -39,7 +39,7 @@ extension CloudIntegrationTests { } func test_backwardsCompatibility_withSharedAccessGroupLegacyValet() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } diff --git a/Tests/ValetIntegrationTests/BackwardsCompatibilityTests/ValetBackwardsCompatibilityTests.swift b/Tests/ValetIntegrationTests/BackwardsCompatibilityTests/ValetBackwardsCompatibilityTests.swift index 62d36357..d5f8e44b 100644 --- a/Tests/ValetIntegrationTests/BackwardsCompatibilityTests/ValetBackwardsCompatibilityTests.swift +++ b/Tests/ValetIntegrationTests/BackwardsCompatibilityTests/ValetBackwardsCompatibilityTests.swift @@ -130,7 +130,7 @@ class ValetBackwardsCompatibilityIntegrationTests: ValetIntegrationTests { } func test_backwardsCompatibility_withLegacySharedAccessGroupValet() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } try Valet.currentAndLegacyPermutations(with: Valet.sharedAccessGroupIdentifier).forEach { permutation, legacyValet in @@ -165,7 +165,7 @@ class ValetBackwardsCompatibilityIntegrationTests: ValetIntegrationTests { } func test_migrateObjectsFromAlwaysAccessibleValet_forwardsCompatibility_withLegacySharedAccessGroupValet() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } let alwaysAccessibleLegacyValet = VALLegacyValet(sharedAccessGroupIdentifier: Valet.sharedAccessGroupIdentifier.groupIdentifier, accessibility: .always)! @@ -177,7 +177,7 @@ class ValetBackwardsCompatibilityIntegrationTests: ValetIntegrationTests { } func test_migrateObjectsFromAlwaysAccessibleThisDeviceOnlyValet_forwardsCompatibility_withLegacySharedAccessGroupValet() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } let alwaysAccessibleLegacyValet = VALLegacyValet(sharedAccessGroupIdentifier: Valet.sharedAccessGroupIdentifier.groupIdentifier, accessibility: .alwaysThisDeviceOnly)! diff --git a/Tests/ValetIntegrationTests/CloudIntegrationTests.swift b/Tests/ValetIntegrationTests/CloudIntegrationTests.swift index ac5b0e2d..6db403c7 100644 --- a/Tests/ValetIntegrationTests/CloudIntegrationTests.swift +++ b/Tests/ValetIntegrationTests/CloudIntegrationTests.swift @@ -25,7 +25,7 @@ class CloudIntegrationTests: XCTestCase static let identifier = Valet.sharedAccessGroupIdentifier static let accessibility = CloudAccessibility.whenUnlocked var allPermutations: [Valet] { - return (testEnvironmentIsSigned() + return (testEnvironmentIsSignedOrDoesNotRequireEntitlement() ? Valet.iCloudPermutations(with: CloudIntegrationTests.identifier.asIdentifier) + Valet.iCloudPermutations(with: CloudIntegrationTests.identifier) : []) } @@ -47,7 +47,7 @@ class CloudIntegrationTests: XCTestCase func test_synchronizableValet_isDistinctFromVanillaValetWithEqualConfiguration() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } diff --git a/Tests/ValetIntegrationTests/KeychainIntegrationTests.swift b/Tests/ValetIntegrationTests/KeychainIntegrationTests.swift index 4af7cd5a..1476a316 100644 --- a/Tests/ValetIntegrationTests/KeychainIntegrationTests.swift +++ b/Tests/ValetIntegrationTests/KeychainIntegrationTests.swift @@ -23,7 +23,7 @@ import XCTest final class KeychainIntegrationTests: XCTestCase { func test_revertMigration_removesAllMigratedKeys() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } diff --git a/Tests/ValetIntegrationTests/MacTests.swift b/Tests/ValetIntegrationTests/MacTests.swift index c6b742d8..307cbc81 100644 --- a/Tests/ValetIntegrationTests/MacTests.swift +++ b/Tests/ValetIntegrationTests/MacTests.swift @@ -110,7 +110,7 @@ class ValetMacTests: XCTestCase XCTAssertEqual($0.baseKeychainQuery[kSecAttrService as String], explicitlySetIdentifier.description) } - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -124,7 +124,7 @@ class ValetMacTests: XCTestCase } func test_withExplicitlySet_canAccessKeychain() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -156,7 +156,7 @@ class ValetMacTests: XCTestCase } func test_withExplicitlySet_canReadWrittenString() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } diff --git a/Tests/ValetIntegrationTests/SecureEnclaveIntegrationTests.swift b/Tests/ValetIntegrationTests/SecureEnclaveIntegrationTests.swift index 43df0c37..a13653b5 100644 --- a/Tests/ValetIntegrationTests/SecureEnclaveIntegrationTests.swift +++ b/Tests/ValetIntegrationTests/SecureEnclaveIntegrationTests.swift @@ -31,7 +31,7 @@ class SecureEnclaveIntegrationTests: XCTestCase { super.setUp() - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } do { @@ -45,7 +45,7 @@ class SecureEnclaveIntegrationTests: XCTestCase func test_secureEnclaveValetsWithEqualConfiguration_canAccessSameData() throws { - guard testEnvironmentIsSigned() && testEnvironmentSupportsWhenPasscodeSet() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() && testEnvironmentSupportsWhenPasscodeSet() else { return } @@ -57,7 +57,7 @@ class SecureEnclaveIntegrationTests: XCTestCase func test_secureEnclaveValetsWithDifferingAccessControl_canNotAccessSameData() throws { - guard testEnvironmentIsSigned() && testEnvironmentSupportsWhenPasscodeSet() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() && testEnvironmentSupportsWhenPasscodeSet() else { return } @@ -74,7 +74,7 @@ class SecureEnclaveIntegrationTests: XCTestCase func test_canAccessKeychain() { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -88,7 +88,7 @@ class SecureEnclaveIntegrationTests: XCTestCase } func test_canAccessKeychain_sharedAccessGroup() { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -104,7 +104,7 @@ class SecureEnclaveIntegrationTests: XCTestCase #if !os(macOS) // We can't test app groups on macOS without a paid developer account, which we don't have. func test_canAccessKeychain_sharedAppGroup() { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -122,7 +122,7 @@ class SecureEnclaveIntegrationTests: XCTestCase func test_migrateObjectsMatchingQuery_failsForBadQuery() { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -137,7 +137,7 @@ class SecureEnclaveIntegrationTests: XCTestCase func test_migrateObjectsFromValet_migratesSuccessfullyToSecureEnclave() throws { - guard testEnvironmentIsSigned() && testEnvironmentSupportsWhenPasscodeSet() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() && testEnvironmentSupportsWhenPasscodeSet() else { return } @@ -175,7 +175,7 @@ class SecureEnclaveIntegrationTests: XCTestCase } func test_migrateObjectsFromValet_migratesSuccessfullyAfterCanAccessKeychainCalls() throws { - guard testEnvironmentIsSigned() && testEnvironmentSupportsWhenPasscodeSet() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() && testEnvironmentSupportsWhenPasscodeSet() else { return } diff --git a/Tests/ValetIntegrationTests/SinglePromptSecureEnclaveIntegrationTests.swift b/Tests/ValetIntegrationTests/SinglePromptSecureEnclaveIntegrationTests.swift index 7c62ab01..118fe1d0 100644 --- a/Tests/ValetIntegrationTests/SinglePromptSecureEnclaveIntegrationTests.swift +++ b/Tests/ValetIntegrationTests/SinglePromptSecureEnclaveIntegrationTests.swift @@ -35,7 +35,7 @@ class SinglePromptSecureEnclaveIntegrationTests: XCTestCase { super.setUp() - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } do { @@ -49,7 +49,7 @@ class SinglePromptSecureEnclaveIntegrationTests: XCTestCase func test_SinglePromptSecureEnclaveValetsWithEqualConfiguration_canAccessSameData() throws { - guard testEnvironmentIsSigned() && testEnvironmentSupportsWhenPasscodeSet() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() && testEnvironmentSupportsWhenPasscodeSet() else { return } @@ -61,7 +61,7 @@ class SinglePromptSecureEnclaveIntegrationTests: XCTestCase func test_SinglePromptSecureEnclaveValetsWithDifferingAccessControl_canNotAccessSameData() throws { - guard testEnvironmentIsSigned() && testEnvironmentSupportsWhenPasscodeSet() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() && testEnvironmentSupportsWhenPasscodeSet() else { return } @@ -78,7 +78,7 @@ class SinglePromptSecureEnclaveIntegrationTests: XCTestCase func test_allKeys() throws { - guard testEnvironmentIsSigned() && testEnvironmentSupportsWhenPasscodeSet() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() && testEnvironmentSupportsWhenPasscodeSet() else { return } @@ -95,7 +95,7 @@ class SinglePromptSecureEnclaveIntegrationTests: XCTestCase } func test_allKeys_doesNotReflectValetImplementationDetails() throws { - guard testEnvironmentIsSigned() && testEnvironmentSupportsWhenPasscodeSet() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() && testEnvironmentSupportsWhenPasscodeSet() else { return } @@ -108,7 +108,7 @@ class SinglePromptSecureEnclaveIntegrationTests: XCTestCase func test_canAccessKeychain() { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -122,7 +122,7 @@ class SinglePromptSecureEnclaveIntegrationTests: XCTestCase } func test_canAccessKeychain_sharedAccessGroup() { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -138,7 +138,7 @@ class SinglePromptSecureEnclaveIntegrationTests: XCTestCase #if !os(macOS) // We can't test app groups on macOS without a paid developer account, which we don't have. func test_canAccessKeychain_sharedAppGroup() { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -156,7 +156,7 @@ class SinglePromptSecureEnclaveIntegrationTests: XCTestCase func test_migrateObjectsMatchingQuery_failsForBadQuery() { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -171,7 +171,7 @@ class SinglePromptSecureEnclaveIntegrationTests: XCTestCase func test_migrateObjectsFromValet_migratesSuccessfullyToSecureEnclave() throws { - guard testEnvironmentIsSigned() && testEnvironmentSupportsWhenPasscodeSet() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() && testEnvironmentSupportsWhenPasscodeSet() else { return } @@ -209,7 +209,7 @@ class SinglePromptSecureEnclaveIntegrationTests: XCTestCase } func test_migrateObjectsFromValet_migratesSuccessfullyAfterCanAccessKeychainCalls() throws { - guard testEnvironmentIsSigned() && testEnvironmentSupportsWhenPasscodeSet() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() && testEnvironmentSupportsWhenPasscodeSet() else { return } diff --git a/Tests/ValetIntegrationTests/ValetIntegrationTests.swift b/Tests/ValetIntegrationTests/ValetIntegrationTests.swift index ba83ca62..302dae11 100644 --- a/Tests/ValetIntegrationTests/ValetIntegrationTests.swift +++ b/Tests/ValetIntegrationTests/ValetIntegrationTests.swift @@ -20,10 +20,10 @@ import XCTest @testable import Valet -/// - Returns: `true` when the test environment is signed. +/// - Returns: `true` when the test environment is signed and does not require entitlement. /// - The Valet Mac Tests target is left without a host app on master. Mac test host app signing requires CI to have the Developer team credentials down in keychain, which we can't easily accomplish. /// - Note: In order to test changes locally, set the Valet Mac Tests host to Valet macOS Test Host App, delete all VAL_* keychain items in your keychain via Keychain Access.app, and run Mac tests. -func testEnvironmentIsSigned() -> Bool { +func testEnvironmentIsSignedOrDoesNotRequireEntitlement() -> Bool { #if targetEnvironment(simulator) if #available(iOS 16, tvOS 16, macOS 13, watchOS 9, *) { return false @@ -114,7 +114,7 @@ class ValetIntegrationTests: XCTestCase signedPermutations += Valet.permutations(with: ValetIntegrationTests.sharedAppGroupIdentifier) #endif return Valet.permutations(with: ValetIntegrationTests.sharedAccessGroupIdentifier.asIdentifier) - + (testEnvironmentIsSigned() + + (testEnvironmentIsSignedOrDoesNotRequireEntitlement() ? signedPermutations : []) } @@ -134,7 +134,7 @@ class ValetIntegrationTests: XCTestCase super.setUp() let permutations: [Valet] - if testEnvironmentIsSigned() { + if testEnvironmentIsSignedOrDoesNotRequireEntitlement() { permutations = [vanillaValet, anotherFlavor] + allPermutations } else { permutations = [vanillaValet] + allPermutations @@ -200,7 +200,7 @@ class ValetIntegrationTests: XCTestCase func test_canAccessKeychain_sharedAccessGroup() { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -213,7 +213,7 @@ class ValetIntegrationTests: XCTestCase // We can't test app groups on macOS without a paid developer account, which we don't have. func test_canAccessKeychain_sharedAppGroup() { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -340,7 +340,7 @@ class ValetIntegrationTests: XCTestCase func test_stringForKey_withEquivalentConfigurationButDifferingFlavor_throwsItemNotFound() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -453,7 +453,7 @@ class ValetIntegrationTests: XCTestCase } func test_objectForKey_withEquivalentConfigurationButDifferingFlavor_throwsItemNotFound() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -662,7 +662,7 @@ class ValetIntegrationTests: XCTestCase func test_removeObjectForKey_isDistinctForDifferingClasses() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -681,7 +681,7 @@ class ValetIntegrationTests: XCTestCase func test_migrateObjectsMatching_failsIfQueryHasNoInputClass() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -710,7 +710,7 @@ class ValetIntegrationTests: XCTestCase func test_migrateObjectsMatching_failsIfNoItemsMatchQuery() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -782,7 +782,7 @@ class ValetIntegrationTests: XCTestCase } func test_migrateObjectsMatchingCompactMap_successfullyMigratesTransformedKey() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -805,7 +805,7 @@ class ValetIntegrationTests: XCTestCase } func test_migrateObjectsMatchingCompactMap_successfullyMigratesTransformedValue() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -828,7 +828,7 @@ class ValetIntegrationTests: XCTestCase } func test_migrateObjectsMatchingCompactMap_returningNilDoesNotMigratePair() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -862,7 +862,7 @@ class ValetIntegrationTests: XCTestCase } func test_migrateObjectsMatchingCompactMap_throwingErrorPreventsAllMigration() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -897,7 +897,7 @@ class ValetIntegrationTests: XCTestCase } func test_migrateObjectsMatchingCompactMap_thrownErrorFromCompactMapIsRethrown() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -931,7 +931,7 @@ class ValetIntegrationTests: XCTestCase func test_migrateObjectsFromValet_migratesSingleKeyValuePairSuccessfully() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -943,7 +943,7 @@ class ValetIntegrationTests: XCTestCase func test_migrateObjectsFromValet_migratesMultipleKeyValuePairsSuccessfully() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -971,7 +971,7 @@ class ValetIntegrationTests: XCTestCase func test_migrateObjectsFromValet_removesOnCompletionWhenRequested() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -1001,7 +1001,7 @@ class ValetIntegrationTests: XCTestCase func test_migrateObjectsFromValet_leavesKeychainUntouchedWhenConflictsExist() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -1058,7 +1058,7 @@ class ValetIntegrationTests: XCTestCase } func test_migrateObjectsFromValetCompactMap_successfullyMigratesTransformedKey() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -1078,7 +1078,7 @@ class ValetIntegrationTests: XCTestCase } func test_migrateObjectsFromValetCompactMap_successfullyMigratesTransformedValue() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -1098,7 +1098,7 @@ class ValetIntegrationTests: XCTestCase } func test_migrateObjectsFromValetCompactMap_returningNilDoesNotMigratePair() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -1129,7 +1129,7 @@ class ValetIntegrationTests: XCTestCase } func test_migrateObjectsFromValetCompactMap_throwingErrorPreventsAllMigration() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } @@ -1161,7 +1161,7 @@ class ValetIntegrationTests: XCTestCase } func test_migrateObjectsFromValetCompactMap_thrownErrorFromCompactMapIsRethrown() throws { - guard testEnvironmentIsSigned() else { + guard testEnvironmentIsSignedOrDoesNotRequireEntitlement() else { return } From f68832f7de1d7f3859dab5b1ad479285a3f4f376 Mon Sep 17 00:00:00 2001 From: Jon Shier Date: Wed, 7 Jun 2023 14:57:08 -0400 Subject: [PATCH 09/19] Build xcframework for modern Carthage. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ce0d37e..7ea16468 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,7 +107,7 @@ jobs: - name: Install Carthage run: brew outdated carthage || brew upgrade carthage - name: Build Framework - run: carthage build --verbose --no-skip-current + run: carthage build --verbose --no-skip-current --use-xcframework spm-11: name: SPM Build macOS 11 runs-on: macOS-11 From 4d499ac9e7bdde988cbacf1906f92a6de52c8c0f Mon Sep 17 00:00:00 2001 From: Jon Shier Date: Wed, 7 Jun 2023 15:44:55 -0400 Subject: [PATCH 10/19] Missing s. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ea16468..ee5502d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,7 +107,7 @@ jobs: - name: Install Carthage run: brew outdated carthage || brew upgrade carthage - name: Build Framework - run: carthage build --verbose --no-skip-current --use-xcframework + run: carthage build --verbose --no-skip-current --use-xcframeworks spm-11: name: SPM Build macOS 11 runs-on: macOS-11 From 5d35a3d84276d8a774d3e1d9df1c23ed3dbc8b39 Mon Sep 17 00:00:00 2001 From: Jon Shier Date: Wed, 7 Jun 2023 16:50:29 -0400 Subject: [PATCH 11/19] Mark watchOS availability. --- Sources/Valet/SinglePromptSecureEnclaveValet.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/Valet/SinglePromptSecureEnclaveValet.swift b/Sources/Valet/SinglePromptSecureEnclaveValet.swift index 5b7df38b..fe968f3d 100644 --- a/Sources/Valet/SinglePromptSecureEnclaveValet.swift +++ b/Sources/Valet/SinglePromptSecureEnclaveValet.swift @@ -15,6 +15,7 @@ // // Xcode 13 and prior incorrectly say that LocalAuthentication is available on tvOS, so we have to check both as long as Xcode 13 and prior are supported. +// Xcode 14 moved the LAContext availability to watchOS 3, so only that version is explicitly annotated. #if !os(tvOS) && canImport(LocalAuthentication) import LocalAuthentication @@ -23,6 +24,7 @@ import Foundation /// Reads and writes keychain elements that are stored on the Secure Enclave using Accessibility attribute `.whenPasscodeSetThisDeviceOnly`. The first access of these keychain elements will require the user to confirm their presence via Touch ID, Face ID, or passcode entry. If no passcode is set on the device, accessing the keychain via a `SinglePromptSecureEnclaveValet` will fail. Data is removed from the Secure Enclave when the user removes a passcode from the device. @objc(VALSinglePromptSecureEnclaveValet) +@available(watchOS 3, *) public final class SinglePromptSecureEnclaveValet: NSObject { // MARK: Public Class Methods @@ -277,6 +279,7 @@ public final class SinglePromptSecureEnclaveValet: NSObject { // MARK: - Objective-C Compatibility +@available(watchOS 3, *) extension SinglePromptSecureEnclaveValet { // MARK: Public Class Methods From b93e01d956ff8a140e2311f34c3b5a84468b06de Mon Sep 17 00:00:00 2001 From: Jon Shier Date: Thu, 8 Jun 2023 15:33:40 -0400 Subject: [PATCH 12/19] Exit rather than throwing out. --- Scripts/build.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Scripts/build.swift b/Scripts/build.swift index a212dbe9..978b82dd 100755 --- a/Scripts/build.swift +++ b/Scripts/build.swift @@ -261,14 +261,14 @@ enum Task: String, CustomStringConvertible { guard CommandLine.arguments.count > 2 else { print("Usage: build.swift platforms [spm|xcode]") - throw TaskError.code(1) + exit(0) } let rawPlatforms = CommandLine.arguments[1].components(separatedBy: ",") let rawTask = CommandLine.arguments[2] guard let task = Task(rawValue: rawTask) else { print("Received unknown task \(rawTask)") - throw TaskError.code(1) + exit(0) } if task.shouldGenerateXcodeProject { @@ -279,7 +279,7 @@ if task.shouldGenerateXcodeProject { for rawPlatform in rawPlatforms { guard let platform = Platform(rawValue: rawPlatform) else { print("Received unknown platform type \(rawPlatform)") - throw TaskError.code(1) + exit(0) } var xcodeBuildArguments = [ "-project", task.project, @@ -307,5 +307,9 @@ for rawPlatform in rawPlatforms { xcodeBuildArguments.append("test") } - try execute(commandPath: "/usr/bin/xcodebuild", arguments: xcodeBuildArguments) + do { + try execute(commandPath: "/usr/bin/xcodebuild", arguments: xcodeBuildArguments) + } catch { + print("xcodebuild failed with error: \(error)") + } } From 8b74288de7f07ec0cda4b5c6e091d0f85f407019 Mon Sep 17 00:00:00 2001 From: Jon Shier Date: Thu, 8 Jun 2023 15:47:49 -0400 Subject: [PATCH 13/19] Use Xcode 12.5 for Xcode 12. --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee5502d4..9122284d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: - name: Bundle Install run: bundle install - name: Select Xcode Version - run: sudo xcode-select --switch /Applications/Xcode_12.4.app/Contents/Developer + run: sudo xcode-select --switch /Applications/Xcode_12.5.1.app/Contents/Developer - name: Prepare Simulator Runtimes run: Scripts/github/prepare-simulators.sh ${{ matrix.platforms }} - name: Build and Test Framework @@ -127,13 +127,13 @@ jobs: - name: Bundle Install run: bundle install - name: Select Xcode Version - run: sudo xcode-select --switch /Applications/Xcode_12.4.app/Contents/Developer + run: sudo xcode-select --switch /Applications/Xcode_12.5.1.app/Contents/Developer if: ${{ matrix.platforms == 'iOS_14,tvOS_14,watchOS_7' }} - name: Select Xcode Version - run: sudo xcode-select --switch /Applications/Xcode_12.4.app/Contents/Developer + run: sudo xcode-select --switch /Applications/Xcode_12.5.1.app/Contents/Developer if: ${{ matrix.platforms == 'iOS_13,tvOS_13,watchOS_6' }} - name: Select Xcode Version - run: sudo xcode-select --switch /Applications/Xcode_12.4.app/Contents/Developer + run: sudo xcode-select --switch /Applications/Xcode_12.5.1.app/Contents/Developer if: ${{ matrix.platforms == 'macOS_11' }} - name: Select Xcode Version run: sudo xcode-select --switch /Applications/Xcode_11.7.app/Contents/Developer From df691df74d6bab6d674f76609c5b8a1385ad7cd1 Mon Sep 17 00:00:00 2001 From: Jon Shier Date: Fri, 9 Jun 2023 11:02:59 -0400 Subject: [PATCH 14/19] Remove iOS 13 builds. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9122284d..d249e2e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: matrix: platforms: [ 'iOS_14,tvOS_14,watchOS_7', - 'iOS_13,tvOS_13,watchOS_6', + 'tvOS_13,watchOS_6', ] fail-fast: false timeout-minutes: 30 From ef6f8e40a7a7690e38e51bea24e3c20d5d9d927b Mon Sep 17 00:00:00 2001 From: Jon Shier Date: Fri, 9 Jun 2023 11:03:14 -0400 Subject: [PATCH 15/19] Use modern SPM integration. --- Scripts/build.swift | 92 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 72 insertions(+), 20 deletions(-) diff --git a/Scripts/build.swift b/Scripts/build.swift index 978b82dd..48da1359 100755 --- a/Scripts/build.swift +++ b/Scripts/build.swift @@ -151,6 +151,16 @@ enum Platform: String, CustomStringConvertible { } } + var requiresUpdatedSPMIntegration: Bool { + switch self { + case .iOS_16, .tvOS_16, .watchOS_9, .macOS_13, + .iOS_17, .tvOS_17, .watchOS_10, .macOS_14: + return true + default: + return false + } + } + var derivedDataPath: String { ".build/derivedData/" + description } @@ -200,21 +210,29 @@ enum Task: String, CustomStringConvertible { rawValue } - var project: String { - switch self { - case .spm: - return "generated/Valet.xcodeproj" - case .xcode: - return "Valet.xcodeproj" + func project(for platform: Platform) -> String? { + if platform.requiresUpdatedSPMIntegration { + return nil + } else { + switch self { + case .spm: + return "generated/Valet.xcodeproj" + case .xcode: + return "Valet.xcodeproj" + } } } - var shouldGenerateXcodeProject: Bool { - switch self { - case .spm: - return true - case .xcode: + func shouldGenerateXcodeProject(for platform: Platform) -> Bool { + if platform.requiresUpdatedSPMIntegration { return false + } else { + switch self { + case .spm: + return true + case .xcode: + return false + } } } @@ -242,7 +260,11 @@ enum Task: String, CustomStringConvertible { func scheme(for platform: Platform) -> String { switch self { case .spm: - return "Valet-Package" + if platform.requiresUpdatedSPMIntegration { + return "Valet" + } else { + return "Valet-Package" + } case .xcode: return platform.scheme } @@ -271,23 +293,44 @@ guard let task = Task(rawValue: rawTask) else { exit(0) } -if task.shouldGenerateXcodeProject { +let platforms = rawPlatforms.map { rawPlatform in + guard let platform = Platform(rawValue: rawPlatform) else { + print("Received unknown platform type \(rawPlatform)") + exit(0) + } + + return platform +} + +if task == .spm && platforms.map({ task.shouldGenerateXcodeProject(for: $0) }).contains(true) { try execute(commandPath: "/usr/bin/xcrun", arguments: ["/usr/bin/swift", "package", "generate-xcodeproj", "--output=generated/"]) } +for platform in platforms { + var deletedXcodeproj = false + var xcodeBuildArguments: [String] = [] + if task == .spm && platform.requiresUpdatedSPMIntegration { + do { + print("Deleting Valet.xcodeproj, any uncommitted changes will be lost.") + try execute(commandPath: "/bin/rm", arguments: ["-r", "Valet.xcodeproj"]) + deletedXcodeproj = true + } catch { + print("Could not delete Valet.xcodeproj due to error: \(error)") + exit(0) + } + } -for rawPlatform in rawPlatforms { - guard let platform = Platform(rawValue: rawPlatform) else { - print("Received unknown platform type \(rawPlatform)") - exit(0) + if let project = task.project(for: platform) { + xcodeBuildArguments.append("-project") + xcodeBuildArguments.append(project) } - var xcodeBuildArguments = [ - "-project", task.project, + + xcodeBuildArguments.append(contentsOf: [ "-scheme", task.scheme(for: platform), "-sdk", platform.sdk, "-configuration", task.configuration, "-PBXBuildsContinueAfterErrors=0", - ] + ]) if !platform.destination.isEmpty { xcodeBuildArguments.append("-destination") xcodeBuildArguments.append(platform.destination) @@ -312,4 +355,13 @@ for rawPlatform in rawPlatforms { } catch { print("xcodebuild failed with error: \(error)") } + + if deletedXcodeproj { + do { + print("Restoring Valet.xcodeproj") + try execute(commandPath: "/usr/bin/git", arguments: ["restore", "Valet.xcodeproj"]) + } catch { + print("Failed to reset Valet.xcodeproj to last committed version due to error: \(error)") + } + } } From 5673a000839b21e10b4482f6d283da47e312350f Mon Sep 17 00:00:00 2001 From: Jon Shier Date: Fri, 9 Jun 2023 11:29:37 -0400 Subject: [PATCH 16/19] Closure return type. --- Scripts/build.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/build.swift b/Scripts/build.swift index 48da1359..a410da7f 100755 --- a/Scripts/build.swift +++ b/Scripts/build.swift @@ -293,7 +293,7 @@ guard let task = Task(rawValue: rawTask) else { exit(0) } -let platforms = rawPlatforms.map { rawPlatform in +let platforms = rawPlatforms.map { rawPlatform -> Platform in guard let platform = Platform(rawValue: rawPlatform) else { print("Received unknown platform type \(rawPlatform)") exit(0) From 871bd566b3975570fe21f40f94e59d6379bd8ec8 Mon Sep 17 00:00:00 2001 From: Jon Shier Date: Fri, 9 Jun 2023 12:04:08 -0400 Subject: [PATCH 17/19] Documentation and variable naming clarity. --- Scripts/build.swift | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Scripts/build.swift b/Scripts/build.swift index a410da7f..e4c8d78c 100755 --- a/Scripts/build.swift +++ b/Scripts/build.swift @@ -151,7 +151,8 @@ enum Platform: String, CustomStringConvertible { } } - var requiresUpdatedSPMIntegration: Bool { + /// Whether the platform's Xcode version requires modern SPM integration in xcodebuild, given the removal of generate-xcodeproj. + var requiresModernSPMIntegration: Bool { switch self { case .iOS_16, .tvOS_16, .watchOS_9, .macOS_13, .iOS_17, .tvOS_17, .watchOS_10, .macOS_14: @@ -211,7 +212,7 @@ enum Task: String, CustomStringConvertible { } func project(for platform: Platform) -> String? { - if platform.requiresUpdatedSPMIntegration { + if platform.requiresModernSPMIntegration { return nil } else { switch self { @@ -224,7 +225,7 @@ enum Task: String, CustomStringConvertible { } func shouldGenerateXcodeProject(for platform: Platform) -> Bool { - if platform.requiresUpdatedSPMIntegration { + if platform.requiresModernSPMIntegration { return false } else { switch self { @@ -260,7 +261,7 @@ enum Task: String, CustomStringConvertible { func scheme(for platform: Platform) -> String { switch self { case .spm: - if platform.requiresUpdatedSPMIntegration { + if platform.requiresModernSPMIntegration { return "Valet" } else { return "Valet-Package" @@ -302,14 +303,17 @@ let platforms = rawPlatforms.map { rawPlatform -> Platform in return platform } -if task == .spm && platforms.map({ task.shouldGenerateXcodeProject(for: $0) }).contains(true) { +// Only generate xcodeproj for SPM on platforms that require it. +let shouldGenerateXcodeproj = task == .spm && platforms.map { task.shouldGenerateXcodeProject(for: $0) }.contains(true) +if shouldGenerateXcodeproj { try execute(commandPath: "/usr/bin/xcrun", arguments: ["/usr/bin/swift", "package", "generate-xcodeproj", "--output=generated/"]) } for platform in platforms { var deletedXcodeproj = false var xcodeBuildArguments: [String] = [] - if task == .spm && platform.requiresUpdatedSPMIntegration { + // If necessary, delete Valet.xcodeproj, otherwise xcodebuild won't generate the SPM scheme. + if task == .spm && platform.requiresModernSPMIntegration { do { print("Deleting Valet.xcodeproj, any uncommitted changes will be lost.") try execute(commandPath: "/bin/rm", arguments: ["-r", "Valet.xcodeproj"]) From 3eab0a44fa4acf1b952f00ea663ac2a1146a066f Mon Sep 17 00:00:00 2001 From: Jon Shier Date: Fri, 9 Jun 2023 12:05:23 -0400 Subject: [PATCH 18/19] Even better note. --- Scripts/build.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Scripts/build.swift b/Scripts/build.swift index e4c8d78c..0dc9a484 100755 --- a/Scripts/build.swift +++ b/Scripts/build.swift @@ -313,6 +313,7 @@ for platform in platforms { var deletedXcodeproj = false var xcodeBuildArguments: [String] = [] // If necessary, delete Valet.xcodeproj, otherwise xcodebuild won't generate the SPM scheme. + // If deleted, the xcodeproj will be restored by git at the end of the loop. if task == .spm && platform.requiresModernSPMIntegration { do { print("Deleting Valet.xcodeproj, any uncommitted changes will be lost.") From 359b2034bbfa735665cbcc28b2175e4636a4a384 Mon Sep 17 00:00:00 2001 From: Jon Shier Date: Fri, 9 Jun 2023 12:30:54 -0400 Subject: [PATCH 19/19] Add TODO about iOS 13 testing. Co-authored-by: Dan Federman --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d249e2e0..6ac9b70c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,7 @@ jobs: matrix: platforms: [ 'iOS_14,tvOS_14,watchOS_7', + # TODO: add iOS_13 back once https://github.com/actions/runner-images/issues/7687 is resolved 'tvOS_13,watchOS_6', ] fail-fast: false