iOS如何使用私有API? [英] iOS How to use private API?

查看:117
本文介绍了iOS如何使用私有API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不想将此应用程序提交给AppStore。我已经尝试了很多次但遇到了很多问题:(

I don't want to submit this app to AppStore. I've tried for many times but met so many problems :(

我使用class-dump来获取UIKit.framework的所有头文件。在UIApplication.h中通过类转储生成,我看到了我想要使用的方法---- launchApplicationWithIdentifier。

I use class-dump to get all the header files of UIKit.framework. In the UIApplication.h generated by class-dump, I saw the method I want to use----launchApplicationWithIdentifier.

然后我将UIApplication.h放入我的项目并导入它。编译,我得到了很多重新定义枚举器....错误,因为在我之前使用的UIKit.framework中,还有另一个UIApplication.h。但是这个文件没有startApplicationWithIdentifier方法。

Then I put UIApplication.h in my project and import it. Compile, I got a lot of "Redefinition of enumerator...." error because in the UIKit.framework I use previous, there's another UIApplication.h. But this file doesn't have the method launchApplicationWithIdentifier.

如果我删除以前的UIKit.framework并导入class-dump生成的文件夹。那么它看起来像一个框架但是如果我展开它,它就是空的。

If I delete the previous UIKit.framework and import the folder generated by class-dump. Then it appears like a framework but if I unfold it, it's empty.

然后我想让所有生成的头文件成为一个框架文件ant替换以前的UIKit.framework。但我不知道如何。正如我们所看到的,在系统框架目录下,有一个文件有与框架同名,并有一个'执行shell脚本'图标。我该怎么做这个文件?

Then I want to make all generated header files a framework file ant replace the previous UIKit.framework. But I don't know how. As we can see, under the system framework directory, there's a file which has the same name as the framework and has a 'executed shell script' icon. How can I made this file?

我真的很困惑。有人可以帮个忙吗?谢谢。

I really got confused. Someone can give me a hand? Thank you.

推荐答案

只需在要使用它的类实现上方的类别接口中指定私有方法,就像这样:

Just specify the private methods in a category interface above the class implementation where you want to use it, like this:

@interface UIApplication (Private)

- (BOOL)launchApplicationWithIdentifier:(id)identifier suspended:(BOOL)suspended;

@end

不要导入整个类转储文件和链接到原始的UIKit框架。

Don't import the whole class-dump file and link with the original UIKit framework.

使用私有API时必须非常小心。这些方法可以在将来的iOS版本中更改或删除!

You must be very careful when using private API. These methods can change or be removed in future iOS versions!

检查方法是否确实存在 respondsToSelector: at运行时并准备好它不存在的情况。

Check if the method really exists with respondsToSelector: at runtime and be prepared for the case that it does not exist.

我在自己的应用程序中使用了一个秘密的MapKit功能,我知道私有方法只存在于iOS 5中所以我的应用程序仍适用于所有iOS版本,但此功能仅适用于iOS 5(Apple已删除或在iOS 6 beta 1中更改)。

I used a secret MapKit feature in my own application and I knew that the private methods only exist in iOS 5. So my app still works in all iOS versions but this feature is only available in iOS 5 (Apple removed or changed it in iOS 6 beta 1).

这篇关于iOS如何使用私有API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