Cordova app for iOS with Plugins - ios

I am trying to create a cordova app for iOS. The same app we are using for android as well. I just tried to add the iOS plugin and launch the app. I have added below code in CDVDevice.h.
http://developmobilesoftware.blogspot.in/2013/12/the-unique-identifier-in-ios-app-udid.html
I am getting exception and my trace is as under :
+[CDVDevice uniqueIDForDevice] : unrecognized selector sent to class 0xf30c4
** WebKit discarded an uncaught exception in the webView: decidePolicyForNavigationAction:request:frame:decisionListener:delegate"<NSInvalidArgumentException> +[CDVDevice uniqueIDForDevice]: unrecognized selector sent to class 0xf30c4
Please help I am new to iOS programming.
Thank You!

First of all, editing CDVDevice isn't a good idea
But you can do two different things to fix your code:
change [devProps setObject:[[self class] uniqueIDForDevice] forKey:#"uniqueid"];
to [devProps setObject:[self uniqueIDForDevice] forKey:#"uniqueid"];
or change -(NSString*)uniqueIDForDevice
to +(NSString*)uniqueIDForDevice
Explanation, class methods start with +, instance methods start with -, you have declared an instance method but you call it like a class method, so you can change the class method to instance method changing the - to + or keep it as instance method and call it as an instance method just with self instead of [self class]
Anyway, as I said before, instead of editting the device plugin, you can use my identifier for vendor plugin
https://github.com/jcesarmobile/IDFVPlugin
window.IDFVPlugin.getIdentifier(function(identifier){ alert(identifier); },function(error){ alert(error); });

Related

iOS 11.3 AND Xcode 9.3 causing Obj-C app launch failures

So this is an odd one... we have an application that is written in Obj-C and prior to anyone updating to iOS 11.3 it ran fine. The 11.3 update broke it... however with Xcode 9.3 and the new compiler we get the same error on any and all devices. So it appears that Apple broke something in the SDK.
By the same token, it seems likely that if they had actually broken something in the SDK then EVERYONE would be having this issue. So I turn to you, the SO braintrust, to help me figure this out!
NOTE: Just to be extremely clear: this is an older app written in Obj-C, not Swift, and has been in maintenance only for some time.
So the offending block of code is very simply this:
- (UINavigationController *)controllerForCategories: (NSArray *)categories titled:(NSString *)title
{
DocumentViewController *dc = [[DocumentViewController alloc]initWithCategories:categories titled:title];
UINavigationController *nc = [[UINavigationController alloc]initWithRootViewController:dc];
[self addChildViewController:nc];
// ERROR HAPPENS ON THIS ^^ LINE
[nc didMoveToParentViewController:self];
[self.contentPanel addSubview:nc.view];
nc.view.frame = self.contentPanel.bounds;
return nc;
}
Now according to the Apple docs, that should be fine. If we had overridden addChildViewController() then we might have an issue, but we didn't, we're just calling the method. The argument, named 'nc', is an SDK class that extends UIViewController, so it's a valid argument to the method in question. However, on 11.3 (or on all iOS versions with Xcode 9.3, we get this error EVERY TIME we launch, on any device:
2018-04-25 14:42:18.792216-0700 Steri-Vac GS[1090:855706]
-[MasterNavigationViewController _viewControllerSubtreeDidGainViewController:]: unrecognized selector sent to instance 0x101210100 2018-04-25 14:42:18.792662-0700 Steri-Vac
GS[1090:855706] * Terminating app due to uncaught exception
'NSInvalidArgumentException', reason:
'-[MasterNavigationViewController
_viewControllerSubtreeDidGainViewController:]: unrecognized selector sent to instance 0x101210100'
* First throw call stack: (0x186c4b164 0x185e94528 0x186c58628 0x1905c6188 0x186c50b10 0x186b35ccc 0x19029a964 0x19029d2c0
0x100a4941c 0x100a48bec 0x190205a00 0x1902055d8 0x19020c1a4
0x190209404 0x1902782e8 0x100a77a24 0x1902742c4 0x190465bc4
0x19046aa14 0x1907062a8 0x1909de100 0x190705f0c 0x19070676c
0x190e8b7c0 0x190e8b664 0x190bf92cc 0x190d923cc 0x190bf917c
0x1909dd760 0x190469158 0x19087edbc 0x18930e1f0 0x189316af8
0x100bb928c 0x100bc59e4 0x1893427f8 0x18934249c 0x189342a38
0x186bf377c 0x186bf36fc 0x186bf2f84 0x186bf0b5c 0x186b10c58
0x1889bcf84 0x1902695c4 0x100a51994 0x18663056c) libc++abi.dylib:
terminating with uncaught exception of type NSException
I've filed a bug with Apple and submitted code to support it, but I thought I'd check with the brain trust here to see if anyone had anything I could look into in the mean time. For now our app is useless and 40% of my field service techs have already updated to 11.3, so it's getting to be a critical issue for us.
Thanks in advance, folks!
Apple responded to my bug!
It turns out that our class was extending the UIViewController and implementing a property called navigationController which was another instance of UIViewController, while at the same time UIViewController HAS a property called navigationController... is an instance of UINavigationController. The trick was to simply rename our navigationController to navController. Conflict resolved.
The real question is why this only stopped working after updating to Xcode 9.3 and didn’t actually break the app till our users updated to iOS 11.3. Under 11.2 the original app ran fine. And after updating to Xcode 9.3 the compiles app wouldn’t run on any version of iOS.
VERY strange!

Xcode with WebTrends - NSCFBoolean hasPrefix: unrecognized selector sent to instance

I made a game in Unity, and built it for iOS devices. The clients asked if we could implement WebTrends into the game, and so I followed this getting started guide for instructions on how to install it.
I was able to set it up, and got to Step 5, which suggests the following:
Lifecycle events can be logged automatically by setting the
wt_dc_automatics_enabled config setting to true
This is where I got stumped. I then added the above setting to my webtrends.plist, so it now looks like this:
When attempting to build and run that, I get an error in Xcode, and the game refuses to run:
Uncaught exception: NSInvalidArgumentException: -[__NSCFBoolean hasPrefix:]: unrecognized selector sent to instance 0x11294d238
This guide suggests setting wt_dc_enabled to true instead of wt_dc_automatics_enabled.
But even after replacing that in the plist, it returns the same error.
Notably, the project runs fine if I remove the wt_dc_automatics_enabled / wt_dc_enabled from the plist file, though it doesn't sent any logs, to my knowledge.
Is there anything else I can do?
Can you trying making wt_dc_automatics_enabled as String type and not boolean type and add its value as YES.
Because your error says somewhere in the code hasPrefix method is called on Boolean value. hasPrefix method is defined in String class and there is no such method in Boolean class.

Why do I get the error "Unrecognized selector sent to instance error"

I'm just learning Objective C and have come across this issue. I have created a simple manager class like so
#import <Foundation/Foundation.h>
#interface PassManager : NSObject
- (void)isValidCredentials:(NSString *) username
withPassword:(NSString *) password
wasValid:(void(^)(BOOL success))handler;
#end
the implementation is as follows
#import "PassManager.h"
#implementation PassManager
- (void)isValidCredentials:(NSString *) username
withPassword:(NSString *) password
wasValid:(void(^)(BOOL success))handler
{
handler(true);
}
#end
This builds but upon running I get the error:
"2016-01-27 16:40:41.555 MessyApp[19395:897750] -[PassManager initWithConfiguration:]: unrecognized selector sent to instance 0x7fd12a413d30 2016-01-27 16:40:41.560 MessyApp[19395:897750] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PassManager initWithConfiguration:]: unrecognized selector sent to instance 0x7fd12a413d30'".
What am I doing wrong?
Well the error says it all, somewhere in your code you are calling the initWithConfiguration method on an PassManager but you don't have that method in your PassManager class, so it throws an exception.
Either add the method and implement it in your PassManager class, or if you want to catch exactly where this is happening (and don't want to search for all the occurrences of initWithConfiguration.
You could go to Breakpoint Navigator by pressing CMD+7 and then on the bottom press the + sign and add an Exception Breakpoint, run the app and wait for it to fire.
Good luck.
After speaking to originaluser2 he showed me it was something else causing the problem. I was using a library called Parse that required startup code in the appdelegate class and it was that what was blowing up. Once he showed me that I looked at what else I did and realised I had created a class called ParseManager that was causing some sort of name conflict. I changed this classes name and sure enough it all started working. Bad question on my part I'm afraid but Im a new to this platform

Call controller method from different thread in iOS

I'm trying to call this method from a music-rendering function that is run in a different thread. The method is inside InstrumentGridViewController.
- (IBAction)stopPlayback:(id)sender{
[self stopToneUnit];
}
This is how I'm calling the method:
dispatch_async(dispatch_get_main_queue(), ^{ [InstrumentGridViewController stopPlayback: nil]; } );
But I'm getting this warning:
Class method `+stopPlayback` not found (return type defaults to `id`)
And when I try to run:
erminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[InstrumentGridViewController stopPlayback:]: unrecognized selector sent to class 0x13e50'
I'm sure the method is there so I really don't see why this is happening.
EDIT: H2CO3 said I should call the stopPlayback method on the currently running instance. Any ideas how I could do that?
Because the method is implemented as an instance method and not as a class method. You must call it on an object of class InstrumentGridViewController, and not on the class itself.

ZoomingPDFViewer example error

I'm trying to develop an app that can show a PDF file. I try to complete this with ZoomingPDFViewer
http://developer.apple.com/library/ios/#samplecode/ZoomingPDFViewer/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010281-Intro-DontLinkElementID_2
code that is in the apple library. When I mix that code with my code some function doesn't work. And if I make it with the same code (don't mixed) the app throw this error:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setPDFPage:]: unrecognized selector sent to instance 0x6a833f0'
I'm in SDK 5.0 the requirements says that I should compile it in SDK 5.1 but the sample runs perfect, the problem is in my project but I don't know what is my error.
I'll appreciate if someone can help me with this strange error.
Check the Class setting in Storyboard.
View Controller -> Custom Class: ZoomingPDFViewerViewController and
Scroll VIew -> Custom Class: PDFScrollView
The second setting is the cause of your error.
You seem to be sending -setPDFPage: to an uncast self.view object. Try casting before calling like so:
[(PDFScrollView *)self.view setPDFPage:PDFPage];
Double check your connections in IB, if you are using it, or make sure you are initing a PDFScrollView* object in -loadView if not.

Resources