-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from p-x9/feature/support-app-kit
Support MacOS Application
- Loading branch information
Showing
7 changed files
with
142 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Foundation | ||
import SystemConfiguration | ||
|
||
func printDeviceInfo() { | ||
let processInfo = ProcessInfo.processInfo | ||
|
||
print("[Device Info]") | ||
if let name = SCDynamicStoreCopyComputerName(nil, nil) { | ||
print("Name: \(name)") | ||
} | ||
|
||
if let model = sysctlByString(key: "hw.model") { | ||
print("Model: \(model)") | ||
} | ||
|
||
print("System Name: macOS") | ||
print("System Version: \(processInfo.operatingSystemVersionString)") | ||
|
||
if let cpu = sysctlByString(key: "machdep.cpu.brand_string") { | ||
print("CPU: \(cpu)") | ||
} | ||
} | ||
|
||
func sysctlByString(key: String) -> String? { | ||
var size: size_t = 0 | ||
sysctlbyname(key, nil, &size, nil, 0) | ||
var value = [CChar](repeating: 0, count: Int(size)) | ||
sysctlbyname(key, &value, &size, nil, 0) | ||
|
||
return String(cString: value) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters