Skip to content

Commit 9526bb3

Browse files
committed
Improvements
1 parent afbd9aa commit 9526bb3

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
import XCTest
21
import SentrySampleShared
2+
import XCTest
33

44
final class UIApplicationSwizzleTests: XCTestCase {
55

6+
// Tests for the crash first reported in https://github.com/getsentry/sentry-cocoa/issues/6966
67
func testSendEvent() {
78
let app = XCUIApplication()
89
app.launchArguments.append(contentsOf: [
9-
SentrySDKOverrides.Other.disableSpotlight.rawValue,
10+
SentrySDKOverrides.Other.disableSpotlight.rawValue
1011
])
1112
app.safelyLaunch()
1213

13-
app.buttons["UIApplication sendEvent"].tap()
14+
app.buttons["UIApplication sendEmptyEvent"].tap()
15+
fatalError()
1416
}
1517

1618
}

Samples/iOS-SwiftUI/iOS-SwiftUI/ContentView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ struct ContentView: View {
176176
Button(action: captureTransactionAction) {
177177
Text("Capture Transaction")
178178
}
179-
Button("UIApplication sendEvent") {
179+
// This is used by a UI test since UIApplication.shared is nil in unit tests.
180+
Button("UIApplication sendEmptyEvent") {
180181
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
181182
}
182183
Button(action: showTTD) {

Sources/Sentry/SentrySwizzleWrapperHelper.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
@implementation SentrySwizzleWrapperHelper
1010

11-
+ (void)swizzle:(void (^)(SEL action, _Nullable id target, _Nullable id sender, UIEvent * _Nullable event))callback;
11+
+ (void)swizzle:(void (^)(SEL action, _Nullable id target, _Nullable id sender,
12+
UIEvent *_Nullable event))callback;
1213
{
1314
# pragma clang diagnostic push
1415
# pragma clang diagnostic ignored "-Wshadow"

Sources/Sentry/include/SentrySwizzleWrapperHelper.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ NS_ASSUME_NONNULL_BEGIN
88

99
@interface SentrySwizzleWrapperHelper : NSObject
1010

11-
+ (void)swizzle:(void (^)(SEL action, _Nullable id target, _Nullable id sender, UIEvent * _Nullable event))callback;
11+
+ (void)swizzle:(void (^)(SEL action, _Nullable id target, _Nullable id sender,
12+
UIEvent *_Nullable event))callback;
1213

1314
@end
1415

0 commit comments

Comments
 (0)