anyone out there tried mocking location on map for iOS UI Tests programmatically (not using edit scheme > allow location simulation) please?
Asked
Active
Viewed 293 times
0
-
Are you not aware of GPX file? – Abu Ul Hassan Apr 09 '19 at 07:34
1 Answers
0
Create a protocol and mock location manager
import CoreLocation
protocol LocationManager: class {
var location: CLLocation? { get }
}
final class MockCLLocationManager: LocationManager {
var location: CLLocation? {
return CLLocation(latitude: CLLocationDegrees(exactly: 52.51657052665494)!,
longitude: CLLocationDegrees(exactly: 13.381044881575008)!)
}
}
extension CLLocationManager: LocationManager { }
Then in your map view controller:
let locationManager: LocationManager = MockCLLocationManager()
I can't get the map view to display the blue user location indicator this way though.

Kacper Cz
- 504
- 3
- 17