cordova-plugin-geofence icon indicating copy to clipboard operation
cordova-plugin-geofence copied to clipboard

Requires swift 3.0 in Xcode 8.3

Open seed880505 opened this issue 7 years ago • 18 comments

Swift 2.3 is not supported and can not be built in Xcode 8.3 with the new iOS SDK 10.3.

seed880505 avatar Mar 29 '17 12:03 seed880505

Same issue after updating Xcode today 😕

VierenV avatar Mar 31 '17 13:03 VierenV

Try the update from here - https://github.com/ypelud/cordova-plugin-geofence/tree/d2e1f22340ac2cd07559598fd290df462e75055d/src/ios

Just copy paste the contents of the 3 files (GeoFencePlugin.swift , SwiftData.swift, SwiftyJson.swift) into your XCode build where you notice build errors for these 3 files and build again.

Till @tsubik - merges this here or Yann makes a release available, the above copy/paste is a working solution.

rafialikhan avatar Apr 04 '17 20:04 rafialikhan

@rafialikhan Yes, thanks for sharing what you have found. Swift is really my pain. I will have a try after updating to Xcode 8.3. If anyone already succeeded, you can post here your progress for sharing.

seed880505 avatar Apr 05 '17 08:04 seed880505

@rafialikhan thanks! your fix worked. I was able to compile after the following steps:

  • update the three files as mentioned
  • use "edit/convert/to current swift syntax" in XCode
  • remove swift legacy setting from my config.xml
  • fixed a remaining bug in swift code following this advice

Let's cross fingers, the code is still working - and that I do not have to rebuild the project...

StephanGieffers avatar Apr 13 '17 13:04 StephanGieffers

@StephanGieffers I was able to compile 1 week ago and now I'm getting errors. Has anyone else gotten this to work? Please help!

thoeunuch avatar Apr 19 '17 01:04 thoeunuch

Hi, I just compiled my app with the plugin with success - when opening the project in xcode, it asks if i would like to convert the code to swift 3. I click Convert. It then compiles with 2 errors. I then copy paste the 3 files from https://github.com/ypelud/cordova-plugin-geofence/tree/d2e1f22340ac2cd07559598fd290df462e75055d/src/ios into xcode and can then compile my app. The geofences seem to work as they should. Would be nice if the plugin was released on npmjs again with the fixes - they work fine for me.

compelling avatar May 04 '17 06:05 compelling

These files also worked for me, except I think I've been able to skip the step of having xcode convert things:

  1. add <plugin name="cordova-plugin-geofence" spec="~0.6.0" />
  2. add <plugin name="cordova-plugin-add-swift-support" spec="~1.6.2" />
  3. do not add preference tag for 'UseLegacySwiftLanguageVersion'
  4. cordova platform add ios (installs plugin, etc)
  5. swap three files above into place (platforms/ios//Plugins/cordova-plugin-geofence/)
  6. build your app - no swift errors/conversion necessary

josh-m-sharpe avatar May 05 '17 03:05 josh-m-sharpe

@josh-m-sharpe Check steps 1 and 2 above... 😮

lpender avatar May 05 '17 20:05 lpender

I need use the branch mentioned above plus the following steps:

Add:

#import "Geofence-Plugin-Bridging-Header.h"`

ToBridging-Header.h

lpender avatar May 05 '17 21:05 lpender

I believe this project needs something along the lines of

https://github.com/meteor/cordova-plugin-meteor-webapp/blob/dd2d61589c27fe41c56778cb9f7bfab41a612fbd/scripts/iosAddBridgingHeader.js

lpender avatar May 05 '17 21:05 lpender

I am getting plugin not installed after following the steps above... Any idea? This is happening right after I replace the files from the other Yann's repo...

curlybracketsSARL avatar May 21 '17 21:05 curlybracketsSARL

I've forked the plugin into a repo called https://github.com/compelling/cordova-plugin-geofence/ that works fine for me with the fixes - and also with fixes for the android versions that used some obsolete java http methods (as the android version cannot use the javascript callbacks for geofence crossing).

compelling avatar May 22 '17 06:05 compelling

@compelling Works for me too. Is that possible to make a pull request to the main repo (cowbell/cordova-plugin-geofence) ? It's easier for future updates.

ElieSauveterre avatar Aug 20 '17 18:08 ElieSauveterre

1- ionic platform remove ios 2- rm -rf plugins/ 3- in config.xml plugin name="phonegap-plugin-push" spec="git+https://github.com/phonegap/phonegap-plugin-push.git"> 4- in package.json "dependencies":{ ..... "phonegap-plugin-push": "git+https://github.com/phonegap/phonegap-plugin-push.git", "cordova-plugin-geofence": "git+https://github.com/ypelud/cordova-plugin-geofence.git", ... } 4- ionic platform add ios 5- Goto : ./platforms/ios/cordova npm install ios-sim 6- finaly run ionic run ios --livereload --consolelogs

mosh2151984 avatar Sep 14 '17 23:09 mosh2151984

Hello Guys, I am able to compile swift code but geofence trigger not working in IOS. I am using ionic 2 cordova geofence plugin. Please help me to get notified on IOS app.

@Corebee - seems you have same issue, pls let me know if this issue has been solved?

brijesh-p avatar Nov 20 '17 05:11 brijesh-p

Plugin works fine for me, but i had to update location access description entries for plist file for iOS11: E.g.


        <config-file mode="add" parent="NSLocationAlwaysAndWhenInUseUsageDescription" target="*-Info.plist">
            <string>This app requires constant access to your location in order for auto alarm on/off to work.</string>
        </config-file>
        <config-file mode="add" parent="NSLocationWhenInUseUsageDescription" target="*-Info.plist">
            <string>This app requires access to your location in find estate address distance.</string>
        </config-file>

compelling avatar Nov 20 '17 07:11 compelling

@compelling, yes I had added 'NSLocationAlwaysAndWhenInUseUsageDescription' in info.plist.

brijesh-p avatar Nov 20 '17 08:11 brijesh-p

@compelling great work - has anyone had this working successfully with xcode v9 or above? My basic understanding is that it would need to be compilable swift code at version 3.2 or higher?

n40jpj avatar Dec 10 '17 00:12 n40jpj