From f2d80b8d35448dee7f38fc1be86ed771376f6d9d Mon Sep 17 00:00:00 2001 From: Kirill Yakimovich Date: Tue, 4 Jun 2024 15:56:07 +0200 Subject: [PATCH 01/14] Switch to Xcode 15.4 --- .github/workflows/Test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml index b67499e..db8e086 100644 --- a/.github/workflows/Test.yml +++ b/.github/workflows/Test.yml @@ -14,7 +14,7 @@ jobs: - name: List available Xcode versions run: ls /Applications | grep Xcode - name: Force Xcode 12.4 - run: sudo xcode-select -switch /Applications/Xcode_12.4.app + run: sudo xcode-select -switch /Applications/Xcode_15.4.app - name: List available simulators run: xcrun simctl list - name: Make project @@ -30,7 +30,7 @@ jobs: - name: List available Xcode versions run: ls /Applications | grep Xcode - name: Force Xcode 12.4 - run: sudo xcode-select -switch /Applications/Xcode_12.4.app + run: sudo xcode-select -switch /Applications/Xcode_15.4.app - name: List available simulators run: xcrun simctl list - name: Make project @@ -46,7 +46,7 @@ jobs: - name: List available Xcode versions run: ls /Applications | grep Xcode - name: Force Xcode 12.4 - run: sudo xcode-select -switch /Applications/Xcode_12.4.app + run: sudo xcode-select -switch /Applications/Xcode_15.4.app - name: Setup Simulator run: | sudo mkdir -p /Library/Developer/CoreSimulator/Profiles/Runtimes From 7e613eb8086420a722ccc7ff18aee65649b80649 Mon Sep 17 00:00:00 2001 From: Kirill Yakimovich Date: Tue, 4 Jun 2024 16:11:17 +0200 Subject: [PATCH 02/14] increment deployment target to v12 --- HammerTests.podspec | 4 ++-- Package.swift | 2 +- project.yml | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/HammerTests.podspec b/HammerTests.podspec index b46a714..5343ad2 100644 --- a/HammerTests.podspec +++ b/HammerTests.podspec @@ -1,13 +1,13 @@ Pod::Spec.new do |spec| spec.name = "HammerTests" - spec.version = "0.14.3" + spec.version = "0.14.4" spec.summary = "iOS touch and keyboard syntheis library for unit tests." spec.description = "Hammer is a touch and keyboard synthesis library for emulating user interaction events. It enables new ways of triggering UI actions in unit tests, replicating a real world environment as much as possible." spec.homepage = "https://github.com/lyft/Hammer" spec.screenshots = "https://user-images.githubusercontent.com/585835/116217617-ab410080-a6fe-11eb-9de1-3d42f7dd6037.gif" spec.license = { :type => "Apache License, Version 2.0", :file => "./LICENSE" } spec.author = { "Gabriel Lanata" => "gabriel@lanata.me" } - spec.platform = :ios, "11.0" + spec.platform = :ios, "12.0" spec.swift_version = "5.3" spec.frameworks = 'XCTest' spec.source = { :git => "https://github.com/lyft/Hammer.git", :tag => "#{spec.version}" } diff --git a/Package.swift b/Package.swift index dac4066..2884f7e 100644 --- a/Package.swift +++ b/Package.swift @@ -5,7 +5,7 @@ import PackageDescription let package = Package( name: "Hammer", platforms: [ - .iOS(.v11), + .iOS(.v12), ], products: [ .library(name: "Hammer", targets: ["Hammer"]), diff --git a/project.yml b/project.yml index 3efd2d5..acd9780 100644 --- a/project.yml +++ b/project.yml @@ -5,7 +5,7 @@ targets: Hammer: type: framework platform: iOS - deploymentTarget: "11.0" + deploymentTarget: "12.0" sources: Sources/Hammer settings: ENABLE_TESTING_SEARCH_PATHS: true @@ -18,7 +18,7 @@ targets: HammerTests: type: bundle.unit-test platform: iOS - deploymentTarget: "11.0" + deploymentTarget: "12.0" sources: Tests/HammerTests dependencies: - target: Hammer @@ -26,5 +26,5 @@ targets: TestHost: type: application platform: iOS - deploymentTarget: "11.0" + deploymentTarget: "12.0" sources: TestHost From a029745304b25efc71f7be275f082397623eeb35 Mon Sep 17 00:00:00 2001 From: Kirill Yakimovich Date: Tue, 4 Jun 2024 16:21:26 +0200 Subject: [PATCH 03/14] update workflows --- .github/workflows/Test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml index db8e086..2bb3fde 100644 --- a/.github/workflows/Test.yml +++ b/.github/workflows/Test.yml @@ -13,7 +13,7 @@ jobs: uses: actions/checkout@v2 - name: List available Xcode versions run: ls /Applications | grep Xcode - - name: Force Xcode 12.4 + - name: Force Xcode 15.4 run: sudo xcode-select -switch /Applications/Xcode_15.4.app - name: List available simulators run: xcrun simctl list @@ -29,7 +29,7 @@ jobs: uses: actions/checkout@v2 - name: List available Xcode versions run: ls /Applications | grep Xcode - - name: Force Xcode 12.4 + - name: Force Xcode 15.4 run: sudo xcode-select -switch /Applications/Xcode_15.4.app - name: List available simulators run: xcrun simctl list @@ -45,12 +45,12 @@ jobs: uses: actions/checkout@v2 - name: List available Xcode versions run: ls /Applications | grep Xcode - - name: Force Xcode 12.4 + - name: Force Xcode 15.4 run: sudo xcode-select -switch /Applications/Xcode_15.4.app - name: Setup Simulator run: | sudo mkdir -p /Library/Developer/CoreSimulator/Profiles/Runtimes - sudo ln -s /Applications/Xcode_10.3.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 12.4.simruntime + sudo ln -s /Applications/Xcode_15.4.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 12.4.simruntime - name: List available simulators run: xcrun simctl list - name: Make project From 2ad56eab3989c66fd2de08aea1bc49d5fe42e3eb Mon Sep 17 00:00:00 2001 From: Kirill Yakimovich Date: Tue, 4 Jun 2024 17:21:45 +0200 Subject: [PATCH 04/14] silence swiftlint --- Sources/Hammer/AppleInternal/AppleInternal+IOHID.swift | 2 ++ Sources/Hammer/Utilties/Subviews.swift | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/Hammer/AppleInternal/AppleInternal+IOHID.swift b/Sources/Hammer/AppleInternal/AppleInternal+IOHID.swift index a54b3cf..63ef27f 100644 --- a/Sources/Hammer/AppleInternal/AppleInternal+IOHID.swift +++ b/Sources/Hammer/AppleInternal/AppleInternal+IOHID.swift @@ -205,3 +205,5 @@ extension IOHID { let kGSEventPathInfoInRange: UInt8 = (1 << 0) let kGSEventPathInfoInTouch: UInt8 = (1 << 1) + +// swiftlint:enable type_name diff --git a/Sources/Hammer/Utilties/Subviews.swift b/Sources/Hammer/Utilties/Subviews.swift index 2f19499..5b5365e 100644 --- a/Sources/Hammer/Utilties/Subviews.swift +++ b/Sources/Hammer/Utilties/Subviews.swift @@ -293,10 +293,8 @@ extension EventGenerator { throw HammerError.windowIsNotReadyForInteraction } - for point in points { - if !self.pointIsHittable(point) { - throw HammerError.pointIsNotHittable(point) - } + if let nonHittablePoint = points.first(where: { !self.pointIsHittable($0) }) { + throw HammerError.pointIsNotHittable(nonHittablePoint) } } From fa673da7f214bb35b72d9f2306f370ca84b3e905 Mon Sep 17 00:00:00 2001 From: Kirill Yakimovich Date: Tue, 4 Jun 2024 17:46:32 +0200 Subject: [PATCH 05/14] do not codesign HammerTests --- project.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/project.yml b/project.yml index acd9780..8051f50 100644 --- a/project.yml +++ b/project.yml @@ -20,6 +20,11 @@ targets: platform: iOS deploymentTarget: "12.0" sources: Tests/HammerTests + settings: + CODE_SIGN_IDENTITY: '' + CODE_SIGNING_REQUIRED: 'NO' + CODE_SIGN_ENTITLEMENTS: '' + CODE_SIGNING_ALLOWED: 'NO' dependencies: - target: Hammer - target: TestHost From 4349150f630ca6b66843a76d1d8db1341d5bcd7f Mon Sep 17 00:00:00 2001 From: Kirill Yakimovich Date: Tue, 4 Jun 2024 17:49:22 +0200 Subject: [PATCH 06/14] Do not sign TestHost --- project.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/project.yml b/project.yml index 8051f50..5ed5c2b 100644 --- a/project.yml +++ b/project.yml @@ -33,3 +33,8 @@ targets: platform: iOS deploymentTarget: "12.0" sources: TestHost + settings: + CODE_SIGN_IDENTITY: '' + CODE_SIGNING_REQUIRED: 'NO' + CODE_SIGN_ENTITLEMENTS: '' + CODE_SIGNING_ALLOWED: 'NO' From 7b16394c240e48dd1a26918ec453d8911857cc0c Mon Sep 17 00:00:00 2001 From: Kirill Yakimovich Date: Tue, 4 Jun 2024 18:01:25 +0200 Subject: [PATCH 07/14] not code signing for hammer --- project.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/project.yml b/project.yml index 5ed5c2b..15b962b 100644 --- a/project.yml +++ b/project.yml @@ -9,6 +9,10 @@ targets: sources: Sources/Hammer settings: ENABLE_TESTING_SEARCH_PATHS: true + CODE_SIGN_IDENTITY: '' + CODE_SIGNING_REQUIRED: 'NO' + CODE_SIGN_ENTITLEMENTS: '' + CODE_SIGNING_ALLOWED: 'NO' scheme: testTargets: - HammerTests From 1a1998029373337c20db922e5c6d57ca99e00fb3 Mon Sep 17 00:00:00 2001 From: Kirill Yakimovich Date: Tue, 4 Jun 2024 18:30:24 +0200 Subject: [PATCH 08/14] set random development team --- project.yml | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/project.yml b/project.yml index 15b962b..fb27d05 100644 --- a/project.yml +++ b/project.yml @@ -9,10 +9,7 @@ targets: sources: Sources/Hammer settings: ENABLE_TESTING_SEARCH_PATHS: true - CODE_SIGN_IDENTITY: '' - CODE_SIGNING_REQUIRED: 'NO' - CODE_SIGN_ENTITLEMENTS: '' - CODE_SIGNING_ALLOWED: 'NO' + DEVELOPMENT_TEAM: 'H1A2M3M4ER' scheme: testTargets: - HammerTests @@ -25,10 +22,7 @@ targets: deploymentTarget: "12.0" sources: Tests/HammerTests settings: - CODE_SIGN_IDENTITY: '' - CODE_SIGNING_REQUIRED: 'NO' - CODE_SIGN_ENTITLEMENTS: '' - CODE_SIGNING_ALLOWED: 'NO' + DEVELOPMENT_TEAM: 'H1A2M3M4ER' dependencies: - target: Hammer - target: TestHost @@ -38,7 +32,4 @@ targets: deploymentTarget: "12.0" sources: TestHost settings: - CODE_SIGN_IDENTITY: '' - CODE_SIGNING_REQUIRED: 'NO' - CODE_SIGN_ENTITLEMENTS: '' - CODE_SIGNING_ALLOWED: 'NO' + DEVELOPMENT_TEAM: 'H1A2M3M4ER' From c4548f1e12a1e2cc21d81810ec0ca3b566a309d3 Mon Sep 17 00:00:00 2001 From: Gabriel Lanata Date: Tue, 4 Jun 2024 12:19:21 -0700 Subject: [PATCH 09/14] Update project.yml --- project.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/project.yml b/project.yml index fb27d05..2a677a9 100644 --- a/project.yml +++ b/project.yml @@ -9,7 +9,6 @@ targets: sources: Sources/Hammer settings: ENABLE_TESTING_SEARCH_PATHS: true - DEVELOPMENT_TEAM: 'H1A2M3M4ER' scheme: testTargets: - HammerTests From 2d3d9b6a94ff13d9f03a772666dfc768c8415462 Mon Sep 17 00:00:00 2001 From: Gabriel Lanata Date: Tue, 4 Jun 2024 12:19:36 -0700 Subject: [PATCH 10/14] Update project.yml --- project.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/project.yml b/project.yml index 2a677a9..acd9780 100644 --- a/project.yml +++ b/project.yml @@ -20,8 +20,6 @@ targets: platform: iOS deploymentTarget: "12.0" sources: Tests/HammerTests - settings: - DEVELOPMENT_TEAM: 'H1A2M3M4ER' dependencies: - target: Hammer - target: TestHost @@ -30,5 +28,3 @@ targets: platform: iOS deploymentTarget: "12.0" sources: TestHost - settings: - DEVELOPMENT_TEAM: 'H1A2M3M4ER' From f52f589d0c5e2df29e7d7233c5e248b19b992bb3 Mon Sep 17 00:00:00 2001 From: Marcos Griselli Date: Tue, 11 Jun 2024 17:59:04 -0700 Subject: [PATCH 11/14] Update test actions --- .github/workflows/Test.yml | 20 ++++++-------------- Makefile | 22 +++++++++++++++------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml index 2bb3fde..f9c0fa0 100644 --- a/.github/workflows/Test.yml +++ b/.github/workflows/Test.yml @@ -15,8 +15,6 @@ jobs: run: ls /Applications | grep Xcode - name: Force Xcode 15.4 run: sudo xcode-select -switch /Applications/Xcode_15.4.app - - name: List available simulators - run: xcrun simctl list - name: Make project run: make generate - name: Run tests @@ -37,24 +35,18 @@ jobs: run: make generate - name: Run tests run: make test-iPhone - test_iphone_ios12: - name: Test-iPhone-iOS12 - runs-on: macos-10.15 + test_iphone_ios15: + name: Test-iPhone-iOS15 + runs-on: macos-12 steps: - name: Checkout uses: actions/checkout@v2 - name: List available Xcode versions run: ls /Applications | grep Xcode - - name: Force Xcode 15.4 - run: sudo xcode-select -switch /Applications/Xcode_15.4.app - - name: Setup Simulator - run: | - sudo mkdir -p /Library/Developer/CoreSimulator/Profiles/Runtimes - sudo ln -s /Applications/Xcode_15.4.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 12.4.simruntime - - name: List available simulators - run: xcrun simctl list + - name: Force Xcode 13.1 + run: sudo xcode-select -switch /Applications/Xcode_13.1.app - name: Make project run: make generate - name: Run tests - run: make test-iPhone-iOS12 + run: make test-iPhone-iOS15 diff --git a/Makefile b/Makefile index 105ce37..0fe8901 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,9 @@ .DEFAULT_GOAL := generate +# Code Signing Settings + +NO_CODE_SIGN_SETTINGS = CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO + # Install Tasks install-lint: @@ -23,24 +27,28 @@ test-iPad: xcodebuild \ -project Hammer.xcodeproj \ -scheme Hammer \ - -destination "name=iPad Pro (12.9-inch) (4th generation)" \ - test + -destination "name=iPad Pro (12.9-inch) (6th generation)" \ + test \ + $(NO_CODE_SIGN_SETTINGS) test-iPhone: set -o pipefail && \ xcodebuild \ -project Hammer.xcodeproj \ -scheme Hammer \ - -destination "name=iPhone 11" \ - test + -destination "name=iPhone 15" \ + test \ + $(NO_CODE_SIGN_SETTINGS) -test-iPhone-iOS12: +test-iPhone-iOS15: set -o pipefail && \ xcodebuild \ -project Hammer.xcodeproj \ -scheme Hammer \ - -destination "name=iPhone 6" \ - test + -destination "name=iPhone 11" \ + -sdk iphonesimulator15.0 \ + test \ + $(NO_CODE_SIGN_SETTINGS) # List all targets (from https://stackoverflow.com/questions/4219255/how-do-you-get-the-list-of-targets-in-a-makefile) From a3352c61cea9ffe725b86258d14d708c50fd5e5b Mon Sep 17 00:00:00 2001 From: Marcos Griselli Date: Tue, 11 Jun 2024 18:16:38 -0700 Subject: [PATCH 12/14] Remove unnecessary logs --- .github/workflows/Test.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml index f9c0fa0..46eb2b0 100644 --- a/.github/workflows/Test.yml +++ b/.github/workflows/Test.yml @@ -11,8 +11,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - - name: List available Xcode versions - run: ls /Applications | grep Xcode - name: Force Xcode 15.4 run: sudo xcode-select -switch /Applications/Xcode_15.4.app - name: Make project @@ -25,12 +23,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - - name: List available Xcode versions - run: ls /Applications | grep Xcode - name: Force Xcode 15.4 run: sudo xcode-select -switch /Applications/Xcode_15.4.app - - name: List available simulators - run: xcrun simctl list - name: Make project run: make generate - name: Run tests @@ -41,8 +35,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - - name: List available Xcode versions - run: ls /Applications | grep Xcode - name: Force Xcode 13.1 run: sudo xcode-select -switch /Applications/Xcode_13.1.app - name: Make project From 52ef93314216e1a6c0c099f930380bbc9aa7f7b4 Mon Sep 17 00:00:00 2001 From: Kirill Yakimovich Date: Wed, 12 Jun 2024 10:03:02 +0200 Subject: [PATCH 13/14] Suppprt scenes based apps (#55) --- Sources/Hammer/Utilties/UIKit+Extensions.swift | 4 ++++ TestHost/Info.plist | 17 +++++++++++++++++ TestHost/SceneDelegate.swift | 8 ++++++++ Tests/HammerTests/KeyboardTests.swift | 5 ++--- 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 TestHost/SceneDelegate.swift diff --git a/Sources/Hammer/Utilties/UIKit+Extensions.swift b/Sources/Hammer/Utilties/UIKit+Extensions.swift index 2a1da24..933b251 100644 --- a/Sources/Hammer/Utilties/UIKit+Extensions.swift +++ b/Sources/Hammer/Utilties/UIKit+Extensions.swift @@ -46,6 +46,10 @@ extension UIDevice { extension UIWindow { convenience init(wrapping viewController: UIViewController) { self.init(frame: UIScreen.main.bounds) + if #available(iOS 13.0, *), self.windowScene == nil { + self.windowScene = UIApplication.shared.connectedScenes + .compactMap { $0 as? UIWindowScene }.first + } self.rootViewController = viewController } } diff --git a/TestHost/Info.plist b/TestHost/Info.plist index 57724db..3793d4c 100644 --- a/TestHost/Info.plist +++ b/TestHost/Info.plist @@ -41,5 +41,22 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneConfigurationName + Default Configuration + + + + diff --git a/TestHost/SceneDelegate.swift b/TestHost/SceneDelegate.swift new file mode 100644 index 0000000..8a02b95 --- /dev/null +++ b/TestHost/SceneDelegate.swift @@ -0,0 +1,8 @@ +import UIKit + +@available(iOS 13.0, *) +final class SceneDelegate: UIResponder, UISceneDelegate { + var window: UIWindow? + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, + options connectionOptions: UIScene.ConnectionOptions) {} +} diff --git a/Tests/HammerTests/KeyboardTests.swift b/Tests/HammerTests/KeyboardTests.swift index cea742f..19f62f7 100644 --- a/Tests/HammerTests/KeyboardTests.swift +++ b/Tests/HammerTests/KeyboardTests.swift @@ -1,4 +1,4 @@ -import Hammer +@testable import Hammer import UIKit import XCTest @@ -187,8 +187,7 @@ final class KeyboardTests: XCTestCase { view.centerXAnchor.constraint(equalTo: viewController.view.centerXAnchor), ]) - let window = UIWindow(frame: UIScreen.main.bounds) - window.rootViewController = viewController + let window = UIWindow(wrapping: viewController) window.isHidden = false let eventGenerator = try EventGenerator(window: window) From 5dd4ebb3716423f1501a57002723f817e1728958 Mon Sep 17 00:00:00 2001 From: Marcos Griselli <14804033+marcosgriselli@users.noreply.github.com> Date: Wed, 12 Jun 2024 01:04:45 -0700 Subject: [PATCH 14/14] Use xcbeautify for test logs (#57) --- Makefile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 0fe8901..e4c2247 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,9 @@ install-lint: install-xcodegen: brew list xcodegen &>/dev/null || brew install xcodegen +install-xcbeautify: + brew list xcbeautify &>/dev/null || brew install xcbeautify + # Run Tasks generate: install-xcodegen @@ -29,7 +32,7 @@ test-iPad: -scheme Hammer \ -destination "name=iPad Pro (12.9-inch) (6th generation)" \ test \ - $(NO_CODE_SIGN_SETTINGS) + $(NO_CODE_SIGN_SETTINGS) | xcbeautify test-iPhone: set -o pipefail && \ @@ -38,7 +41,7 @@ test-iPhone: -scheme Hammer \ -destination "name=iPhone 15" \ test \ - $(NO_CODE_SIGN_SETTINGS) + $(NO_CODE_SIGN_SETTINGS) | xcbeautify test-iPhone-iOS15: set -o pipefail && \ @@ -48,7 +51,7 @@ test-iPhone-iOS15: -destination "name=iPhone 11" \ -sdk iphonesimulator15.0 \ test \ - $(NO_CODE_SIGN_SETTINGS) + $(NO_CODE_SIGN_SETTINGS) | xcbeautify # List all targets (from https://stackoverflow.com/questions/4219255/how-do-you-get-the-list-of-targets-in-a-makefile)