如何在iOS模拟器中禁用系统位置警报

问题描述:

我使用KIF框架( http://github.com/kif-framework/KIF ),并使用Xcode Continuous Integration Server进行UI测试。

I use KIF framework (http://github.com/kif-framework/KIF) with Xcode Continuous Integration Server for UI testing.

当iOS Simulator系统中的XCode CI服务器启动应用程序时,会出现应用程序想要使用您当前的位置警报。

When XCode CI server start app in iOS Simulator system alert "Application would like to use your current location" appears.

我使用此委托人

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus: (CLAuthorizationStatus)status

以获得用户允许使用位置和我需要它保持原样。

to get the notification that user allows to use location and I need it to keep like it is.


  1. 是否可以使用KIF在此系统警报上点击确定?我没有找到方法。

  2. 或者如何在不显示此警报的情况下允许应用程序在模拟器中使用位置服务?


根据此从最重要的KIF贡献者那里得到答案,不可能自动解除系统警报,因此,您应该模拟(即替代)定位服务,以便您可以测试代码而不会遇到警报。

According to this answer from the top KIF contributor, dismissing system alerts automatically is impossible, and you should therefore mock (i.e. provide a substitute for) the location service so that you can test your code without running into the alert.