[Tutorial] Import IOKit framework into Xcode project

While you’re developing iOS project on Xcode, you may need IOKit framework for some reason, such as get UDID of iDevice …etc, or using on Yalu’s project

The I/O Kit framework implements non-kernel access to I/O Kit objects (drivers and nubs) through the device-interface mechanism.

So, in this article, I tried to write down how I import IOKit framework into a Xcode project.

Things you need are:

  • Xcode 8 (This sample was builded on Xcode version 8 in macOS 10.12)
  • iOS SDK (It should be installed with your Xcode)
  • Trident – IOKit header files

Import Error

When you try to use IOKit, for instance:
#import <IOKit/IOKitLib.h>

you may meet error like this:
螢幕快照 2017-01-27 上午1.32.08

Step 1:Import IOKit Framework

Different from IOKit as a libraries on iOS 5, Apple change IOKit from library into framework on iOS 7.
So first of all, we need to import the IOKit framework in Xcode.app into our project

if you try to type in your terminal
$ find /Applications/Xcode.app/ -name IOKit.framework
you will find 5 different IOKit framework of 5 different platforms in Xcode.app

We need “iPhoneOS.platform” recently, the path is:


Then go to application Target → General in Xcode project tab, and find “Link Frameworks and Libraries“.

Press the add button on the bottom left and use “Add Other” button to find the framework in the specific path.
螢幕快照 2017-01-27 上午1.54.51

Find the IOKit.framework on the path I mentioned above and add it, after you finish it, it will show up in the area of “Link Frameworks and Libraries

Also remember check if the IOKit.framework also shows up at the area of “Link Binary with Libraries” at application Target → Build Phases in Xcode project tab

Step 2:Add header files of IOKit

I read some article on internet said that header files of IOKit framework will be at

but I couldn’t find any header files in the path, so I tried another way.
I use the header files in Trident and add it to my project.
First, download it form GitHub, what we need is a folder in it Trident-master/Headers/IOKit called IOKit

Copy the IOKit folder to $(SRCROOT) – the path to the directory containing your Xcode project

Then link the folder to your project, drag the folder to the project’s “Groups & Files” area

螢幕快照 2017-01-27 上午2.13.46

Step 3:Make Xcode find header files you added

Go to application Target → Build Setting in Xcode project tab, and search “Header Search Paths” by search bar on the top right of navigator.

and add $(SRCROOT) into the item, remember change the option to “recursive”
螢幕快照 2017-01-27 上午2.50.58

Then it done.
Remember to clean your project (CMD+SHIFT+K) and build it again


  1. I have done all your steps but XCode keeps telling me “No such module named ‘IOKit'” when I try to write “import IOKit”


這個網站採用 Akismet 服務減少垃圾留言。進一步瞭解 Akismet 如何處理網站訪客的留言資料