`
shappy1978
  • 浏览: 703434 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

How to get IMEI

 
阅读更多

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.

分享到:
评论

相关推荐

    How to Get Ideas - Jack Foster.pdf

    How to Get Ideas - Jack Foster.pdf

    How to get a PhD(怎样获得博士学位)

    一本经典的指导读博的好书,正在读博士的兄弟们可以看看,会有一定收获的。

    「安全认证」How to Get Promoted:Developing Metrics to Show How Thre

    「安全认证」How to Get Promoted:Developing Metrics to Show How Threat Intel Works - 恶意软件 数据安全 防火墙 身份管理 安全体系 安全漏洞

    linux howto中文合集

    HOWTO-html&lt;br&gt;News-HOWTO-html&lt;br&gt;News-Leafsite-html&lt;br&gt;Oracle-HOWTO-html&lt;br&gt;Plug-and-Play-HOWTO-html&lt;br&gt;PPP-HOWTO-html&lt;br&gt;Printing-HOWTO-html&lt;br&gt;QT 3.3 中文白皮书.pdf Quota RCS-...

    最基础的听力训练和测试——哈曼How to listen

    《哈曼How to listen:开启你的听力训练之旅》 听力的敏锐度并非与生俱来,而是需要通过后天不断的训练和提升。对于音乐爱好者和音频工作者而言,对声音细节的感知力至关重要,它关乎于对音乐的理解,对音频作品的...

    Unit_3_How_do_you_get_to_school课件.ppt

    Unit_3_How_do_you_get_to_school课件.ppt

    How To Listen (Public) 2.0.4 Setup.zip

    "How To Listen"是一款专为提升用户听力敏感度和音质辨识能力设计的训练软件,尤其适用于音乐制作人、音频工程师以及任何对声音有高要求的人群。这个名为"How To Listen (Public) 2.0.4 Setup.zip"的压缩包包含了该...

    HowTo2152.zip_howto2152

    包含了将近100张图表,这些图表能用来根据载流能力和温度限制条件来精确估计导线的宽度,这个Excel工具允许设计者根据不同的叠层结构和设计条件填入不同的数值来计算导线宽度。很简单的在绿色单元格内输入项目的设计...

    Very simple application which shows how to get your PC’s IP

    Very simple application which shows how to get your PC’s IP address using the VB Winsock control.

    C++ How to Program, 10th Edition

    C++ How to Program (10th Edition) By 作者: Harvey M. Deitel Paul Deitel ISBN-10 书号: 9332585733 ISBN-13 书号: 9789332585737 Edition 版本: 10th 出版日期: 2017 Format: Paperback C++ How to Program ...

    Linux Howto 中文文档

    Linux HOWTO(中文版) BootPrompt-HOWTO (28KB) 启动提示说明 CDROM-HOWTO (27KB) 如何安装, 设定及使用光驱,同时列出支援的硬体. Chinese-HOWTO (39KB) 如何在 Linux 的系统上使用中文?/TD&gt; Config-...

    RK3399的DRM-HOWTO测试

    RK3399的DRM-HOWTO测试 最近在学习与调试RK3399的DRM显示架构,网上有很多例程,其中介绍比较多的是来于David Herrmann’s Github的drm-howto.开源代码 但这些源码下载后执行make编译出来的执行文件只能在PC机上测试...

    How to Write papers in English

    【如何用英语撰写论文】 撰写学术论文是科研工作中不可或缺的一部分,尤其在国际交流日益频繁的今天,用英语写作论文显得尤为重要。以下是一些关键要点,旨在帮助你提高英文论文的撰写质量。 ...

    Galaxy is born Hands-How to get Android O Developer Preview Issue 37 2017

    Android AdvisorA A Galaxy is born Hands-on with Samsung's 2017 flagship phones - How to get Android O Developer Preview Issue 37 2017

    How To Write A Dissertation

    How To Write A Dissertation

    英语新目标八年级上Unit How do you get to school PPT课件.pptx

    这篇PPT课件是针对英语新目标八年级上册Unit "How do you get to school"的教学资源,旨在帮助学生学习和掌握与出行方式相关的词汇和表达。本单元的重点在于理解和运用与交通方式、时间和到达地点相关的英语句型。 ...

    Linux中文HOWTO

    Linux中文HOWTO Linux中文HOWTO Linux中文HOWTO

    C++大学教程C++ How to Program(中英文)

    《C++ How to Program》是C++编程领域的一本经典教材,由保罗·戴特尔(Paul Deitel)和哈维·戴特尔(Harvey Deitel)共同编写,提供了全面且深入的C++学习资源。该教程分为第九版(9E)和第十版(10E),并提供中...

    最新的linux howto 中文合集

    # RedHat CD HOWTO, by Peter von der Ah , Morten Kjeldgaard &lt;mok@imsb.au.dk&gt;. 如何从 Red Hat 发行套件,自己制作像 Red Hat 一样的 CD-ROM. Updated 2 March 2000. # SMB HOWTO, by David Wood ...

Global site tag (gtag.js) - Google Analytics