如何建立与IDE支持科尔多瓦插件项目? [英] How to set up Cordova plugin project with IDE support?

查看:144
本文介绍了如何建立与IDE支持科尔多瓦插件项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力建立我的科尔多瓦插件工程。主要是由于以下事实:

I've been struggling to set up my cordova plugin project. Mainly due the facts that:


  • 插件需要在一个单独的文件夹从主客场项目

  • Plugins need to be in a separate folder away from the main project

当我使用的,例如科尔多瓦构建Android 来构建项目,科尔多瓦副本从我的插件文件夹中的java文件,并把它变成平台/安卓/ src目录文件夹中。

When I use, for example, cordova build android to build the project, cordova copies the java file from my plugin folder and put it into platforms/android/src folder.

因此​​,我不应该手动修改我的插件的java文件在Android项目中,我写我的code在我的插件文件夹中。

Thus I should not modify my plugin's .java file in the Android project manually, I have to write my code in my plugin folder.

但我不能插件文件夹导入到IDE项目,因此我没有code完成。

But I can't import plugin folder into the IDE project, thus I don't have code completion.

这是基本不可能编写Java / Objective-C的不支持IDE

It's basically impossible to write Java/Objective-C without IDE support

如何建立一个IDE(例如,针对Android工作室)与code完成了我的插件开发项目?

How can I set up an IDE(for example, for Android Studio) project with code completion for my plugin development?

推荐答案

制定科尔多瓦插件是一个有点疼痛。

Developing a Cordova plugin is a bit of a pain.

下面是一个办法做到这一点:

Here is a way to do it :


  1. 创建你的插件的基本文件(的plugin.xml 文件,的.java 文件为Android插件, .H .M 在你的插件分隔的文件夹适用于iOS的文件)

  2. 提供在的plugin.xml 来安装该插件需要什么

  3. 在科尔多瓦的应用程序安装你的插件:科尔多瓦插件添加/路径/要/普金

  4. 构建你想发展你的插件平台。 科尔多瓦构建Android 科尔多瓦建设的ios

  1. Create the basic files of your plugin (plugin.xml file, .java file for Android plugin, .h and .m files for iOS) in a separated folder for your plugin
  2. Provide in your plugin.xml what is needed to install the plugin
  3. Install your plugin in your Cordova app : cordova plugin add /path/to/pugin
  4. Build the platforms you want to develop your plugin. cordova build android or cordova build ios

然后为每个平台,您必须对您的插件在建造项目的直接工作:

Then for each platform, you'll have to work directly on your plugin in the builded project :


  • 安卓与Android工作室的建造Android项目位于 yourCordovaAppFolder /平台/ Android开放导入项目(Eclipse的ADT,摇篮等)。


  1. 打开项目工具窗口查看>工具窗口>项目或<大骨节病>⌘ + <大骨节病> 1

  2. 打开你的插件类文件位于:安卓>的java> com.your.plugin> YourPlugin

  1. Open the Project tool window : View > Tool Windows > Project , or + 1
  2. Open your plugin class file located at : android > java > com.your.plugin > YourPlugin

iOS版:以X code位于 yourCordovaAppFolder /建造该项目的iOS开放平台/ IOS
在X code,你的插件类文件位于插件文件夹

  • iOS : open with Xcode the builded iOS project located in yourCordovaAppFolder/platforms/ios In Xcode, your plugin class files are located in the Plugins folder

    您就可以开发和测试,直接你的插件为每个平台,而不需要一次又一次重新安装一遍......只是运行Android的工作室/ X code,和该项目不重新安装插件,它会抹去你在项目中做了什么

    You can then develop and test directly your plugin for each platform without the need to reinstall it again and again and again... just run the project from Android Studio/Xcode, and don't reinstall your plugin, it will erase what you have done in the project.

    当你认为你的开发完成(或当你想),取代在第一步创建的,从你正在开发的项目之一,原来的插件文件夹中的插件文件(S)。

    When you think your developments are done (or when you want to), replace the plugin file(s) in the original plugin folder created at very first step, with the one from the project you were developing on.

    编辑:

    我发现的Eclipse去年夏天做了更新, 火星的Eclipse(4.5) ,包括 THYM (混合移动工具)。

    I've discovered that Eclipse made an update last summer, Eclipse Mars (4.5) that includes Thym (The HYbrid Mobile Tools).

    如果需要他们有一个 Github上的项目页面

    我赶紧对其进行了测试,它允许创建科尔多瓦项目中,轻松地添加插件,直接在所需的平台上运行(Android版,iOS版)。

    I've quickly tested it, it allows to create Cordova projects, easily add plugins, and run directly on desired platform (Android, iOS).

    微软也取得了的Visual Studio的免费版本的Apache科尔多瓦,但我没有测试它。

    Microsoft has also made a free version of Visual Studio for Apache Cordova, but I haven't tested it.

    关于与THYM Eclipse中,我第一次快速的结论是,这是实际的开发应用科尔多瓦但将不会是最终的解决方案来开发插件科尔多瓦,因为它不是面向这种方式,并没有对于插件,但应用程序做出决策(而且很可能是为Visual Studio为Apache科尔多瓦相同)。

    Regarding Eclipse with Thym, my first quick conclusion is that it is practical to develop Cordova apps but won't be THE ultimate solution to develop Cordova plugins because it is not oriented this way and was not made for plugins but apps making (and it is probably the same for Visual Studio for Apache Cordova).

    当我遇到了一些麻烦,推出的iOS模拟器与Eclipse + THYM的方式,所以也许它仍然需要改进,即使它看起来已经很好了。

    By the way I had some trouble to launch iOS simulator with Eclipse+Thym, so maybe it still needs improvements even if it looks already good.

    这篇关于如何建立与IDE支持科尔多瓦插件项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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