Skip to content

Commit

Permalink
Bypass deprecation warning
Browse files Browse the repository at this point in the history
This method is deprecated but we still need to use it because iOS uses it itself and we need it to detect when the app is ignoring events. The fix is to add a protocol to bypass the warning.
  • Loading branch information
gabriellanata authored Jul 14, 2022
1 parent 00afd05 commit 1b8e6e8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion HammerTests.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "HammerTests"
spec.version = "0.14.1"
spec.version = "0.14.2"
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"
Expand Down
9 changes: 8 additions & 1 deletion Sources/Hammer/EventGenerator/EventGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public final class EventGenerator {

/// Returns if the window is ready to receive user interaction events
public var isWindowReady: Bool {
guard !UIApplication.shared.isIgnoringInteractionEvents
guard !(UIApplication.shared as UIApplicationDeprecated).isIgnoringInteractionEvents
&& self.window.isHidden == false
&& self.window.isUserInteractionEnabled
&& self.window.rootViewController?.viewIfLoaded != nil
Expand Down Expand Up @@ -183,3 +183,10 @@ public final class EventGenerator {
try waiter.start()
}
}

// Bypasses deprecation warning for `isIgnoringInteractionEvents`
private protocol UIApplicationDeprecated {
var isIgnoringInteractionEvents: Bool { get }
}

extension UIApplication: UIApplicationDeprecated {}

0 comments on commit 1b8e6e8

Please sign in to comment.