Open scmeek opened 4 years ago
I'm seeing the same problem. All you have to do is create a new project, add the nativescript-contacts plugin, then add const contacts = require("nativescript-contacts");
and you'll see the error. You don't actually have to invoke anything.
We're using import * as NativeScriptContacts from "nativescript-contacts";
and it works fine with iOS 13.4.x. Maybe you could try that?
Mine is a javascript project, so I use
const contacts = require("nativescript-contacts");
which is functionally equivalent, yes?
I've spent some time investigating this, and error is triggered by line 6 in index.ios.js, which defines the CustomCNContactPickerViewControllerDelegate
function. All the documentation I can find is for swift, not javascript, so I'm not sure if the functions defined within the delegate actually match the protocol. Right now I'm guessing that's where the problem is.
We're using
import * as NativeScriptContacts from "nativescript-contacts";
and it works fine with iOS 13.4.x. Maybe you could try that?
@mrpaaske I am importing it in the same way. I wonder if it is related to an actual device vs. an emulator. We are using emulators for development and that’s where we are hitting the exception. Are you having success when running your application on an emulator?
Hm, strange. I just tried our app on iPhone 11 iOS 13.4.1 (emulator) and with iPhone X iOS 13.4.1 (real device). Both works fine.
Did you upgrade NativeScript or the plugin recently? If so, I recommend to do rm -rf node_modules platforms hooks
, and then npm i
and tns run ios
. It usually helps on some weird issues :)
@mrpaaske Actually, my primary app works OK, too. I had created a sample app to debug another problem when I hit this. It's very easy to recreate:
tns create sampleApp
(create a JavaScript, Hello World app)
tns plugin add nativescript-contacts
add code to invoke contacts.getContact
tns run ios
Yes, I get the same issue with the sample app. I have no idea why this happens...
In your main projects are you referencing or configuring other iOS APIs? What is the tns-ios
version in your main projects?
Nothing more than whatever the {N} javascript hello-world template does. My versions are:
✔ Component nativescript has 6.5.0 version and is up to date.
✔ Component tns-core-modules has 6.5.1 version and is up to date.
✔ Component tns-android has 6.5.0 version and is up to date.
✔ Component tns-ios has 6.5.0 version and is up to date.
I'm getting the same issue with the sample app.
Having the same issue in my project on iPhone 11 Pro Max iOS 13.4.1 (Emulator) and on iPhone 6 iOS 12.4.6
Also seeing this on iOS 13.5.1 on physical iPhone.
I noticed that it fails when running the app via tns run ios --emulator
. However, opening Xcode and running it manually from there works fine..
A colleague found that commenting out the delegate methods makes it possible to run the app with tns run ios
. Obviously getContact()
will not work as intended anymore..
var CustomCNContactPickerViewControllerDelegate = NSObject.extend(
{
initWithResolveReject: function(resolve, reject) {
var self = this.super.init();
if (self) {
this.resolve = resolve;
this.reject = reject;
}
return self;
},
// contactPickerDidCancel: function(controller) {
// this.resolve({
// data: null,
// response: "cancelled"
// });
// },
// contactPickerDidSelectContact: function(controller, contact) {
// controller.dismissModalViewControllerAnimated(true);
//
// //Convert the native contact object
// var contactModel = new Contact();
// contactModel.initializeFromNative(contact);
//
// this.resolve({
// data: contactModel,
// response: "selected"
// });
// CFRelease(controller.delegate);
// }
},
{
protocols: [CNContactPickerDelegate]
}
);
@firescript, do you have any input on this? Are you able to reproduce this issue?
Created a sample app now (Angular+TypeScript), and still seeing this issue on latest versions. Both on emulator (iPhone 11, iOS 13.6) and device (iPhone X, iOS 14 beta 3).
✔ Getting NativeScript components versions information...
✔ Component nativescript has 6.7.8 version and is up to date.
✔ Component tns-core-modules has 6.5.12 version and is up to date.
✔ Component tns-android has 6.5.3 version and is up to date.
✔ Component tns-ios has 6.5.2 version and is up to date.
I'm running into this after upgrading my iOS platform from 6.1.2 to 6.5.2. I upgraded the platform in the first place to get my app working on iOS 14. Perhaps a bug was introduced in tns-ios somewhere between those versions?
I can confirm, at least in my app, that this crash happens in iOS runtime 6.3.0 but not 6.2.0. I haven't yet been able to identify why.
I have same issue on real iPhone 12 OS 15.2.1 and simulator iOS 12.1, here is my environment setting.
"nativescript-contacts": "^1.6.4",
"tns-core-modules": "^6.5.27"
"tns-ios": "6.5.2"
Referencing this module, as described in the README, is crashing in iOS 13.4. This appears to be related to the availability of
CNContactPickerViewController
at runtime.Section that caught my attention:
Full stack trace: