gpt4 book ai didi

ios - 找不到插件,或者不是 CDVPlugin。检查 config.xml 中的插件映射

转载 作者:可可西里 更新时间:2023-11-01 03:03:21 27 4
gpt4 key购买 nike

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

  <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 应用程序调用它

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

我怀疑这可能与我导入的所有东西有关,所以这里是 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

这是 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 调用它的方法有什么想法吗?

最佳答案

这是我忘记在问题中提到的一个不重要的细节。这就是www/config.xml在使用插件的示例应用程序中看起来像。你能发现问题吗?

<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>My Cordova Test</name> .起初这似乎可行,但它在稍后将托管您的插件的文件夹名称中放置了空格。这足以干扰插件安装过程。这就是我为解决问题所做的工作:

  • 将测试应用的名称更改为 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 聊天室。我希望这对某人有所帮助。

关于ios - 找不到插件,或者不是 CDVPlugin。检查 config.xml 中的插件映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21792101/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com