本文介绍了以编程方式扩展iOS字典应用程序词典的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apple App Store中有一个应用程序可以下载自定义的字典,并以编程方式将其添加到iOS的内置Dictionary.app中,无需用户干预。它正常使用库存ROM,即没有越狱或任何这样的需要。



我不知道这是可能的,因为苹果从未记录过这样的功能。 在iOS和Dictionary.app文档中没有API或提示来解释这是如何完成的。



如何实现?

解决方案

Dictionary.appender应用程序使用私有框架 MobileAsset.framework 。应用程序使用几个选择器:




  • setQueriesLocalAssetInformationOnly: / p>


  • runQueryAndReturnError:


  • initWithAssetType:属性:。资产类型为iOS< code> com.apple.MobileAsset.DictionaryServices.dictionary 7和 com.apple.MobileAsset.DictionaryServices.dictionary2 for iOS> = 7.它们保存在 / var / mobile / Library / Assets / / code>。




这里是框架的类转储,您可以在其中找到这些选择器的方法。



为了调用它们,应用程序使用非常简单的技术 - NSClassFromString 在运行时获取类对象。在我们的例子中, ASAsset ASAssetQuery 类。我不知道如何在App Store中获得批准,但这是如何工作的。非常简单的技术,选择器和类名称甚至不加密。



更新



该应用没有显式地链接私人 MobileAsset.framework 。它不使用任何常规技术来动态加载框架 - 不需要$ code> dlopen NSBundle 调用。导入表不包含私人 MobileAsset.framework 。但是它被 UIKit.framework 链接,这显然是由应用程序链接的。我做了一个简单的测试。写了一个剥离的控制台应用程序,通过关闭可能自动链接框架的所有项目设置来链接所需的框架。没有 UIKit.framework 执行 NSClassFromString(@ASAsset)返回nil。使用 UIKit.framework 它返回 ASAsset 类对象。


There is an app in the Apple App Store that downloads custom dictionaries and programmatically adds them to the iOS's built-in Dictionary.app without user intervention. It works normally with the stock ROM, i.e. no jailbreak or anything of that sort is required.

I wonder how this is possible since Apple has never documented such a "feature." There is no API or hints in the iOS and Dictionary.app documents to explain how this is done.

How could this be implemented?

解决方案

Dictionary.appender app uses private framework MobileAsset.framework. There are several selectors that the app use:

  • setQueriesLocalAssetInformationOnly:

  • runQueryAndReturnError:

  • initWithAssetType:attributes:. Asset types are com.apple.MobileAsset.DictionaryServices.dictionary for iOS < 7 and com.apple.MobileAsset.DictionaryServices.dictionary2 for iOS >= 7. They are saved in /var/mobile/Library/Assets/.

And here's class-dump of the framework https://github.com/nst/iOS-Runtime-Headers/tree/master/PrivateFrameworks/MobileAsset.framework where you can find methods with those selectors.

In order to call them the app uses very simple technique - NSClassFromString to obtain class object in runtime. In our case, ASAsset and ASAssetQuery classes. I don't know how this got approved in App Store but that's how it works. Very simple technique , selectors and class names are not even encrypted.

UPDATE

The app doesn't explicitly link private MobileAsset.framework. It doesn't use any of the usual techniques to dynamically load a framework - no dlopen or NSBundle calls. Import table doesn't contain private MobileAsset.framework either. But it linked by UIKit.framework which obviously is linked by the app. I did a simple test. Wrote a stripped out console application that links only needed frameworks by turning off all the project settings that may automatically link the frameworks. Without UIKit.framework executing NSClassFromString(@"ASAsset") returns nil. With UIKit.framework it returns ASAsset class object.

这篇关于以编程方式扩展iOS字典应用程序词典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 07:27