This project lets your kernel extensions (kexts) target a broad range of XNU kernels when using the latest Xcode version right from the interface. In addition, it also includes several headers only available in other projects or older Xcode releases.
To start using MacKernelSDK do the following steps:
-
Clone MacKernelSDK to your project directory:
git clone https://github.com/acidanthera/MacKernelSDK
-
Add custom
KERNEL_EXTENSION_HEADER_SEARCH_PATHSandKERNEL_FRAMEWORK_HEADERSvalues in project configuration in Xcode. To do this choose Add User-defined Setting.KERNEL_EXTENSION_HEADER_SEARCH_PATHS = $(PROJECT_DIR)/MacKernelSDK/Headers KERNEL_FRAMEWORK_HEADERS = $(PROJECT_DIR)/MacKernelSDK/Headers -
Link to custom
libkmod.alibrary by adding it to your kernel extension Link Binary with Libraries. -
Ensure that Library Search Paths contains the
libkmod.alocation, e.g.:$(PROJECT_DIR)/MacKernelSDK/Library/x86_64Otherwise Xcode will link to the original libkmod.
-
Optionally add
/MacKernelSDKto.gitignore. -
To make sure that you use the right SDK check for
__ACIDANTHERA_MAC_SDKmacro inAvailability.h.
To compile for 32-bit you will need to add a set of flags in your project:
-
Other C Flags (
OTHER_CFLAGS):-static-nostdlib-Wno-stdlibcxx-not-found-target i386-apple-macos10.6-fallow-unsupported-fno-stack-protectorif targeting 10.5 and older-fno-jump-tablesif targeting 10.5 and older
-
Other Linker Flags (
OTHER_LDFLAGS):-static-target i386-apple-macos10.6
-
C++ Standard Library (
CLANG_CXX_LIBRARY) to Compiler Default or empty. -
Library Search Paths set to contain a kmod with an i386 slice, e.g. $(PROJECT_DIR)/MacKernelSDK/Library/universal.
-
The symbol table may be misaligned due to i386 kexts being of type
MH_OBJECT.
fix-macho32is provided in thescriptsdirectory of ocbuild to correct alignments. Python 3 andmacholibare required.Usage:
./fix-macho32 [bin_path]
- Based on macOS 11 SDK from Xcode 12.0 (12A7209)
- Added extra headers from
xnu-8019.80.24:- Absolute time macros (
libkern/OSBase.h) - Cryptography (
corecrypto,libkern/crypto) - CPU PM (
i386/cpu_topology.handi386/pmCPU.h) - MAC Framework (
security/_label.h,security/mac_framework.h,security/mac_policy.h) - Skywalk Subsystem (
skywalk,IOKit/skywalk/IOSkywalkSupport.h)
- Absolute time macros (
- Added private headers from IOHIDFamily 1446.140.2:
IOHIDPrivateKeys.hIOHIDEventServiceKeys_Private.hIOHIDEvent.hIOHIDEventFieldDefs.hIOHIDEventService.hIOHIDEventTypes.hIOHIDUtility.h
- Added private headers from IOHIDFamily 1035.70.7:
AppleHIDUsageTables.h(removed in newer releases)
- Added private headers for IOBluetoothFamily from 10.6 SDK
IOBluetoothInternal.h(removed in newer releases)
- Added private
IOPCIHostBridgeclass from IOPCIFamily 484.40.6 - Added extra compiled and reverse-engineered headers:
- SMBus (
IOKit/IOSMBusController.h) - Apple Smart Battery (
IOKit/battery/AppleSmartBatteryCommands.h) - KDP (
kdp/kdp_support.h) - NKE private APIs (
IOKit/network) - IOUSBFamily from macOS 10.10 SDK
- IO80211Family from Black80211 originally created by Roman Peshkov
- IOSkywalkFamily by cjiang (
IOKit/skywalk) - IOBluetoothFamily by cjiang (
IOKit/bluetooth) for macOS 11 and below
- SMBus (
- Added kmod targeting earlier macOS kernels:
- 10.6 64-bit or newer (
Library/x86_64/libkmod.a) - 10.4 or newer (
Library/universal/libkmod.a)
- 10.6 64-bit or newer (
- Added availability checking when targeting older macOS versions:
- In
string.hto avoid using new checked interfaces before 10.13 - In
IOService.hto avoid report virtual methods before 10.9 - In
RootDomain.hto avoid report virtual methods before 10.9 - In
OSMetaClass.hto avoid DriverKit usage before 10.15 - In
cdefs.hto avoid Darwin14 aliases before 10.10 - In
assert.hto avoid kext assertion checking before 10.12 - In
IOHIDDevice.hto avoid new virtual methods before 10.14 - In
IOFramebuffer.hto avoid new virtual methods before 10.13 - In
IONDRVFramebuffer.hto avoid new virtual methods before 10.13 - In
IOSCSIParallelInterfaceController.hto avoid new virtual methods before 10.7 - In
IOPCIBridge.hto avoid new virtual methods before 12.0 - In
IOService.hto avoid init methods before 10.10 - In
IOUserClient.hto avoid new virtual methods before 10.6 - In
IOBlockStorageDevice.hto avoid new virtual methods before 10.12 - In
ipc_mig.hto avoid new methods before 10.6
- In
- Fixed compiler warnings:
- In
IOPCIDevice.hdue to missing overrides - In
OSMetaClass.hdue to using unsupported memory checking with older clang - In
kauth.hdue to KPI deprecation - In
net,netinit,network,sysdue to NKE KPI deprecation - In
hid,serial,usbdue to missing overrides and KPI deprecation in favor ofDriverKit - In
OSUnserialize.hdue toOSStringPtrmisuse - In
KUNCUserNotifications.hdue to KPI deprecation - In
IOSCSIParallelInterfaceController.hdue to missing overrides - In
IOPCIBridge.hdue to missing overrides
- In
- Fixed incorrect compiler behavior:
- In
IOUserClient.hto avoid issues withIOExternalMethodon 32-bit platforms- Use
IOMethodACID32in place ofIOMethod, referencing a static method taking the class as the first parameter - Set
paddinginIOExternalMethodtokIOExternalMethodACID32Padding - Refer to the
IOExternalMethoddefinition for more details
- Use
- In

