自动化Xcode的“debugging”>“模拟位置”命令

有没有任何编程方式来控制xcode > simulate location命令? 我有我想运行的外部位置testing脚本,理想情况下,testing套件可能会导致xcode随意更改连接的手机的位置。

这是可能的,如果是的话如何?

有一个叫做Pokemon-Go-Controller的GitHub项目,它完全符合你的要求。

解决scheme概述:

  1. 创build一个gpx文件
  2. 创build一个空白项目引用(不复制)该gpx文件并在设备上运行它
  3. 运行自动点击器,它会不断点击Xcode中的update location
  4. 使用一些脚本更新gpx文件,设备位置将自动更新

自动点击器,而不是你可以使用这个苹果脚本:

 #Will continue update the location to the location name below from Xcode: property locationName : "pokemonLocation" #name of your gpx filex ########################### tell application "System Events" tell process "Xcode" repeat while true click menu item locationName of menu 1 of menu item "Simulate Location" of menu 1 of menu bar item "Debug" of menu bar 1 delay 0.2 end repeat end tell end tell 

不确定是否正是你所要做的,但是你可以通过在scheme中设置不同的unit testing包使用不同的位置(或GPX文件)。

然后你可以在每个bundle中进行unit testing,testing你需要的特定位置。

方案

xctool也可以使用-only选项在特定目标中运行unit testing:

 path/to/xctool.sh \ -workspace YourWorkspace.xcworkspace \ -scheme YourScheme \ test -only SomeTestTarget 

对的,这是可能的。 1.如@InsertWittyName的答案中所述设置GPX文件,或如本博客文章所述 。 2.使用仪器使用不同的GPX文件在模拟器中运行您的应用程序。

我会写出整个过程,但有人比我更有说服力了 。

作为一个狂热的S / O用户,我将无法离开基本上是单链接的答案。 所以这里是一些额外的奖金信息。

  1. 你一定要考虑安全testing你的位置感知function 。 今年我将在黑帽会议,所以如果你在那里,让我们来谈谈它!

  2. 如果你不喜欢以前连接/解释的答案,你可以使用XCTest代码来模拟不同的位置( 像这样 )。

  3. 看起来像也有苹果脚本解决scheme, 就像这个 。

我希望我至less能够提供足够的信息,不仅仅是一个懒惰的链接答案。 享受,祝你好运!