检查 运行 应用程序或测试 UI

Check whether Running the app or Testing UI

只有在测试应用程序 (UITesting) 时 运行 我才需要一组代码,而不是 运行 应用程序时。我一直在尝试查找 运行ning 应用程序还是 UITesting?。

这是 xcode 8 及更高版本的新功能。

有人能帮我解决这个问题吗?

现在我们可以用“UITesting”的一行代码简单地检查一下。

[[[NSProcessInfo processInfo] arguments] containsObject:@"-ui_testing"]

-ui_testing只会在测试应用时出现。