gpt4 book ai didi

ios - Cordova/Phonegap/iOS : ERROR: Plugin 'Plugin01' not found, 或不是 CDVPlugin。检查 config.xml 中的插件映射

转载 作者:行者123 更新时间:2023-11-29 01:50:02 24 4
gpt4 key购买 nike

升级到 Phonegap 5 后,我无法为旧项目或新项目创建工作插件。

这样的问题有很多,但大多数与对我来说效果很好的版本 3 相关。找不到与版本 5 相关的好文档。

我创建了新的测试项目,就像那样,但仍然无法使其工作。

phonegap create test01 com.example.test01 Test01
phonegap platform add ios
phonegap plugin add ../test01-plugin01/
phonegap build ios

插件.xml

<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
id="com.example.plugin01"
version="1.0.0">

<name>Plugin01</name>

<!-- ios -->
<platform name="ios">

<header-file src="src/ios/Plugin01.h" />
<source-file src="src/ios/Plugin01.m" />
</platform>
</plugin>

插件01.h

#import <Foundation/Foundation.h>
#import <Cordova/CDVPlugin.h>

@interface Plugin01 : CDVPlugin {
NSString* callbackID;
}
@property (nonatomic, copy) NSString* callbackID;
- (void)test:(CDVInvokedUrlCommand*)command;
@end

配置文件

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.test01" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>Test01</name>
<description>
Hello World sample application that responds to the deviceready event.
</description>
<author email="support@phonegap.com" href="http://phonegap.com">
PhoneGap Team
</author>
<content src="index.html" />
<preference name="permissions" value="none" />
<preference name="orientation" value="default" />
<preference name="target-device" value="universal" />
<preference name="fullscreen" value="true" />
<preference name="webviewbounce" value="true" />
<preference name="prerendered-icon" value="true" />
<preference name="stay-in-webview" value="false" />
<preference name="ios-statusbarstyle" value="black-opaque" />
<preference name="detect-data-types" value="true" />
<preference name="exit-on-suspend" value="false" />
<preference name="show-splash-screen-spinner" value="true" />
<preference name="auto-hide-splash-screen" value="true" />
<preference name="disable-cursor" value="false" />
<preference name="android-minSdkVersion" value="7" />
<preference name="android-installLocation" value="auto" />
<gap:plugin name="org.apache.cordova.battery-status" />
<gap:plugin name="org.apache.cordova.camera" />
<gap:plugin name="org.apache.cordova.media-capture" />
<gap:plugin name="org.apache.cordova.console" />
<gap:plugin name="org.apache.cordova.contacts" />
<gap:plugin name="org.apache.cordova.device" />
<gap:plugin name="org.apache.cordova.device-motion" />
<gap:plugin name="org.apache.cordova.device-orientation" />
<gap:plugin name="org.apache.cordova.dialogs" />
<gap:plugin name="org.apache.cordova.file" />
<gap:plugin name="org.apache.cordova.file-transfer" />
<gap:plugin name="org.apache.cordova.geolocation" />
<gap:plugin name="org.apache.cordova.globalization" />
<gap:plugin name="org.apache.cordova.inappbrowser" />
<gap:plugin name="org.apache.cordova.media" />
<gap:plugin name="org.apache.cordova.network-information" />
<gap:plugin name="org.apache.cordova.splashscreen" />
<gap:plugin name="org.apache.cordova.vibration" />
<gap:plugin name="com.example.plugin01" />
<icon src="icon.png" />
<icon gap:platform="android" gap:qualifier="ldpi" src="www/res/icon/android/icon-36-ldpi.png" />
<icon gap:platform="android" gap:qualifier="mdpi" src="www/res/icon/android/icon-48-mdpi.png" />
<icon gap:platform="android" gap:qualifier="hdpi" src="www/res/icon/android/icon-72-hdpi.png" />
<icon gap:platform="android" gap:qualifier="xhdpi" src="www/res/icon/android/icon-96-xhdpi.png" />
<icon gap:platform="blackberry" src="www/res/icon/blackberry/icon-80.png" />
<icon gap:platform="blackberry" gap:state="hover" src="www/res/icon/blackberry/icon-80.png" />
<icon gap:platform="ios" height="57" src="www/res/icon/ios/icon-57.png" width="57" />
<icon gap:platform="ios" height="72" src="www/res/icon/ios/icon-72.png" width="72" />
<icon gap:platform="ios" height="114" src="www/res/icon/ios/icon-57-2x.png" width="114" />
<icon gap:platform="ios" height="144" src="www/res/icon/ios/icon-72-2x.png" width="144" />
<icon gap:platform="webos" src="www/res/icon/webos/icon-64.png" />
<icon gap:platform="winphone" src="www/res/icon/windows-phone/icon-48.png" />
<icon gap:platform="winphone" gap:role="background" src="www/res/icon/windows-phone/icon-173-tile.png" />
<gap:splash gap:platform="android" gap:qualifier="port-ldpi" src="www/res/screen/android/screen-ldpi-portrait.png" />
<gap:splash gap:platform="android" gap:qualifier="port-mdpi" src="www/res/screen/android/screen-mdpi-portrait.png" />
<gap:splash gap:platform="android" gap:qualifier="port-hdpi" src="www/res/screen/android/screen-hdpi-portrait.png" />
<gap:splash gap:platform="android" gap:qualifier="port-xhdpi" src="www/res/screen/android/screen-xhdpi-portrait.png" />
<gap:splash gap:platform="blackberry" src="www/res/screen/blackberry/screen-225.png" />
<gap:splash gap:platform="ios" height="480" src="www/res/screen/ios/screen-iphone-portrait.png" width="320" />
<gap:splash gap:platform="ios" height="960" src="www/res/screen/ios/screen-iphone-portrait-2x.png" width="640" />
<gap:splash gap:platform="ios" height="1136" src="www/res/screen/ios/screen-iphone-portrait-568h-2x.png" width="640" />
<gap:splash gap:platform="ios" height="1024" src="www/res/screen/ios/screen-ipad-portrait.png" width="768" />
<gap:splash gap:platform="ios" height="768" src="www/res/screen/ios/screen-ipad-landscape.png" width="1024" />
<gap:splash gap:platform="winphone" src="www/res/screen/windows-phone/screen-portrait.jpg" />
<access origin="*" />
<plugin name="cordova-plugin-whitelist" version="1" />
<plugin name="com.example.plugin01" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>

