File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#ifndef PACKAGES_WEBGPU_APPLE_RNWGUIKIT_H_
22#define PACKAGES_WEBGPU_APPLE_RNWGUIKIT_H_
33
4+ // Select UIKit or AppKit before importing either framework.
5+ #import < TargetConditionals.h>
6+
47#if !TARGET_OS_OSX
58#import < UIKit/UIKit.h>
69#else
7- #import < Appkit/Appkit .h>
10+ #import < AppKit/AppKit .h>
811#endif
912
1013#if !TARGET_OS_OSX
Original file line number Diff line number Diff line change @@ -46,13 +46,38 @@ @implementation WebGPUModule
4646 return webgpuManager;
4747}
4848
49- #pragma Setup and invalidation
49+ #pragma mark - Setup and invalidation
5050
5151+ (BOOL )requiresMainQueueSetup {
5252 return YES ;
5353}
5454
55+ #if TARGET_OS_OSX
56+ - (instancetype )init {
57+ if (self = [super init ]) {
58+ [[NSNotificationCenter defaultCenter ]
59+ addObserver: self
60+ selector: @selector (applicationWillTerminate: )
61+ name: NSApplicationWillTerminateNotification
62+ object: nil ];
63+ }
64+ return self;
65+ }
66+
67+ - (void )applicationWillTerminate : (NSNotification *)notification {
68+ // AppKit exits without necessarily invalidating the React instance. Release
69+ // the manager before static teardown destroys SurfaceRegistry and its mutex.
70+ [self invalidate ];
71+ }
72+ #endif
73+
5574- (void )invalidate {
75+ #if TARGET_OS_OSX
76+ [[NSNotificationCenter defaultCenter ]
77+ removeObserver: self
78+ name: NSApplicationWillTerminateNotification
79+ object: nil ];
80+ #endif
5681 webgpuManager = nil ;
5782}
5883
Original file line number Diff line number Diff line change 11#pragma once
22
33#import " MetalView.h"
4+ // RNWGUIKit selects AppKit for native macOS and UIKit for other Apple targets.
5+ #import " RNWGUIKit.h"
46#import < React/RCTViewComponentView.h>
5- #import < UIKit/UIKit.h>
67
78NS_ASSUME_NONNULL_BEGIN
89
Original file line number Diff line number Diff line change 1818
1919# The other files under apple/ need React and codegen headers, which only
2020# exist after a pod install.
21- FILES=(apple/MetalLayerColorSpace.mm apple/AppleVideoPlayer.mm)
21+ # Also compile the platform header on its own: TargetConditionals must be
22+ # available before it decides whether UIKit or AppKit is required.
23+ FILES=(apple/RNWGUIKit.h apple/MetalLayerColorSpace.mm apple/AppleVideoPlayer.mm)
2224
2325# sdk:target pairs, using the podspec's minimum versions.
2426TARGETS=(
You canβt perform that action at this time.
0 commit comments