Skip to content

Commit 3da0daa

Browse files
authored
Merge pull request #94 from Code-Hex/fix/issue-76
fixed issue #76
2 parents a5e901f + bb872b3 commit 3da0daa

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

virtualization.m

+10-7
Original file line numberDiff line numberDiff line change
@@ -1207,13 +1207,16 @@ void sharedApplication()
12071207

12081208
void startVirtualMachineWindow(void *machine, double width, double height)
12091209
{
1210-
@autoreleasepool {
1211-
AppDelegate *appDelegate = [[[AppDelegate alloc]
1212-
initWithVirtualMachine:(VZVirtualMachine *)machine
1213-
windowWidth:(CGFloat)width
1214-
windowHeight:(CGFloat)height] autorelease];
1210+
if (@available(macOS 12, *)) {
1211+
@autoreleasepool {
1212+
AppDelegate *appDelegate = [[[AppDelegate alloc]
1213+
initWithVirtualMachine:(VZVirtualMachine *)machine
1214+
windowWidth:(CGFloat)width
1215+
windowHeight:(CGFloat)height] autorelease];
12151216

1216-
NSApp.delegate = appDelegate;
1217-
[NSApp run];
1217+
NSApp.delegate = appDelegate;
1218+
[NSApp run];
1219+
}
12181220
}
1221+
RAISE_UNSUPPORTED_MACOS_EXCEPTION();
12191222
}

virtualization_view.h

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#pragma once
88

9+
#import <Availability.h>
910
#import <Cocoa/Cocoa.h>
1011
#import <Virtualization/Virtualization.h>
1112

@@ -22,6 +23,7 @@
2223
- (instancetype)init;
2324
@end
2425

26+
API_AVAILABLE(macos(12.0))
2527
@interface AppDelegate : NSObject <NSApplicationDelegate, NSWindowDelegate, VZVirtualMachineDelegate>
2628
- (instancetype)initWithVirtualMachine:(VZVirtualMachine *)virtualMachine
2729
windowWidth:(CGFloat)windowWidth

0 commit comments

Comments
 (0)