Skip to content

Commit 1571573

Browse files
committed
Update AppKit API
1 parent 355e83b commit 1571573

File tree

3 files changed

+47
-3
lines changed

3 files changed

+47
-3
lines changed

Sources/OpenSwiftUI_SPI/Shims/AppKit/AppKit_Private.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
OPENSWIFTUI_ASSUME_NONNULL_BEGIN
1717

1818
@interface NSApplication (OpenSwiftUI_SPI)
19-
- (void)startedTest:(nullable NSString *)name;
20-
- (void)finishedTest:(nullable NSString *)name;
21-
- (void)failedTest:(nullable NSString *)name withFailure:(nullable NSError*)failure;
19+
- (void)startedTest_openswiftui_safe_wrapper:(nullable NSString *)name OPENSWIFTUI_SWIFT_NAME(startedTest(_:));
20+
- (void)finishedTest_openswiftui_safe_wrapper:(nullable NSString *)name OPENSWIFTUI_SWIFT_NAME(finishedTest(_:));
21+
- (void)failedTest_openswiftui_safe_wrapper:(nullable NSString *)name withFailure:(nullable NSError*)failure OPENSWIFTUI_SWIFT_NAME(failedTest(_:withFailure:));
2222
@end
2323

2424
OPENSWIFTUI_ASSUME_NONNULL_END

Sources/OpenSwiftUI_SPI/Shims/AppKit/AppKit_Private.m

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,28 @@
55
// Status: WIP
66

77
#import "AppKit_Private.h"
8+
#import "../OpenSwiftUIShims.h"
9+
10+
#if __has_include(<AppKit/AppKit.h>)
11+
12+
#import <objc/runtime.h>
13+
14+
@implementation NSApplication (OpenSwiftUI_SPI)
15+
- (void)startedTest_openswiftui_safe_wrapper:(NSString *)name {
16+
OPENSWIFTUI_SAFE_WRAPPER_IMP(void, @"startedTest:", , NSString *);
17+
func(self, selector, name);
18+
}
19+
20+
- (void)finishedTest_openswiftui_safe_wrapper:(NSString *)name {
21+
OPENSWIFTUI_SAFE_WRAPPER_IMP(void, @"finishedTest:", , NSString *);
22+
func(self, selector, name);
23+
}
24+
25+
- (void)failedTest_openswiftui_safe_wrapper:(NSString *)name withFailure:(NSError *)failure {
26+
OPENSWIFTUI_SAFE_WRAPPER_IMP(void, @"failedTest:withFailure:", , NSString *, NSError *);
27+
func(self, selector, name, failure);
28+
}
29+
@end
30+
31+
#endif /* AppKit.h */
832

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// AppKitPrivateTests.swift
3+
// OpenSwiftUI_SPITests
4+
5+
import OpenSwiftUI_SPI
6+
import Testing
7+
8+
#if canImport(AppKit)
9+
@MainActor
10+
struct AppKitPrivateTests {
11+
@Test
12+
func application() {
13+
let app = NSApplication.shared
14+
let name = "ATest"
15+
app.startedTest(name)
16+
app.finishedTest(name)
17+
app.failedTest(name, withFailure: nil)
18+
}
19+
}
20+
#endif

0 commit comments

Comments
 (0)