检测iOS应用的AppStore安装 [英] Detect AppStore installation of iOS app

查看:26
本文介绍了检测iOS应用的AppStore安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的应用中实现自定义日志记录.

I need to implement a custom logging in my app.

为此,我需要检测当前版本的应用程序是否已从应用程序商店安装或正在从 xcode 运行或是否为 TestFlight 版本.

To do this i need to detect if the current version of the app has been installed from the app store or is running from xcode or is a TestFlight version.

根据安装源的不同,应用中有什么不同吗?

There is something different in the app depending from the installation source?

我不想在开发环境中有一些不同的东西.

I don't want to have something different in the development environment.

推荐答案

您可以通过从应用程序包中读取 Embedded.mobileprovision 文件来获得部分方法:

You can get part of the way there by reading in the embedded.mobileprovision file from the application bundle:

NSString *provisionPath = [[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"];

如果不存在,则您在应用商店构建中.

If that does not exist, you are in an app store build.

如果确实存在,您需要找出调试配置文件和临时配置文件之间的一些区别,并寻找它来确定您在哪个版本中.

If it does exist, you need to figure out some difference between your debug and ad-hoc provisioning profiles, and look for that to determine which build you are in.

因为 XCode 会在 Debug 配置中自动设置带有DEBUG"标志的应用程序,该标志未在 Release 中设置(默认情况下用于 AdHoc 构建),您最好在应用商店构建中禁用日志记录并根据 DEBUG 宏标志确定日志记录级别.

Because XCode automatically sets up applications with a "DEBUG" flag in the Debug config, that is not set in Release (which is used by default for AdHoc builds), you may be better off disabling logging in an app store build and determining the level of logging based on the DEBUG macro flag.

这篇关于检测iOS应用的AppStore安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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