找不到插件,或者不是CDVPlugin。在config.xml中检查插件映射 [英] Plugin not found, or is not a CDVPlugin. Check your plugin mapping in config.xml

查看:2645
本文介绍了找不到插件,或者不是CDVPlugin。在config.xml中检查插件映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在plugin.xml中声明了我的插件文件,如下所示:

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" />

在插件JavaScript文件中我有这个函数,我稍后从JavaScript应用程序调用

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]);   
},



我运行的应用程序使用这个插件从xcode看到调试输出。我得到这个当我调用 showCatPictures 函数:

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
  ]
]

$ b b

我怀疑这个可能与我导入的所有东西有关,所以这里是CDVOP.h

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


$ b b

这是CDVOP.m的顶部:

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];
}

任何想法为什么插件似乎没有正确初始化,使用 exec ?

Any ideas why the plugin does not seem to be properly initialized and why cant I call its methods with exec?

推荐答案

这里是一个小的不重要的细节我忘了在问题中提到。这是使用插件的示例应用程序中的 www / config.xml 。您能找到问题吗?

Here is an small unimportant detail I forgot to mention in the question. This is what the www/config.xml in the sample app using the plugin looked like. Can you spot the issue?

<widget id="org.sample.test" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>My Cordova Test</name>
    <description>
        A series of tests demonstrating the use of my cordova plugin
    </description>
    <author email="" href="">
        That would be me
    </author>
    <content src="index.html" />
    <access origin="*" />
</widget>

注意应用程序名称中的空格< name& / name> 。这似乎起初工作,但它在文件夹名称中放置空间,以后将托管您的插件。这足以干扰插件安装过程。这是我解决问题的方法:

Notice the space in the application name <name>My Cordova Test</name>. This seems to work at first, but it puts spaces in the folder name that will later host your plugin. That is enough to interfere with the plugin installation process. This is what I did to fix the issue:


  • 将测试应用程式的名称变更为 MyCordovaTest

  • cordova platform remove ios

  • cordova plugin remove org.myplugin.cordova

  • cordova平台添加ios

  • cordova plugin add ../ my-plugin

  • cordova build ios

  • changed the name of the test app to MyCordovaTest
  • cordova platform remove ios
  • cordova plugin remove org.myplugin.cordova
  • cordova platform add ios
  • cordova plugin add ../my-plugin
  • cordova build ios

现在插件已正确安装,并按预期进行初始化。非常感谢在 #phonegap IRC房间谁帮助我调试这个问题的好人。我希望这有助于某人。

Now the plugin is installed properly and is initialized as expected. Many thanks to the nice folks in #phonegap IRC room who helped me debug this problem. I hope this helps someone.

这篇关于找不到插件,或者不是CDVPlugin。在config.xml中检查插件映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