-
Notifications
You must be signed in to change notification settings - Fork 317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ios build failing (Swift 3 errors) #243
Comments
@graphicgeek after some days trying to resolve this, i finally was able to compile the project and to prevent application crash after adding a new zone. I was able to do that doing:
After all this, you should have files like the attached ones! I didn't have the opportunity to test that notification really works, but geofence does all the passage (init and add/update) with no issues. Hope this can help you. |
Thanks @centos94, I will give this a try. |
@graphicgeek let me know if it works so it can be useful for others with the same problem too! |
Worked for me thanks ! |
Will this work using XCode9 or do we have to stay below that? |
@dovk yes, it works with xcode 9! |
@centos94 I went by your instructions as written above to @graphicgeek |
This worked for me. It looks like someone has forked the repo to create a version that has all of these files here https://github.com/compelling/cordova-plugin-geofence/ Note, I had to remove from my config.xml to get it to build. Hopefully the fixed files will get merged into the main repo soon. |
HI there Not sure if it's related, but I'm not able to get it working on ios. Xcode Version 9.0.1 Any ideas? |
I realize now what worked was that I was able to complete the build without any errors, but the geofence itself still does not work. Can someone point me to a fork that works with Xcode 9 ? |
@marcelomiura @dovk Now i tried to add in the plist file NSLocationAlwaysAndWhenInUseUsageDescription, the warning disappeared and the app asks me another authorization. Maybe is that. Can you try it and tell us if it works? |
@centos94 I've already added NSLocationAlwaysAndWhenInUseUsageDescription on the plist too. I could make it work simulating a big location change with Xcode. When disabling the location simulator, all my near geofences were detected at the same time. But I'm not able to make this work testing a normal use case yet. |
Firstly, thanks for the hard work on this. I am using Ionic Cloud build and I beleive they have upgraded it to use a new version of Xcode which does not use Swift 2.3. What are the plans to upgrade this plugin to use newer version of Swift? You can see my issues with Ionic 2 here: https://forum.ionicframework.com/t/ionic-package-ios-release-build-error-in-package-ionic-services/109507/15 |
Finally! Thank you again centos94 - I checked again and the solution works!
I did not have to change much in the Xcode developer, other than adding the 1024 icon manually (until I figure that one out). And though I'm not sure I needed to, I ticked the location updates checkbox in Capabilities/Background modes.
There is one other thing that I did, I don't know if this is an issue with anyone else - I was getting too many permission error messages when the app initializes so I just remarked all the warnings.append in GeofencePlugin.swift. By the way rodneyjoyce - Like many others I too was having a very difficult time with Ionic's unreliable Cloud Build. I finally gave up on them and got myself a macMini for the .ipa builds. It took a while to get used to but I now have a lot more control and understanding of the process now. If this will help anyone, here are the relevant packeges I have in package.json
BTW I read a pretty good explanation about the Location permission here https://mackuba.eu/2017/07/13/changes-to-location-tracking-in-ios-11/ |
Hi, do you plan a date for release compatibility with swift 3 ? |
I noticed that Swift 4.0 is the default version in Xcode 9.1, I understand you can still use Swift 3.0 code, but the compatibility issue might be relevant as well. |
Or maybe a date for Swift4 ? ;) |
@centos94 , I am able to compile code by changing 3 swifts files, but geofence is still not working in IOS device (however fence is adding perfectly but unable to trigger transition), any Idea what I am missing? |
Hello @brijesh-p, did you try what @dovk has done? |
Sorry, I forgot to mention that, although I might have been able to do this differently, I copy the 3 sources to 3 different places - <path_to_project>/<project_name>/node_modules/cordova-plugin-geofence/src/ios And as I wrote earlier, at one point it wasn't working because I had a spelling mistake in one of the fence json parameters (openAppOnClic instead of openAppOnClick). Also - as a result of different behavior between Android and iOS, and based on suggestions that I read about, I define the fence json parameters as follows (although some may seem obvious or may not be necessary) -
If I notice anything else I did, I'll add it here later - Good luck ! |
@dovk, thanks. Its is possible to share, .swifts files for IOS?, meantime I am looking your suggestions. |
@brijesh-p I'm still facing the same issue as you. Geofences added, but transitions not triggered on ios. Have you made any progress? |
I've already gone down to radius of 100 and it's ok, so I guess that was never a real problem there. I placed some of the relevant code here https://github.com/dovk/geofence-fix You might also notice things in package.json or config.xml that would be beneficial to add. Regarding the Swift sources - I took those from https://github.com/ypelud/cordova-plugin-geofence And in the build_ios.sh (I know it's ugly - it's the first shell script I ever wrote) you can see how I automatically run the build and copy the Swift files to their respective places. Take a look and let me know. |
@dovk , thanks. |
Yes, absolutely, as you can see in the screenshot above from my iPhone. And as I wrote, it is all with recent versions, including using the new WKWebView, node/npm, and cordova, whose latest versions had caused problems and forced me in the past to revert to previous versions - now everything is up-to-date. By the way, it did not go well with XCode 9.1.0, so I stayed at 9.0.1.
I also found it important to make sure that everyting regarding notifications is also defined and installed correctly, because at one point the problem wasn't with Geofence but rather with localNotifications. For example using all those permission definitions in config.xml (under config-file) |
Hi, guys, this thread is very hard to follow. I understand that the compatibility with Swift >=3 is not already working, but a temporary patch exists. Thats true ? In this case is it possible to describe the full procedure (with version required of ios) to follow to use geofence plugin ? Thanks in advance. |
Please you can define your current problem, because there are a lot of possibilities. Try to include relevant sources. |
My initial problem was : "I had trouble following the procedure to make geofence work on the latest Xcode versions". But I tried to understand your explanations well now i can pass the compilation step. I will try to explain what I did and the new problem that I am experiencing now.
<path_to_project>/<project_name>/node_modules/cordova-plugin-geofence/src/ios
It only happens when I use the geofence lib. Below a simple code that i used : import { Injectable } from '@angular/core';
import { Geofence } from '@ionic-native/geofence';
@Injectable()
export class GeofenceService {
constructor(private geofence: Geofence) {}
public watch(): void {
console.log('watch geofence');
// initialize the plugin
this.geofence.initialize().then(() => {
console.log('watch');
this.addGeofence();
}, (err) => {
console.log(err);
});
}
private addGeofence():void {
//options describing geofence
let fence = {
id: '69ca1b88-6fbe-4e80-a4d4-ff4d3748acdb', //any unique ID
latitude: -21.0130745, //center of geofence radius
longitude: 55.2646077,
radius: 100, //radius to edge of geofence in meters
transitionType: 3, //see 'Transition Types' below
notification: { //notification settings
id: 1, //any unique ID
title: 'You crossed a fence', //notification title
text: 'You just arrived to Gliwice city center.', //notification body
openAppOnClick: true //open app when notification is tapped
}
}
this.geofence.addOrUpdate(fence).then(
() => console.log('Geofence added'),
(err) => console.log('Geofence failed to add')
);
}
} My environment :
Hope it's help to understand my request. Thanks in advance. |
Try to code as close as possible to my code here |
I am also facing the same issue and the above mentioned solution is not working for me |
If you put some of your code up I can take a look. It still works for us but be aware that it might not be a viable solution for your purposes in any case since there are limitations when using the plugin in a Web/Javascript-based app framework like Ionic - geolocation and geofence works fine when the app is active in foreground, or when the app is minimized (for example when focusing on another app or pressing the back button on Android). However, when the app is closed, for example when you close the app window from the app list on Android, or swipe the app up on iOS, only the notification will work, not the actual Javascript code that you want to run when the entering or leaving event occurs. I am checking different solutions for that case. |
Thank you for your response. I am working on Ionic platform and in Android the geofence is working fine without having any issue. In iOS it is added succesfully(as per the log) but no notification is showing. {code} @component({ constructor(public navCtrl: NavController, private geofence: Geofence, public http: Http, private plt: Platform, private file: File, private fileOpener: FileOpener) { } callGeofence(){ private addGeofence() { } {code} |
We learnt alot in the process of trying to integrate the Geofence plugin in our app, but finally removed it from our app today and replaced it with simple home-made Geofence functionality based on the Background Geolocation plugin.
and the fence object is defined as
I also mentioned above that:
|
I've seen some other closed issues that indicated this has been fixed but it is not building for me with a fresh HelloWorld app.
Cordova 7.0.1
ios platform 4.4.0 (also tried with 4.5.0)
Xcode 8.3.3 (I also just updated to 9.0 with the same results)
cordova-plugin-geofence 0.7.0
I even tried updating cordova-plugin-add-swift-support to version 1.7.0 but no luck.
Here's the log output:
The text was updated successfully, but these errors were encountered: