I am attempting to fetch hardware information on macOS using IOKit FFI bindings in rust. I am on a apple silicon machine running macOS 13.1, apple clang 14.0.0, xcode 14.2, and command line tools 14.2. I have reinstalled both xcode and command line tools multiple times. I am receiving the following error when attempting to build via cargo:
error: failed to run custom build command for `iokit_binding_test v0.1.0 (/Users/curlin/Desktop/master/school/school22-23/spring/cosc340/Watchtower/local/iokit_binding_test)`
Caused by:
process didn't exit successfully: `/Users/curlin/Desktop/master/school/school22-23/spring/cosc340/Watchtower/local/iokit_binding_test/target/debug/build/iokit_binding_test-c6ae1186e1f0394a/build-script-build` (exit status: 101)
--- stderr
wrapper.h:7:10: fatal error: 'IOKit/IOKitLib.h' file not found
wrapper.h:7:10: note: did not find header 'IOKitLib.h' in framework 'IOKit' (loaded from '/System/Library/Frameworks')
wrapper.h:7:10: fatal error: 'IOKit/IOKitLib.h' file not found, err: true
thread 'main' panicked at 'Unable to generate bindings: ()', build.rs:17:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
My cargo.toml:
[package]
name = "iokit_binding_test"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
libc = "0.2" # provides all definitions necessesary to easily interoperate with C code (or 'C-like' code) in rust
# includes type definitions (e.g. 'c_int'), constants, and function headers (e.g. 'malloc')
#[target.'cfg(macos)'.build-dependencies] -- target-specific build dependency header
[build-dependencies] # other cargo-based crate dependencies (can only be used in build.rs, which prepares external dependencies before build)
bindgen = "0.59
My wrapper.h:
#include <IOKit/IOKitLib.h
There are no headers located in my /System/Library/Frameworks/IOKit.framework/Versions/A directory. Attempting to locate these headers via xcode indicates that they are located in xcode's /Applications/ directory.
I've attempted to locate a solution here and on apple's developer boards, however the only information I've found consists of similar issues specific to IOS development, suggesting that I manually create a symlink for each header; and suggestions that I run an SDK pkg located in /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg, yet there is no package directory in that path on my machine.
Is <IOKit/IOKitLib.h> a deprecated include path, or do I have an issue in my configuration?
I apologize if this issue is trivial or documented, I have searched for existing solutions thoroughly to no end. I have little experience with rust or macOS development.