index.html

            <button onclick="test01();">Test</button>
</div>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
app.initialize();

function test01(){
cordova.exec(null, null, 'Plugin01', 'test', []);
}
</script>

当我在 Plugin 文件夹中打开项目时,我可以在 Xcode 中看到 Plugin01.hPlugin01.m 。我可以在 iPhone 上运行应用程序。

当我触摸“测试”按钮时,出现以下错误:

2015-07-20 12:00:29.108 Test01[1925:1174928] ERROR: Plugin 'Plugin01' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2015-07-20 12:00:29.109 Test01[1925:1174928] -[CDVCommandQueue executePending] [Line 159] FAILED pluginJSON = ["INVALID","Plugin01","test",[]]

我无法从 WebView 执行我的 native 代码

最佳答案

您必须在 plugin.xml 的配置文件标签内添加功能标签,以便将其添加到 config.xml

<name>Plugin01</name>

<!-- ios -->
<platform name="ios">
<config-file target="config.xml" parent="/*">
<feature name="Plugin01">
<param name="ios-package" value="Plugin01"/>
</feature>
</config-file>
<header-file src="src/ios/Plugin01.h" />
<source-file src="src/ios/Plugin01.m" />

</platform>

关于ios - Cordova/Phonegap/iOS : ERROR: Plugin 'Plugin01' not found, 或不是 CDVPlugin。检查 config.xml 中的插件映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31512881/

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