Crash on iOS calling GMSMapView.mapWithFrameCamera
I'm migrating a large NativeScript JavaScript project from version 6.8 to 8.1 - a very big leap with lots of breaking changes. I make heavy use of Google Maps and the nativescript-google-maps-sdk plugin. I'm at a point where I'm migrating my map-page, and I get an immediate crash on iOS calling GMSMapView.mapWithFrameCamera
:
this.nativeView = GMSMapView.mapWithFrameCamera(CGRectZero, this._createCameraPosition());
I understand this to be the JavaScript binding for mapWithFrame:camera:
. The call is within the Google Maps plugin, and I've used two different versions of the plugin (from kefaB and jamescodesthings) and the crash occurs on both.
My problem is what to do next. No exception is thrown, and there are no messages, just an immediate crash. I created a small sample project with only the map creation and that works OK. I added the additional plugins from my main project and the sample still works OK. I've been banging my head on this for almost 2 weeks now and I've GOT to get it working.
My question: how to debug this, given that try/catch, stepping into within a debugger, and tracing have all yielded zero results? I'll appreciate any insights.
Note: I have also created an issue on kefaB/nativescript-google-maps. I'm creating this post to get more visibility, and because the fix may not be within the plugin.
I've finally found the issue, and it was a simple coding error in app.js where I specify the map API key. In particular, I had:
if (application.isIOS) {
GMSServices.provideAPIKey(<my API Key>);
}
See the problem? isIOS
is a property for platform, but for application the corresponding property is just ios
(should be all lower case - autocorrect keeps changing). Hence, the API Key was never being specified.
The lesson here, though, is that there was no exception thrown or error message. So, if you're getting an unexpected crash navigating to a page that contains a Google map, check to see that your API key is being specified.