8、Plugin.xml(基础知识)

翻译自cordova官方文档(如果需要链接,请自行对照原文链接进行查看):
https://cordova.apache.org/docs/en/latest/plugin_ref/spec.html

Plugin.xml

Plugin.xml是用于设置你得插件,他包含很多元素为你的插件提供详细的设置。

<pluginxmlns="http://apache.org/cordova/ns/plugins/1.0"id="cordova-plugin-splashscreen"version="3.2.0"><!--
        plugin 标签是Plugin配置文件最顶层的元素
            xmlns:用于指定命名空间(namespace),当然也可以指定针对特定平台的命名空间比如
                xmlns:android="http://schemas.android.com/apk/res/android"
               id:用于设置plugin的识别id
          version:plugin的版本号
    --><name>Splashscreen</name><!--
            用于为plugin设定一个名字。
        --><description>Cordova Splashscreen Plugin</description><!--
            plugin的描述或者说明
        --><license>Apache 2.0</license><!--
            为plugin指定使用哪种开源许可license
        --><keywords>cordova,splashscreen</keywords><!--
            使用逗号分割,用于描述plugin的关键字。
        --><author>Foo plugin author</author><!--
            用于设置作者信息。
            # 这个是为了解释这个标签特地加入的,并不是splashscreen插件带的。
        --><assetsrc="www/new-foo.js"target="js/experimental/foo.js" /><!--
            将特定js文件拷贝到工程指定目录。并且可以重命名。
            # 这个是为了解释这个标签特地加入的,并不是splashscreen插件带的。
        --><repo>https://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen.git</repo><!--
            plugin的描述或者说明
        --><issue>https://issues.apache.org/jira/browse/CB/component/12320653</issue><dependencyid="cordova-plugin-someplugin"url="https://github.com/myuser/someplugin"commit="428931ada3891801"subdir="some/path/here" /><dependencyid="cordova-plugin-someplugin"version="1.0.1"><!--
            用于声明该plugin会依赖其他plugin,通过id或者是url来指定依赖plugin的源。
        --><engines><enginename="cordova-android"version=">=3.6.0" /><!-- Requires CordovaPlugin.preferences --></engines><!--
            engines用于设置plugin适用的平台镜像版本
            engine用于设置具体支持的版本,name用于指定镜像平台,version用于设置版本号
            ,如果不设置默认支持全平台全版本
            目前cordova支持的平台主要如下:
            .cordova
            .cordova-plugman
            .cordova-android
            .cordova-ios
            .cordova-blackberry10
            .cordova-wp8
            .cordova-windows
            .cordova-osx
            .windows-os
            .android-sdk (returns the highest Android api level installed)
            .windows-sdk (returns the native windows SDK version)
            .apple-xcode (returns the xcode version)
            .apple-ios (returns the highest iOS version installed)
            .apple-osx (returns the OSX version)
            .blackberry-ndk (returns the native blackberry SDK version)
        --><js-modulesrc="www/splashscreen.js"name="SplashScreen"><clobberstarget="navigator.splashscreen" /></js-module><!--
            js-module标签一般用于发布定义js接口的js文件。本例中,将www/splashscreen.js文件中定义的接口发布到
            window.navigator.splashscreen对象上,这样web端可以直接通过navigator.splashscreen对象来访问plugin
            的api。如果想替换掉window对象上指定接口还可以通过以下方式:
            <js-module src="socket.js" name="Socket">
                <merges target="chrome.socket" />
                # 使用merges标签,如果chrome.socket存在,那么用此plugin内的chrome.socket替换掉原有的。
            </js-module>
            <js-module src="socket.js" name="Socket">
                <runs/>
                # 使用runs标签你代码需要通过cordova.require去指定,并且不是安装到window对象上。
                这个标签用于安装模块或者是其他的时候使用。该标签和<clobbers/>或者<merges/>一起使用是多余的。
            </js-module>
        --><!--
        platform用于指定plugin安装到哪些平台,这里主要介绍android和ios,如果没有指定平台,那么cordova会把plugin看
        做只提供javascript接口的plugin。
                 name:用于指定平台名字。
          source-file:用于告诉plugin把config-file包含的内容安装到target里面。或者是target-dir里面。
          header-file:同样也是用来将指定文件拷贝到指定目录下。
        resource-file:同样也是用于拷贝文件,不同的是这个配置用于拷贝非代码资源。
                  <resource-file src="FooPluginStrings.xml" target="res/values/FooPluginStrings.xml" />
          config-file:指定需要设置的配置文件爱你,比如xml或者plist,添加进去的内容必须以xml的格式设置。
                  具体参见下面例子代码。其中parent用于指定在哪一个父元素下添加。
        plugins-plist:已经过时了。现在使用<config-file>来替代。
             lib-file: 用于添加依赖包。
                     <lib-file src="src/BlackBerry10/native/device/libfoo.so" arch="device" />
                     src用于指定plugin下的文件路径,arch用于设置依赖包需要的架构比如x86,x64,
                     device-target用于设置目标设备win,phone,all.
           framework:用于引入一个依赖framework。
                  <framework src="libsqlite3.dylib" />
                  <framework src="com.google.android.gms:play-services-gcm:+" />
                  <framework src="relative/path/rules.gradle" custom="true" type="gradleReference" />
                  <framework src="path/to/project/LibProj.csproj" custom="true" type="projectReference"/>
                  <framework src="src/windows/example.dll" arch="x64" />
                info:提供一些额外信息。说明信息之类的。
                hook:用于设置在cordova某些命令执行后需要执行的脚本比如
                         <hook type="after_plugin_install" src="scripts/afterPluginInstall.js" />   
                         具体参照[Hooks](https://cordova.apache.org/docs/en/latest/guide/appdev/hooks/index.html)
             uses-permission:用来声明plugin需要申请的权限,比如:
                     <uses-permission android:name="my-app-id.permission.C2D_MESSAGE"/>
              preference:用于在安装plugin的时候check用户设置的变量,如果变量的内容不正确,显示警告信息
                 <preference name="API_KEY" default="default-value" />
                 比如在statusbar插件中的设置
                 <config-file target="config.xml" parent="/*">
                    <feature name="StatusBar">
                        <param name="ios-package" value="CDVStatusBar" />
                        <param name="onload" value="true" />
                    </feature>
                    <preference name="StatusBarOverlaysWebView" value="true" />
                    <preference name="StatusBarStyle" value="lightcontent" />
                 </config-file>
        --><!-- android --><platformname="android"><!-- 修改AndroidManifest.xml文件 
                <config-file target="AndroidManifest.xml" parent="/manifest">
                     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
                </config-file>--><config-filetarget="res/xml/config.xml"parent="/*"><!--在androidn的config.xml中添加feature内的配置信息--><featurename="SplashScreen"><paramname="android-package"value="org.apache.cordova.splashscreen.SplashScreen"/><paramname="onload"value="true"/></feature></config-file><!--将指定文件安装到target-dir的位置--><source-filesrc="src/android/SplashScreen.java"target-dir="src/org/apache/cordova/splashscreen" /><!--将依赖的jar添加到系统--><!--<source-file src="plugin_path/**.jar" target-dir="libs" />--></platform><!-- ios --><platformname="ios"><config-filetarget="config.xml"parent="/*"><!--在config.xml中添加feature内的配置信息--><featurename="SplashScreen"><paramname="ios-package"value="CDVSplashScreen"/><paramname="onload"value="true"/></feature></config-file><!--为了举例添加的例子代码--><config-filetarget="helloworld-Info.plist"parent="CFBundleURLTypes"><array><dict><key>PackageName</key><string>$PACKAGE_NAME</string></dict></array></config-file><header-filesrc="src/ios/CDVSplashScreen.h" /><source-filesrc="src/ios/CDVSplashScreen.m" /><header-filesrc="src/ios/CDVViewController+SplashScreen.h" /><source-filesrc="src/ios/CDVViewController+SplashScreen.m" /><frameworksrc="CoreGraphics.framework" /></platform></plugin>
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
资源包主要包含以下内容: ASP项目源码:每个资源包中都包含完整的ASP项目源码,这些源码采用了经典的ASP技术开发,结构清晰、注释详细,帮助用户轻松理解整个项目的逻辑和实现方式。通过这些源码,用户可以学习到ASP的基本语法、服务器端脚本编写方法、数据库操作、用户权限管理等关键技术。 数据库设计文件:为了方便用户更好地理解系统的后台逻辑,每个项目中都附带了完整的数据库设计文件。这些文件通常包括数据库结构图、数据表设计文档,以及示例数据SQL脚本。用户可以通过这些文件快速搭建项目所需的数据库环境,并了解各个数据表之间的关系和作用。 详细的开发文档:每个资源包都附有详细的开发文档,文档内容包括项目背景介绍、功能模块说明、系统流程图、用户界面设计以及关键代码解析等。这些文档为用户提供了深入的学习材料,使得即便是从零开始的开发者也能逐步掌握项目开发的全过程。 项目演示与使用指南:为帮助用户更好地理解和使用这些ASP项目,每个资源包中都包含项目的演示文件和使用指南。演示文件通常以视频或图文形式展示项目的主要功能和操作流程,使用指南则详细说明了如何配置开发环境、部署项目以及常见问题的解决方法。 毕业设计参考:对于正在准备毕业设计的学生来说,这些资源包是绝佳的参考材料。每个项目不仅功能完善、结构清晰,还符合常见的毕业设计要求和标准。通过这些项目,学生可以学习到如何从零开始构建一个完整的Web系统,并积累丰富的项目经验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值