Xamarin UITest "Unable to set fake location on iOS Simulator" - ios

I am testing a Xamarin Forms app on Android and iOS using Xamarin.UITest. Since the application depends on the GPS location, I need to set a fake location. I do this using
App.Device.SetLocation(latitude, longitude)
...where latitude and longitude are variables of type double which contain the desired coordinates.
This works fine on Android but fails on the iPhone Simulator with the following exception:
SetUp : Xamarin.UITest.XDB.Exceptions.DeviceAgentException : Unable to set location
ExitCode: 4
-d,--device-id <device-identifier> iOS Simulator GUID or 40-digit physical device ID
set-location <latitude,longitude>
Expected lat,lng: Got 48,135831,11,573423
I did some research and found a thread on the Xamarin Forums which says that it might help to round the fake coordinates to only 4 digits after the decimal point but it didn't help. Apart from that, I tried to hardcode the coordinates and to use floats instead of doubles but neither of the attempts worked.
What's going on there and how can it be fixed?
Here's my setup:
Xamarin.UITest version 2.2.4
iOS Simulator running iOS 9.3 on an iPhone 6
Host computer: Mac mini running MacOS High Sierra 10.13.6
The same issue occurred several months ago with the following setup:
Xamarin.UITest version 2.2.1
iOS Simulator running iOS 11.2 on an iPhone X
Host computer: Mac Mini running MacOS High Sierra (10.13.3)
At the time, I just left it alone, but now is the time where I need a fix.

Expected lat,lng: Got 48,135831,11,573423
It appears to be a bug in that Xamarin is using your local locale to convert those doubles to strings when they send them to simctl (and simctl is expecting decimal point-based strings or quoted decimals and thus it is parsing those are 4 separate numbers).
In your test code before setting the location, change the culture to en-US and set it back later to your actual culture if needed.
Something like this should work:
var currentCulture = CultureInfo.DefaultThreadCurrentCulture;
CultureInfo.DefaultThreadCurrentCulture = new System.Globalization.CultureInfo("en-US");"
// do some location setting / testing
CultureInfo.DefaultThreadCurrentCulture = currentCulture;

Related

Call directory extensions won't run on iPhone 5 but will on all other device types

I've got 3 iPhone 5, 2 iPhone SE, 2 iPhone 6, an iPhone 6+ and an iPhone 7.
I've found that my app which uses a call directory extension won't work on any of the three iPhone 5 devices but there's no problem with it working on the other 6 assorted devices.
In case there is some problem with my app, I created a new app with a call extension which was created entirely using the XCode project templates (the Xcode call directory target template creates a lot of boilerplate code which is fully functional and will run and work without further change).
I got the same results - the template app also does not run on any of the iPhone 5 but it does run on the other 6 devices.
The conclusion from this would appear to be that for some reason call extensions don't work on an iPhone 5, however this is not a correct assumption because I downloaded an app from the app store (Hiya) which uses call extensions onto an iPhone 5 and there were no similar problems with its call extension.
So it is a mystery to me why both my app and the Xcode template app both do not work on any of my iPhone 5 but they are fine on every other device.
And that therefore is my question - has anybody encountered a similar situation or has any speculation why they don't work on iPhone 5?
(Was there an architecture change after iPhone5 and the build settings of the call extension might need changing to get it to work on the iPhone 5 for example?)
The way my app and the Xcode template app fails on the iPhone 5 is the same
1) the extension does not appear in Setting | Phone | Call Blocking & Identification. This implies it may not have installed/registered with the OS properly, however I don't see any problems being logged by the OS in the console when looking at the OS logging.
2) The status of the extension cannot be queried on an iPhone 5:
let theExtension = CXCallDirectoryManager.sharedInstance
theExtension.getEnabledStatusForExtension(withIdentifier: "com.redacted.redacted.CallDirectoryApp.TheCallExtension") {(enabledStatus, error) -> Void in
if let err = error as? NSError
{
print ("\(err.code) \(err.localizedDescription) \(err.localizedFailureReason)")
}
}
The error is err NSError domain: "com.apple.CallKit.error.calldirectorymanager" - code: 1
Again this might indicate the problem is related to the extension not installing.
(The problem is independent of the version of iOS 10 used on the iPhone 5, its the same result with a few versions of both beta and non beta versions. All devices are registered on the provisioning portal)
The iPhone 5 is 32 bit and everything else is 64 bit. I changed Xcode's default settings for the extension to the following and it now works:

