iPhone Dev: IOKit - The Missing Public Framework

By Erica Sadun
April 14, 2009 | Comments: 3

IOKitGoneMissing.png

On Sunday, I was working on my open source UIDevice extensions for the upcoming revision of my iPhone Developer's Cookbook. The Objective-C category that I've been building for a few months extends the UIDevice class to produce more robust information. With this code, UIDevice can now report its MAC address, its IP address, and express whether it supports a built-in camera or microphone, among other features. Here's a quick overview of the current interface:

enum {
  UIDeviceSupportsGPS  = 1 << 0,
  UIDeviceBuiltInSpeaker = 1 << 1,
  UIDeviceBuiltInCamera = 1 << 2,
  UIDeviceBuiltInMicrophone = 1 << 3,
  UIDeviceSupportsExternalMicrophone = 1 << 4,
  UIDeviceSupportsTelephony = 1 << 5,
  UIDeviceSupportsVibration = 1 << 6
};
 
@interface UIDevice (Hardware)
 
- (NSString *) platform;
- (int) platformType;
- (int) platformCapabilities;
- (NSString *) platformString;
 
- (NSUInteger) cpuFrequency;
- (NSUInteger) busFrequency;
- (NSUInteger) pageSize;
- (NSUInteger) totalMemory;
- (NSUInteger) userMemory;
- (NSUInteger) maxSocketBufferSize;
 
- (NSString *) macaddress;
- (NSString *) hostname;
- (NSString *) localWiFiIPAddress;
- (NSString *) localIPAddress;
@end

A couple of things that are not reported are the device IMEI and serial numbers. These are both pieces of information that I know are available via IOKit, as I use that framework in my jailbreak deviceinfo program which is part of my Erica Utilities. The I/O Kit registry stores hierarchical information about the hardware installed on a device.

You can get a sense of the kind of information available through this registry by running the ioreg command-line utility on a Macintosh. These details will obviously vary between an OS X system and an iPhone but you can see how the registry stores a huge amount of system information that can be valuable to developers. Enter ioreg -w0 -l | more at the terminal and be prepared for a major information dump.

After tweeting about wishing that IOKit were public, I was surprised to be reminded that in fact it is. iPhone developer Layton Duncan pointed out that the framework lived in the public arena, and not in Apple's protected PrivateFrameworks directory. So off I went to try to put this knowledge to use.

In Xcode, I was surprised to see that Apple didn't include IOKit header files. When I tried to add #import <IOKit/IOKit.h>, the file could not be found. So I manually put together a simple header file by hand, added IOKit to my frameworks and attempted to compile.

As you can see from the screenshot at the top of this post, I failed to do so. Xcode complained that the IOKit framework could not be found. Despite being filed as public, IOKit is apparently not meant to be used by the general public. As iPhone evangelist Matt Drance tweeted, "IOKit is not public on iPhone. Lack of headers and docs is rarely an oversight."

In the official docs, I found a quote that described IOKit as such: "Contains interfaces used by the device. Do not include this framework directly." So in the end, my desire to access that IOKit information was thwarted. For whatever reason, Apple has chosen to list it as a public framework but the reality is that it is not.


You might also be interested in:

3 Comments

Erica you rock !
You always come out with real new news. Not like those people just relaying it
Keep it up!

You actually DO rock! I was thinking the same thing right before I read the last comment.

two years later, but anyway

anybody know where to download the iokit framework?

News Topics

Recommended for You

Got a Question?