File tree Expand file tree Collapse file tree 3 files changed +18
-8
lines changed Expand file tree Collapse file tree 3 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -73,11 +73,8 @@ static NSApplication()
73
73
{
74
74
if ( Platform . IsNotMacOS )
75
75
return ;
76
- var libHandle = NativeLibrary . Load ( NativeLibraryNames . AppKit ) ;
77
- if ( libHandle != IntPtr . Zero )
78
- {
79
- NSAppPtr = ( IntPtr * ) NativeLibrary . GetExport ( libHandle , "NSApp" ) ;
80
- }
76
+ var libHandle = NativeLibraryHandles . AppKit ;
77
+ NSAppPtr = ( IntPtr * ) NativeLibrary . GetExport ( libHandle , "NSApp" ) ;
81
78
NSApplicationClass = Class . GetClass ( "NSApplication" ) . AsNonNull ( ) ;
82
79
}
83
80
Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ namespace CarinaStudio.MacOS;
9
9
public static class NativeLibraryHandles
10
10
{
11
11
// Constants.
12
+ static readonly string [ ] AppKitLibPaths =
13
+ [
14
+ "/System/Library/Frameworks/AppKit.framework/AppKit"
15
+ ] ;
12
16
static readonly string [ ] CoreFoundationLibPaths =
13
17
[
14
18
"/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation" ,
@@ -27,12 +31,20 @@ public static class NativeLibraryHandles
27
31
28
32
29
33
// Fields.
34
+ static IntPtr appKitLibHandle ;
30
35
static IntPtr coreFoundationLibHandle ;
31
36
static IntPtr coreGraphicsLibHandle ;
37
+ static bool isAppKitLibResolved ;
32
38
static bool isCoreFoundationLibResolved ;
33
39
static bool isCoreGraphicsLibResolved ;
34
40
static bool isImageIOLibResolved ;
35
41
static IntPtr imageIOLibHandle ;
42
+
43
+
44
+ /// <summary>
45
+ /// Handle of AppKit library.
46
+ /// </summary>
47
+ public static IntPtr AppKit => GetHandle ( AppKitLibPaths , ref appKitLibHandle , ref isAppKitLibResolved ) ;
36
48
37
49
38
50
/// <summary>
Original file line number Diff line number Diff line change @@ -10,21 +10,22 @@ public static class NativeLibraryNames
10
10
/// <summary>
11
11
/// AppKit.
12
12
/// </summary>
13
+ [ Obsolete ( "The path to AppKit may be different between macOS, use NativeLibraryHandles.AppKit instead." ) ]
13
14
public const string AppKit = "/System/Library/Frameworks/AppKit.framework/AppKit" ;
14
15
/// <summary>
15
16
/// Core Foundation.
16
17
/// </summary>
17
- [ Obsolete ( "The path to CoreFoundation may be different between macOS, use NativeLibraryHandles.CoreFoundation instead." ) ]
18
+ [ Obsolete ( "The path to Core Foundation may be different between macOS, use NativeLibraryHandles.CoreFoundation instead." ) ]
18
19
public const string CoreFoundation = "/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreFoundation.framework/CoreFoundation" ;
19
20
/// <summary>
20
21
/// Core Graphics.
21
22
/// </summary>
22
- [ Obsolete ( "The path to CoreFoundation may be different between macOS, use NativeLibraryHandles.CoreGraphics instead." ) ]
23
+ [ Obsolete ( "The path to Core Graphics may be different between macOS, use NativeLibraryHandles.CoreGraphics instead." ) ]
23
24
public const string CoreGraphics = "/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/CoreGraphics" ;
24
25
/// <summary>
25
26
/// Image I/O.
26
27
/// </summary>
27
- [ Obsolete ( "The path to CoreFoundation may be different between macOS, use NativeLibraryHandles.ImageIO instead." ) ]
28
+ [ Obsolete ( "The path to ImageIO may be different between macOS, use NativeLibraryHandles.ImageIO instead." ) ]
28
29
public const string ImageIO = "/System/Library/Frameworks/ApplicationServices.framework/Frameworks/ImageIO.framework/ImageIO" ;
29
30
/// <summary>
30
31
/// Objective-C Runtime.
You can’t perform that action at this time.
0 commit comments