Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
99
rated 0 times [  106] [ 7]  / answers: 1 / hits: 5500  / 10 Years ago, tue, june 24, 2014, 12:00:00

This is more of an informational post: I've spent the past few days struggling with a non-functional geolocation app on the latest iOS 8 Beta.



At first I wasn't sure if it was isolated to iOS 8, or if it was an issue of device vs simulator, but after re-downloaded XCode 6 Beta 2 (my first download had a broken simulator for some reason), I confirmed that indeed, iOS 8 Beta 2 simulator did not seem to like my attempts at grabbing a geolocation.



At first the call didn't seem to work at all; then I made a change from including phonegap.js to including cordova.js and finally made some progress. The documentation is awful on this, as following guides in the official docs seems to lead one to believe they're interchangeable. I would suggest those with issues check that first.



Rather than running the navigator.geolocation.getCurrentPosition(....) callback functions as expected, it would instead hang and not do anything at all. Sometimes navigating away from the page and back to it would force the error callback, but it was very inconsistent. After setting a { timeout: 5000 } option, it seemed to keep timing out every call. There were no errors to the console, no errors in XCode, nothing. The success function just would not run, period, and neither would the error callback if I didn't explicitly timeout after X seconds. This is an error isolated to the iOS 8 Beta, so nothing of concern to most (yet), but I felt I should post this in case someone ran into it. I'll also be posting on the Apple Dev Center.


More From » ios

 Answers
4

It's a known issue and is fixed here:



https://github.com/apache/cordova-plugin-geolocation/commit/4102a332b0c6b0c3513370a4c030a32e46a51e10#commitcomment-7791523



Just tested it in iOS8, it works.



Run the following command in platforms/ios folder of your phonegap project:



cordova plugin rm org.apache.cordova.geolocation
cordova plugin add https://github.com/apache/cordova-plugin-geolocation.git


For some reason it removes the CDVLocation.m from the compilation list, you need to revert that.



The entries In XXX.xcodeproj/project.pbxproj:



979B00CA27D6412CB8C6CF74 /* CDVLocation.m in Sources / = {isa = PBXBuildFile; fileRef = E3B4F7C4AF8242A09E9BF8C1 / CDVLocation.m */; };
979B00CA27D6412CB8C6CF74 /* CDVLocation.m in Sources */,


Without these 2 lines, the plugin is not available to use in the app.



If you have that file in source control just revert the deletions related to CDVLocation.m in XXX.xcodeproj/project.pbxproj.



If not try add CDVLocation.m to the Compile Sources step in the Build Phases in the project settings.


[#44341] Monday, June 23, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kaia

Total Points: 574
Total Questions: 109
Total Answers: 110

Location: Malaysia
Member since Wed, May 11, 2022
2 Years ago
;