xcode 如何检查您的 iOS 应用代码是否使用了应用商店不允许的 api?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9695408/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to check if your iOS app code is using an api that is not allowed on the app store?
提问by Pterie Daktyl
I know that there are some restricted api's or code that are not allowed to be in your app when you submit it to the app store.
我知道当您将应用程序提交到应用程序商店时,您的应用程序中不允许存在一些受限制的 api 或代码。
How do you know what they are? Is there a way to check your app before you submit it to ensure you have not used such api's?
你怎么知道它们是什么?有没有办法在提交之前检查您的应用程序以确保您没有使用此类 api?
It is probably better to avoid this problem at the design stage, than trying to fix it later, so I was wondering if there is any tool in Xcode, or document to determine this.
在设计阶段避免这个问题可能比以后尝试修复它更好,所以我想知道 Xcode 中是否有任何工具或文档可以确定这一点。
回答by Nate
The way Apple intends for you to do this is to use XCode's Validationfeature. When you're submitting an app, you build for achiving (or Archivefrom the XCode menu). Then, you open up Organizer to see the archive you just created. At this point, you can press the Validatebutton in Organizer. That will perform a validation, without actually submitting the app. It will tell you if you're using Private APIs. Depending on howyou use them, it might identify what the violation is:
Apple 打算让您这样做的方式是使用 XCode 的验证功能。当您提交应用程序时,您是为实现而构建(或从 XCode 菜单存档)。然后,您打开管理器以查看您刚刚创建的存档。此时,您可以按管理器中的验证按钮。这将执行验证,而无需实际提交应用程序。它会告诉您是否使用私有 API。根据如何使用它们,它可以识别违规是什么:
There's definitely ways that code can fool this validation step, and "get away" with using Private APIs until the reviewer looks at the bundle. But, as far as I know, those ways would all be intentional methods of hiding Private API usage, and it sounds like you're trying to discover accidental usage.
代码肯定有办法欺骗这个验证步骤,并在审阅者查看包之前“逃避”使用私有 API。但是,据我所知,这些方法都是有意隐藏私有 API 使用的方法,听起来您是在尝试发现意外使用。
If you fail this Validation test, then you might want to use something like AppScanner, mentioned in alan duncan's answer. But, for completeness, I wanted to make sure people knew that this Validation step is available in XCode, and checking for Private API usage is one of the things it's doing before you submit (and have to wait a few days to be told what you did wrong). Also, even if you don't use the Validatebutton in Organizer, but just use Submit, the tool is performing a Validation for you. The only difference is whether the bundle actually gets uploaded to iTunes Connect.
如果您未能通过此验证测试,那么您可能需要使用像艾伦邓肯的回答中提到的 AppScanner 之类的东西。但是,为了完整起见,我想确保人们知道 XCode 中提供了此验证步骤,并且检查私有 API 使用情况是在您提交之前它正在做的事情之一(并且必须等待几天才能被告知您做错了)。此外,即使您不使用Organizer 中的Validate按钮,而只是使用Submit,该工具也会为您执行验证。唯一的区别是捆绑包是否真正上传到 iTunes Connect。
回答by FluffulousChimp
If you stick to documented interfaces as suggested above, you're fine. The only issue is with third-party libraries whose implementation may be opaque to you.
如果您按照上面的建议坚持使用文档化的接口,那就没问题了。唯一的问题是第三方库的实现可能对您不透明。
There is a Mac app called AppScanner that scans from private API usage. I have no experience with it, though.
有一个名为 AppScanner 的 Mac 应用程序可以扫描私有 API 使用情况。不过,我没有这方面的经验。
回答by Vaquita
You will get more information on Apple approval process from
您将从以下网址获得有关 Apple 审批流程的更多信息
- App Store Review Guidelines for iOS apps(You must be a registered iOS developer for accessing this data).
- iOS Human Interface Guidlines.
- iOS 应用程序的 App Store 审核指南(您必须是注册的 iOS 开发者才能访问此数据)。
- iOS 人机界面指南。
回答by atool
- get the private API list.
- use class-dump to process the Mach-O file, and get the processed string.
- use regex to get the interface, class, or method in the string.
- match the API to private API list.
- 获取私有 API 列表。
- 使用 class-dump 处理 Mach-O 文件,并获取处理后的字符串。
- 使用正则表达式获取字符串中的接口、类或方法。
- 将 API 与私有 API 列表匹配。
then GOT it~
然后明白了~
I opened a porject to do this, but because the reason of my company, canceled. very sorry for this.
我开了一个项目来做这个,但是因为我公司的原因,取消了。对此非常抱歉。