我试图将cordova项目添加到我现有的ios项目中.我可以成功编译应用程序.但是当我运行它时,我得到了cordovaSettingForKey的这个例外. – [__ NSDictionaryM cordovaSettingForKey:]:无法识别的选择器发
          – [__ NSDictionaryM cordovaSettingForKey:]:无法识别的选择器发送到实例0x147052a30
EXCEPTION THROW: – [__ NSDictionaryM cordovaSettingForKey:]:无法识别的选择器发送到实例0x147052a30
任何人都知道如何解决问题
这是头文件
#import <Cordova/CDVViewController.h> #import <Cordova/CDVCommandDelegateImpl.h> #import <Cordova/CDVCommandQueue.h> @interface MainViewController : CDVViewController @end @interface MainCommandDelegate : CDVCommandDelegateImpl @end @interface MainCommandQueue : CDVCommandQueue @end
这是.m文件
#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 (e.g. 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.
    // e.g. 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*) 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 
 我就是这样称呼的
MainViewController * layer = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
谢谢
-Emmy
尝试将-ObjC添加到目标的“其他链接标志”中.注意:cordova文档称它是“-Obj-C”标志,不能解决问题.https://cordova.apache.org/docs/en/latest/guide/platforms/ios/webview.html
