English 中文(简体)
了解应用程序是否在测试环境中运行
原标题:Knowing if the app is running in a testing environment

是否有办法知道程序是否在开发环境中运行? 我使用卷风分析器,想要通过不同的应用程序代号, 这样数据就不会在开发过程中被我的测试弄脏了。

我喜欢的是这样的:

Boolean isDevEnv = .... (is this a test in the simulator or device,
                         OR is it a real user that downloaded the 
                         app through the app store?)
if (isDevEnv)
  [FlurryAnalytics startSession:@"firstAppId"];
else
  [FlurryAnalytics startSession:@"secondAppId"];

坦白说,

最佳回答

看来这是Xode默认完成的,在项目构建设置中,在 Apple LLLVM 汇编器3.1 - 预处理 (这是用于未来参考的Xcode 4.3.2)下,一个称为 DEBUG 的设置含有数值 1

所以,我其实没有做任何事情, 只是代码中的这个(在我的例子中, AppDelegates s d Finish Launching with Options 方法) :

[FlurryAnalytics startSession:DEBUG ? @"firstAppId" : @"secondAppId"];
问题回答

在建筑设置中,您必须设置标志, 取决于建筑内容 。

使用 #ifdef 和 #define 设置适应。

#ifdef DEBUG
#    define APPID ...    
#else
#    define APPID ...
#endif

在您的构建设置中,定义 AppStore 发布版本的新标志。 然后使用 来决定要使用哪个程序 。

如果您不想使用 DEBUG 旗和 DEBUG 环境, 创建新的建筑配置( 重复发布配置), 在构建设置中, 预处理器宏会添加一个卷轴分析标志 。 在您的代码检查 < code> if (FlurryAlytics) 中, 在 XCode 中创建一个新方案, 利用此新的发布构建配置创建 ipa 。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签