appcelerator iOS application error with geolocation module

We are developing app for iOS and Android and we are using Ti.Gelocation to getCurrentPosition and then set the Region of the MapView of ti.map module.
The app is already on marketplace and downloaded, so we are developing an important upgrade with this new feature. We dont't have problem with Android platform, but with iOS version of the app we get a several error invoking Ti.Geolocation module
The error on iOS 9.x on iPad and iPhone (we have no test on iPod) is:
-[__NSCFString containsObject:] unrecognized selector sent to instance 0x1463d500 at GeoView.js (line xxxx)
This error happens with the project with it.vocami.vocamiapp app-id, in the test project (ap-id=it.vocami.vocamitest) that we use for research and test of new features, no error happens and all run good. When we add at every level of our code (in the first row too), for example, Ti.Geolocation.locationServiceEnabled, in the main vocamiapp project, we get the error.
We have tried all we could think but at the end, if we change the app-id, the code runs otherwise we get the error. We cannot change the app-id because we need to update our published app.
We are developing with AppceleratorStudio version 4.5.0.021602170281 and Ti SDK ver 5.2.0GA on Mac OS X 10.10.5.
I just recently was "hit" by the fact that when I made my app ready for Google Play I use a specific key/user to sign it with. That behaves differently from just running it locally on the phone.
I had to make sure that I had registered two certificates with Google's API in the developer console. It didn't give me exactly the message that you show - but wouldn't show the map with a location. And the way I read the location prior to showing it on the map led me in the wrong direction looking at permissions on Android first :-)
/John

xcode sample project "CurrentAddress": where does current location come from?

I am using Xcode version 4.5.1 and OS X version 10.8.2.
I downloaded the CurrentAddress sample project (ver 1.2) and when I run it the first time it prompts "'CurAddress' Would you like to use your current location", to which I say OK. I cannot figure out from where the code is getting the location that it ends up using, which is in or near San Francisco, lat 37.7858, long -122.406. I have looked all over the project and cannot see where these values are coming from. Thanks for any help.
this comes from CLLocationManager, which either will get that data from the GPS sensor in your iphone device, or from the GPS simulation built in in iPhone Simulator.
San Francisco is the default GPS simulation track, near Apples Headquarter.
If you are running in simulator, go to simulator debug menu -> Location -> you can set any location here. If I am correct, your CLLocationManager should pick the current location in simulator from here. In device, it should pick the current location, if the same is enabled.

geocoder gives wrong address in ios 5

For 5.0, i use the clgeocoder and clplacemark, but i get "1 stockton street" everytime. I believe 1 stockton st is the address of an apple store in s.f. The Mk classes work for the same program for younger version simulators.
Why is the 5.0 simulator defaulting to the store's location?
Check out the Location Simulation section in the release notes for Xcode 4.2
You can also simulate movement using a GPX file, check this out Simulate Location including movement in Xcode 4.2 / iOS5
Earlier versions of iOS simulator have no location while iOS 5 Simulator have the ability to simulate location (note the location arrow at the bottom of xCode screen). I don't know how you simulate location changes in your code, but it may happen, that simulator activity interrupts your location changes chain.

Neither float nor double works on Blackberry OS 4.5

As soon as I add a float or a double variable to my program, it stops working on BB models 8100 and 8800, both running OS 4.5.
I have a couple of newer phones with OS 5 and 6, respectively, and the same binary works just fine on those.
Why would this be?
Also, see "Float or double on Blackberry?" which led to this question.
When the application is started, before it really starts, it shows an error message to the effect of "modules bla blah can not verify blah". I'll update the message to the real one when I get a chance to start the broken app again.
Your quoted error message is still "modules bla blah can not verify blah", which is kind of vague, but it sounds like you are building against a SDK that is newer than BlackBerry OS 4.5, and then trying to deploy the app to a 4.5 device.
It's possible that float and double are the first references that pull in modules that don't exist on OS 4.5, so it appears to you that they are breaking your app, when it is really a build issue.

Resources