I have declared my plugin file for iOS inside plugin.xml like so:
<config-file target="config.xml" parent="/*">
<feature name="CDVOP">
<param name="ios-package" value="CDVOP"/>
</feature>
</config-file>
<header-file src="src/ios/CDVOP.h" />
<source-file src="src/ios/CDVOP.m" />
In the plugin JavaScript file I have this function which I later call from the JavaScript app
showCatPictures: function(interval) {
exec(null, null, 'CDVOP', 'showCatPictures', [interval]);
},
I am running the app that uses this plugin from xcode to see the debug output. I get this when I call the showCatPictures
function:
OP Cordova Tests[1122:60b] ERROR: Plugin 'CDVOP' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2014-02-14 16:23:45.233 OP Cordova Tests[1122:60b] -[CDVCommandQueue executePending] [Line 127] FAILED pluginJSON = [
"INVALID",
"CDVOP",
"showCatPictures",
[
30
]
]
I suspect this may have something to do with all the stuff I imported, so here is CDVOP.h
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <Cordova/CDVPlugin.h>
#import <Cordova/CDV.h>
#import <Cordova/CDVViewController.h>
//OP SDK
#import "OpenpeerSDK/HOPStack.h"
#import "OpenpeerSDK/HOPLogger.h"
#import "OpenpeerSDK/HOPMediaEngine.h"
#import "OpenpeerSDK/HOPCache.h"
#import "OpenpeerSDK/HOPAccount.h"
#import "OpenpeerSDK/HOPIdentity.h"
@interface CDVOP : CDVPlugin <UIWebViewDelegate> {
NSString* callbackId;
UIImageView* peerImageView;
UIImageView* selfImageView;
}
@property (nonatomic, copy) NSString* callbackId;
@property (retain, nonatomic) UIImageView *peerImageView;
@property (retain, nonatomic) UIImageView *selfImageView;
- (void) authorizeApp:(CDVInvokedUrlCommand*)command;
- (void) configureApp:(CDVInvokedUrlCommand*)command;
- (void) getAccountState:(CDVInvokedUrlCommand*)command;
- (void) startLoginProcess:(CDVInvokedUrlCommand*)command;
- (void) showCatPictures:(CDVInvokedUrlCommand*)command
@end
and this is the top part of CDVOP.m:
#import "CDVOP.h"
@implementation CDVOP
@synthesize webView, selfImageView, peerImageView, callbackId;
-(CDVPlugin*) initWithWebView:(UIWebView*)theWebView
{
self = (CDVOP*)[super initWithWebView:theWebView];
NSLog(@">>> initializing with cordova webView <<<"); // actually this does not get called!
return self;
}
// stress test UIImageViews using a series of cat pictures
- (void)showCatPictures:(CDVInvokedUrlCommand*)command
{
//initialize and configure the image view
CGRect selfRect = CGRectMake(0, 0, 100.0, 200.0);
self.selfImageView = [[UIImageView alloc] initWithFrame:selfRect];
[self.webView.superview addSubview:self.selfImageView];
// load pictures and start animating
NSLog(@"displaying cat pictures");
selfImageView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"1.JPG"], [UIImage imageNamed:@"2.JPG"], [UIImage imageNamed:@"3.JPG"],
[UIImage imageNamed:@"4.JPG"], [UIImage imageNamed:@"5.JPG"], [UIImage imageNamed:@"6.JPG"],
[UIImage imageNamed:@"7.JPG"], [UIImage imageNamed:@"8.JPG"], nil];
selfImageView.animationDuration = 0.3;
[selfImageView startAnimating];
}
Any ideas why the plugin does not seem to be properly initialized and why cant I call its methods with exec
?