2016-01-19 77 views
0

我已經創建了一個項目科爾多瓦科爾多瓦創建sampleApp com.sample.app sampleApp 後來再也科爾多瓦平臺添加iOS和再科爾多瓦插件添加科爾多瓦 - 插件設備項目科爾多瓦IOS插件沒有找到當我運行

文件:

平臺/ IOS/ios.json

在我添加了一些所謂的sayHelloPlugin下面的JSON內的自定義插件的ios.json

{ 
    "prepare_queue": { 
     "installed": [], 
     "uninstalled": [] 
    }, 
    "config_munge": { 
     "files": { 
      "config.xml": { 
       "parents": { 
        "/*": [ 
         { 
          "xml": "<feature name=\"Device\"><param name=\"ios-package\" value=\"CDVDevice\" /></feature>", 
          "count": 1 
         }, 
         { 
          "xml": "<feature name=\"sayHelloPlugin\"><param name=\"ios-package\" value=\"sayHelloPlugin\" /></feature>", 
          "count": 1 
         } 
        ] 
       } 
      } 
     } 
    }, 

} 

平臺/ IOS/sampleApp/config.xml中

在config.xml中還我已經添加

<feature name="sayHelloPlugin"> 
     <param name="ios-package" value="sayHelloPlugin" /> 
</feature> 

WWW/JS/index.js 我添加調用本地目標C用作

cordova.exec(sayHelloSuccess, sayHelloFailure, "SayHelloPlugin", "sayHello", [name]); 

function test(){   
    alert("Received Event"); 
} 

function sayHelloSuccess(data){ 
    alert("Success"); 
} 

function sayHelloFailure(data){ 
    alert("Error"); 
} 

而且我的目標類是什麼樣子

#import "SayHelloPlugin.h" 

@implementation SayHelloPlugin 

- (void)sayHello:(CDVInvokedUrlCommand*)command{ 

    NSString *responseString = 
     [NSString stringWithFormat:@"Hello %@", [command.arguments objectAtIndex:0]]; 

    CDVPluginResult *pluginResult = 
     [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:responseString]; 

    [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; 
} 

@end 

當我做一個科爾多瓦建立ios的構建是成功的。 當我模仿和運行我得到一個錯誤消息

2016-01-19 05:39:44.017 sampleApp[21225:1854134] CDVPlugin class sayHelloPlugin (pluginName: SayHelloPlugin) does not exist. 
2016-01-19 05:39:44.018 sampleApp[21225:1854134] ERROR: Plugin 'SayHelloPlugin' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml. 
2016-01-19 05:39:44.018 sampleApp[21225:1854134] -[CDVCommandQueue executePending] [Line 159] FAILED pluginJSON = ["SayHelloPlugin535510559","SayHelloPlugin","sayHello",["Hello"]] 

如何解決這個問題?

回答

0

錯誤清楚地說sayHelloPlugin沒有找到。你演示瞭如何添加設備插件,但不是這個特定的插件。

+0

是sayHelloPlugin是我的自定義插件 我提出呼籲cordova.exec(sayHelloSuccess,sayHelloFailure, 「SayHelloPlugin」, 「sayHello的」,[名]);並且在config.xml和ios.json中添加相同的內容 – user3383301

+0

好的,你是否按照說明添加了自己的插件?你的問題(afaik)沒有解決這個問題。 –

+0

我已經更新了這個問題,你可以檢查它 – user3383301

相關問題