Skip to content

Commit ca451ea

Browse files
committed
从 Bundle 中获取 MachServiceName
1 parent b005dd3 commit ca451ea

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

Sources/SystemExtensionKit/SystemExtensionKit+.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Created by CodingIran on 2023/9/25.
66
//
77

8+
import Foundation
89
import SystemExtensions
910

1011
public extension SystemExtensionKit {
@@ -121,6 +122,18 @@ public extension SystemExtensionKit {
121122
}
122123
}
123124

125+
public extension Bundle {
126+
var extensionMachServiceName: String? {
127+
guard
128+
let networkExtensionKeys = object(forInfoDictionaryKey: "NetworkExtension") as? [String: Any],
129+
let machServiceName = networkExtensionKeys["NEMachServiceName"] as? String
130+
else {
131+
return nil
132+
}
133+
return machServiceName
134+
}
135+
}
136+
124137
// MARK: - OSSystemExtensionError Code Description
125138

126139
extension OSSystemExtensionError.Code: CustomStringConvertible {

Sources/SystemExtensionKit/SystemExtensionKit.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import SystemExtensions
1212
#error("SystemExtensionKit doesn't support Swift versions below 5.5.")
1313
#endif
1414

15-
/// Current SystemExtensionKit version 2.0.4. Necessary since SPM doesn't use dynamic libraries. Plus this will be more accurate.
16-
public let version = "2.0.4"
15+
/// Current SystemExtensionKit version 2.0.5. Necessary since SPM doesn't use dynamic libraries. Plus this will be more accurate.
16+
public let version = "2.0.5"
1717

1818
public let SystemExtension = SystemExtensionKit.shared
1919

0 commit comments

Comments
 (0)