diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml index b67499e..46eb2b0 100644 --- a/.github/workflows/Test.yml +++ b/.github/workflows/Test.yml @@ -11,12 +11,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - - 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 - - name: List available simulators - run: xcrun simctl list + - name: Force Xcode 15.4 + run: sudo xcode-select -switch /Applications/Xcode_15.4.app - name: Make project run: make generate - name: Run tests @@ -27,34 +23,22 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - - 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 - - name: List available simulators - run: xcrun simctl list + - name: Force Xcode 15.4 + run: sudo xcode-select -switch /Applications/Xcode_15.4.app - name: Make project 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 12.4 - run: sudo xcode-select -switch /Applications/Xcode_12.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 - - 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/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/Makefile b/Makefile index 105ce37..e4c2247 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: @@ -8,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 @@ -23,24 +30,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) | xcbeautify 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) | xcbeautify -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) | xcbeautify # List all targets (from https://stackoverflow.com/questions/4219255/how-do-you-get-the-list-of-targets-in-a-makefile) 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/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) } } 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) 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