Get system information using Swift

Is there a way to get some system information, such as CPU name and word size, using only Swift standard library and/or Foundation?

A lot of info like this is available using sysctlbyname, a Darwin API that’s relatively easy to call from Swift. To get started, read its man page, then the sysctl man page (in both sections 3 and 8).

For an example of how to call it from Swift, see this DevForums.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

1 Like