8

In Xcode 7 Apple added XCUITest as the new and preferred way to test the UI of your application.

I want to migrate my old testing script, but haven't found any information on how to set a custom core location when using XCUITest.

Old call:

UIATarget.localTarget().setLocation({latitude: '48.21048', longitude: '16.3595'});

I also tried to find some information on how to provide a GPX-File as a workaround via launch arguments, but had no success and idea if this is possible and what the key would be.

Does anyone know how to set a custom core location using XCUITest?

Max MacLeod
  • 26,115
  • 13
  • 104
  • 132
  • 1
    have the same issue. The location set on the scheme's Run Options is ignored. Setting Test Location on the Test's UI target is also ignored. Setting on the Debugger does work. However that is useless as I need something - using either argument, code, or scheme - to work in Xcode CI. Don't suppose you eventually resolved this? – Max MacLeod Jul 13 '16 at 10:24
  • 1
    No, unfortunately I haven't. But thanks for your comment! Now I realize that I have to solve this problem in the next 2–3 weeks. We are launching our app in a new market and the location in the test target should be used for automatically capturing screenshots for all devices in all available markets. – Tobias Kreß Jul 14 '16 at 11:31

1 Answers1

4

WWDC Session 409 Advanced Testing and Continuous Integration WWDC 2016 offers a big clue on this.

In short, it's not possible. At least as of Xcode 8.

Apple engineers in the video configure the location - or rather, they disable location - manually using the simulator settings.

To run a Bot against a specific location, one must first create the new simulator using the CI machine's Xcode Devices. Then, edit the Bot and select "Specific iOS Devices" on the Devices tab.

Max MacLeod
  • 26,115
  • 13
  • 104
  • 132
  • 1
    Thanks for the hint. Will be watching the video in the next few days. Not sure that this will help me, as I am using the XCUITest to capture screenshots with fastlane/snapshot and I think there are no bots/CI involved. – Tobias Kreß Jul 14 '16 at 11:34
  • 2
    Just watched the video. Unfortunately creating additional simulators seems to not work for me, because i need to be able to set the location in code (or at least provide it via launch arguments) to account for the different available languages (Tests for Germany should use the location of Berlin, tests for UK should use London). – Tobias Kreß Jul 28 '16 at 11:54