自动化 Xcode' 调试 > 模拟位置命令
Automating Xcode' Debug > Simulate Location command
有没有编程方式来控制xcode > simulate location
命令?我有我想要 运行 的外部位置测试脚本,理想情况下,测试套件可以导致 xcode 随意更改连接的 phone 的位置。
这可能吗?如果可能的话怎么办?
不确定这是否正是您所追求的,但您可以通过在方案中进行设置,让不同的单元测试包使用不同的位置(或 GPX 文件)。
然后您可以在每个包中进行单元测试,测试您对特定位置的需求。
xctool 还可以 运行 使用 -only 选项在特定目标中进行单元测试:
path/to/xctool.sh \
-workspace YourWorkspace.xcworkspace \
-scheme YourScheme \
test -only SomeTestTarget
是的,这是可能的。
1. 按照@InsertWittyName 的回答或 as described in this blog post 中的描述设置 GPX 文件。
2. 使用 Instruments 运行 使用不同的 GPX 文件在模拟器中使用您的应用程序。
我会写出整个过程,但是someone more eloquent than myself already has。
作为一个狂热的 S/O 用户,如果我留下基本上是单一 link 的答案,我会感到很遗憾。所以这里有一些额外的奖励信息。
你一定要看看 security testing your location aware features。今年我会参加 Black Hat,所以如果你在那里,我们来谈谈吧!
如果你不喜欢之前linked/sort的解释答案,你可以使用XCTest with code to simulate different locations (like this).
貌似还有Apple Script的解决方案,like this one。
我希望我至少提供了足够的信息来证明不仅仅是一个懒惰的 link-only 答案。享受,祝你好运!
有一个名为 Pokemon-Go-Controller 的 GitHub 项目可以满足您的需求。
解决方案概述:
- 创建
gpx
文件
- 创建一个引用(不复制)该
gpx
文件的空白项目,并 运行 它在您的设备上
- 运行 自动答题器将在 Xcode
中持续点击 update location
- 使用一些脚本更新
gpx
文件,设备位置将自动更新
您可以使用此 Apple 脚本代替自动答题器:
#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
idevicelocation 是在 ios 设备中模拟地理定位的命令行工具。
用法:
$ idevicelocation [OPTIONS] LATITUDE LONGITUDE
设置位置传递两个参数,纬度和经度:
$ idevicelocation 48.856614 2.3522219000000177
传递负值:
$ idevicelocation 77.432332 -- -7.008373564
停车位置模拟:
$ idevicelocation --stop
选项:
-d enable connection debug messages.<br/>
-u specify device UDID.<br/>
-h help.<br/>
-s stop location simulation on device.
它使用 libimobiledevice 库与进程 com.apple.dt.simulatelocation 通信,Xcode 也出于相同目的在内部使用该进程。
构建说明在自述文件中。
确保在随机放置之前安装正确的开发人员映像。
感谢 Angulo 编写了这个很棒的实用程序。
此工具目前未随 libimobiledevice 软件包一起提供,尽管 Pull Request 长期以来一直处于待定状态。
有没有编程方式来控制xcode > simulate location
命令?我有我想要 运行 的外部位置测试脚本,理想情况下,测试套件可以导致 xcode 随意更改连接的 phone 的位置。
这可能吗?如果可能的话怎么办?
不确定这是否正是您所追求的,但您可以通过在方案中进行设置,让不同的单元测试包使用不同的位置(或 GPX 文件)。
然后您可以在每个包中进行单元测试,测试您对特定位置的需求。
xctool 还可以 运行 使用 -only 选项在特定目标中进行单元测试:
path/to/xctool.sh \
-workspace YourWorkspace.xcworkspace \
-scheme YourScheme \
test -only SomeTestTarget
是的,这是可能的。 1. 按照@InsertWittyName 的回答或 as described in this blog post 中的描述设置 GPX 文件。 2. 使用 Instruments 运行 使用不同的 GPX 文件在模拟器中使用您的应用程序。
我会写出整个过程,但是someone more eloquent than myself already has。
作为一个狂热的 S/O 用户,如果我留下基本上是单一 link 的答案,我会感到很遗憾。所以这里有一些额外的奖励信息。
你一定要看看 security testing your location aware features。今年我会参加 Black Hat,所以如果你在那里,我们来谈谈吧!
如果你不喜欢之前linked/sort的解释答案,你可以使用XCTest with code to simulate different locations (like this).
貌似还有Apple Script的解决方案,like this one。
我希望我至少提供了足够的信息来证明不仅仅是一个懒惰的 link-only 答案。享受,祝你好运!
有一个名为 Pokemon-Go-Controller 的 GitHub 项目可以满足您的需求。
解决方案概述:
- 创建
gpx
文件 - 创建一个引用(不复制)该
gpx
文件的空白项目,并 运行 它在您的设备上 - 运行 自动答题器将在 Xcode 中持续点击
- 使用一些脚本更新
gpx
文件,设备位置将自动更新
update location
您可以使用此 Apple 脚本代替自动答题器:
#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
idevicelocation 是在 ios 设备中模拟地理定位的命令行工具。
用法:
$ idevicelocation [OPTIONS] LATITUDE LONGITUDE
设置位置传递两个参数,纬度和经度:
$ idevicelocation 48.856614 2.3522219000000177
传递负值:
$ idevicelocation 77.432332 -- -7.008373564
停车位置模拟:
$ idevicelocation --stop
选项:
-d enable connection debug messages.<br/>
-u specify device UDID.<br/>
-h help.<br/>
-s stop location simulation on device.
它使用 libimobiledevice 库与进程 com.apple.dt.simulatelocation 通信,Xcode 也出于相同目的在内部使用该进程。
构建说明在自述文件中。
确保在随机放置之前安装正确的开发人员映像。
感谢 Angulo 编写了这个很棒的实用程序。
此工具目前未随 libimobiledevice 软件包一起提供,尽管 Pull Request 长期以来一直处于待定状态。