如何使用iPhone SDK私有API

发布于 2024-09-02 03:27:57 字数 1026 浏览 2 评论 0原文

我还没有找到使用 iPhone 库中的私有 API 所需步骤的完整列表。

特别是,我想知道如何获取头文件,如果需要的话,如何让它编译(当我简单地添加头文件时,它会抱怨函数未定义),以及可以使用哪些资源用于了解私有 API(例如,根据其他用户的经验,例如 http://iphonedevwiki.net/ )几个)。

我在其他地方读到人们建议使用 class-dump 来获取标头。有其他方法吗?我注意到有 一些 iPhone Private SDK 存储库,其中最重要的是您会推荐最新的资源吗?

大部分以前 有关私有 API 文档的问题,均链接至 Erica Sadun 的网站,似乎不再有文档(左侧的所有链接都被划掉了)。

请保存关于不使用私有 API 的评论...我知道最大的风险:

  • 应用程序将被 Apple 拒绝。
  • 应用程序将在操作系统的未来更新中中断。

我说的是合法用途,例如:

  • 私人应用程序使用(例如用于单元测试,或者闲逛看看有什么可能)

I haven't found a comprehensive list of the steps that are required to use a private API from the iPhone Library.

In particular, I would like to know how to get header files, if they are even required, how to get it to compile (when I simply add the header, it complains that the functions aren't defined), and what resources one can use to learn about private APIs (e.g. from other user's experiences, such as http://iphonedevwiki.net/ which has a few).

I've read in other places that people recommend using class-dump to get the headers. Are there any alternative methods? I've noticed that there are some repositories of iPhone Private SDKs, what are the most up to date resources you would recommend?

Most of the previous questions about documentation of private APIs, have all linked to Erica Sadun's website, which doesn't seem to have documentation anymore (all the links on the left are crossed out).

Please save the comments about not using private API's... I know of the biggest risks:

  • App will get rejected by Apple.
  • App will break in future updates to the OS.

I'm talking about legitimate uses, such as:

  • Private application use (e.g. for unit testing, or messing around to see what's possible)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云淡月浅 2024-09-09 03:27:57

Objective-C 在编译的二进制文件中有足够的信息来几乎完全重建头文件。唯一缺少的是参数名称(通常可以从类型或方法原型近似)以及一些结构和枚举定义。这就是为什么像 class-dump 这样的程序是获取标头的最佳方法。它们是全面的,包括每个方法,无论它是否在真实的标头中,都是最新的并且不需要分发。获取标头的另一种方法是查看同一框架的公共版本,例如 WebKit 仅在 iPhone 上是私有的,并且在其他方​​面有详细记录。

如果你对 Objective-C 之外的东西感兴趣,你几乎必须采用老式的方式,通过反汇编来猜测函数参数。一旦您获得一些符号,搜索它们,也许您会找到其他人发布的标题。 otool 是一个很好的起点。

如果您包含标头,无论是 Objective-C 还是 C,您还必须包含标头为其声明方法的框架或库,就像任何其他标头一样。大多数 Objective-C 内容都位于常规 Frameworks 文件夹旁边的 PrivateFrameworks 文件夹中。您可以在 usr/lib 文件夹中查找库。

请注意,模拟器和设备之间存在很多差异,因此请确保从真实设备构建标头。还有一些方法您无权作为沙盒应用程序运行。

Objective-C has enough information in the compiled binary to almost completely reconstruct the headers. The only things missing are argument names, which can often be approximated from the type or method prototype, and some structure and enum definitions. That is why programs like class-dump are the best way to get the headers. They are comprehensive, including every method whether it was in the real header or not, up to date and do not need to be distributed. The other way to get headers is to look in the public version of the same framework, for example WebKit is only private on the iPhone and is otherwise well documented.

If you are interested in things besides Objective-C you pretty much have to do it the old fashioned way, slogging through disassembly to guess function arguments. Once you get a few symbols, search for them and maybe you will find a header someone else has posted. otool is a good place to start.

If you include the headers, be it for Objective-C or C, you must also include the frameworks or libraries the headers declare methods for, just like any other headers. Most of the Objective-C stuff is in a PrivateFrameworks folder right next to the regular Frameworks folder. You can look in the usr/lib folder to find libraries.

Be aware that there are lots of differences between the simulator and the device, so make sure you build headers from the real device. There are also some of methods that you will not have permission to run as a sandboxed app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文