Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to Xcode 15.4 #56

Merged
merged 14 commits into from
Jun 12, 2024
36 changes: 10 additions & 26 deletions .github/workflows/Test.yml
Original file line number Diff line number Diff line change
@@ -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
Comment on lines -14 to -19
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed these since that information is out in each runner: https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md

- 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

4 changes: 2 additions & 2 deletions HammerTests.podspec
Original file line number Diff line number Diff line change
@@ -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" => "[email protected]" }
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}" }
22 changes: 15 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I was trying to do that in different place fa673da
Thank you!


# 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 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This a bit unfortunate but GitHub Actions deprecated the macos_11 runner which would let us test all the way to iOS 13.7. We can figure out alternatives if this is critical but we'd need to download and install a large runtime file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine

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)

2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import PackageDescription
let package = Package(
name: "Hammer",
platforms: [
.iOS(.v11),
.iOS(.v12),
],
products: [
.library(name: "Hammer", targets: ["Hammer"]),
2 changes: 2 additions & 0 deletions Sources/Hammer/AppleInternal/AppleInternal+IOHID.swift
Original file line number Diff line number Diff line change
@@ -205,3 +205,5 @@ extension IOHID {

let kGSEventPathInfoInRange: UInt8 = (1 << 0)
let kGSEventPathInfoInTouch: UInt8 = (1 << 1)

// swiftlint:enable type_name
6 changes: 2 additions & 4 deletions Sources/Hammer/Utilties/Subviews.swift
Original file line number Diff line number Diff line change
@@ -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)
}
}

4 changes: 4 additions & 0 deletions Sources/Hammer/Utilties/UIKit+Extensions.swift
Original file line number Diff line number Diff line change
@@ -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
}
}
17 changes: 17 additions & 0 deletions TestHost/Info.plist
Original file line number Diff line number Diff line change
@@ -41,5 +41,22 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
</dict>
</array>
</dict>
</dict>
</dict>
</plist>
8 changes: 8 additions & 0 deletions TestHost/SceneDelegate.swift
Original file line number Diff line number Diff line change
@@ -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) {}
}
5 changes: 2 additions & 3 deletions Tests/HammerTests/KeyboardTests.swift
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 3 additions & 3 deletions project.yml
Original file line number Diff line number Diff line change
@@ -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,13 +18,13 @@ targets:
HammerTests:
type: bundle.unit-test
platform: iOS
deploymentTarget: "11.0"
deploymentTarget: "12.0"
sources: Tests/HammerTests
dependencies:
- target: Hammer
- target: TestHost
TestHost:
type: application
platform: iOS
deploymentTarget: "11.0"
deploymentTarget: "12.0"
sources: TestHost