Problems when adding Cordova to my existing iOS project: CordovasettingforKey:]: Unrecognizable selector sent to an instance

I am trying to add the cordova project to my existing ios project. I can successfully compile the application. But when I run it, I get this exception of cordovaSettingForKey.

– [__ NSDictionaryM cordovaSettingForKey:]: Unrecognized selector sent to instance 0x147052a30

EXCEPTION THROW: – [__ NSDictionaryM cordovaSettingForKey:]: Unrecognized selector sent to Example 0x147052a30

Anyone knows how to solve the problem

This is the header file

#import  
#import
#import

@interface MainViewController: CDVViewController

@end< br />
@interface MainCommandDelegate: CDVCommandDelegateImpl
@end

@interface MainCommandQueue: CDVCommandQueue
@end

This is a .m file< /p>

#import "MainViewController.h"

@implementation MainViewController

- (id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Uncomment to override the CDVCommandDelegateImpl used
// _commandDelegate = [[MainCommandDelegate alloc] initWithViewController:self];
// Uncomment to override the CDVCommandQueue used
// _commandQueue = [[MainCommandQueue alloc] ] initWithViewController:self];
}
return self;
}

- (id)init
{
self = [super init ];
if (self) {
// Uncomment to override the CDVCommandDelegateImpl used
// _commandDelegate = [[MainCommandDelegate alloc] initWithViewController:self];
// Uncomment to override the CDVCommandQueue used
// _commandQueue = [[MainCommandQueue alloc] initWithViewController:self];
}
return self;
}

- (void) didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren' t in use.
}

#pragma mark View lifecycle

- (void)viewWillAppear:(BOOL)animated
{
/ / View defaults to full size. If you want to customize the view's size, or its subviews (eg webView),
// you can do so here.

[super viewWillAppear:animated] ;
}

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib .
}

- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// eg self.myOutlet = nil;
)

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return [super shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}

/* Comment out the block below to over-ride */

/*
- (UIWebView*) newCordovaViewWit hFrame:(CGRect)bounds
{
return[super newCordovaViewWithFrame:bounds];
}
*/

@end

@implementation MainCommandDelegate

/* To override the methods, uncomment the line in the init function(s)
in MainViewController.m
*/

#pragma mark CDVCommandDelegate implementation

- (id)getCommandInstance:(NSString*)className
{
return [super getCommandInstance:className];
}

- (NSString*)pathForResource:(NSString*)resourcepath
{
return [super pathForResource:resourcepath];
}

@end

@implementation MainCommandQueue

/* To override, uncomment the line in the init function(s)
in MainViewController.m
*/
- (BOOL)execute:(CDVInvokedUrlCommand*)command
{
return [super execute:command];
}

@end

< p>That’s how I call it

MainViewController * layer = [[MainViewController alloc] initWithNib Name:@"MainViewController" bundle:nil];

Thank you

-Emmy

Try to add -ObjC to the “other link flags” of the target. Note: The cordova documentation says that it is the “-Obj-C” flag, which does not solve the problem.

< p>https://cordova.apache.org/docs/en/latest/guide/platforms/ios/webview.html

I tried to add the cordova project to my In an existing ios project. I can successfully compile the application. But when I run it, I get this exception of cordovaSettingForKey.

– [__ NSDictionaryM cordovaSettingForKey:]: Unrecognized Selector sent to instance 0x147052a30

EXCEPTION THROW: – [__ NSDictionaryM cordovaSettingForKey:]: Unrecognized selector sent to instance 0x147052a30

Anyone knows how to solve the problem

This is the header file

#import 
#import
#import

@interface MainViewController: CDVViewController

@end

@interface MainCommandDelegate: CDVCommandDelegateImpl
@end< br />
@interface MainCommandQueue: CDVCommandQueue
@end

This is a .m file

#import "MainViewCon troller.h"

@implementation MainViewController

- (id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Uncomment to override the CDVCommandDelegateImpl used
// _commandDelegate = [[MainCommandDelegate alloc] initWithViewController:self] ;
// Uncomment to override the CDVCommandQueue used
// _commandQueue = [[MainCommandQueue alloc] initWithViewController:self];
}
return self;
}

- (id)init
{
self = [super init];
if (self) {
// Uncomment to override the CDVCommandDelegateImpl used
// _commandDelegate = [[MainCommandDelegate alloc] initWithViewController:self];
// Uncomment to override the CDVCommandQueue used
// _commandQueue = [[MainCommandQueue alloc] initWithViewController:self];
}
return self;
}

- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

#pragma mark View lifecycle

- (void)viewWillAppear:(BOOL)animated
{
// View defaults to full size. If you want to customize the view's size, or its subviews (eg webView),
// you can do so here.

[super viewWillAppear:animated];
}

- (void )viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}

- (void )viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// eg self.myOutlet = nil;
}< br />
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientatio n
{
// Return YES for supported orientations
return [super shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}

/* Comment out the block below to over-ride */

/*
- (UIWebView*) newCordovaViewWithFrame:(CGRect)bounds
{
return[super newCordovaViewWithFrame:bounds];
}
*/

@end

@implementation MainCommandDelegate

/* To override the methods, uncomment the line in the init function(s)
in MainViewController.m
*/

#pragma mark CDVCommandDelegate implementation

- (id)getCommandInstance:(NSString*)className
{
return [super getCommandInstance:className];
}

- (NSString*)pathForResource:(NSString*)resourcepath
{
return [super pathForResource:resourcepath];
}

@end

@implementation MainCommandQueue

/* To override, uncomment the line in the init function(s)
in MainViewController.m
*/
- (BOOL)execute:(CDVInvokedUrlCommand*)command
{
return [super execute:command];
}

@end

That’s how I call it

MainViewController * layer = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil ];

Thank you

-Emmy

Try to add -ObjC to the target’s “other link flags” Medium. Note: The cordova documentation says that it is the “-Obj-C” flag, which cannot solve the problem.

https://cordova.apache.org/docs/en/latest/guide/platforms /ios/webview.html

Leave a Comment

Your email address will not be published.