PhoneGap 3.1.0差异超过2.9.0?

时间:2013-11-25 23:54:15

标签: ios cordova phonegap-build cordova-3

我正在使用以下内容在iOS上使用PhoneGap获取应用程序的根文件夹。使用Phonegap Build构建。它在phonegap 2.9.0上工作正常,但在3.1.0上失败。有人可以指出改变了什么,代码可能出了什么问题?谢谢。

function findLocalPath()
{
    window.requestFileSystem(  
        LocalFileSystem.PERSISTENT, 
        0,  
        function onFileSystemSuccess(fileSystem)
        {  
            fileSystem.root.getFile(
                "dummy.html", 
                {create: true, exclusive: false},  
                function gotFileEntry(fileEntry)
                { 
                    var sPath = fileEntry.fullPath.replace("dummy.html","");  
                    var fileTransfer = new FileTransfer();  
                    fileEntry.remove();

                    alert(sPath);
                },
            fail);
        },  
    fail);
 }

在config.xml中,我已经替换了

<plugin name="File" value="CDVFile" />
<plugin name="FileTransfer" value="CDVFileTransfer" />

以下文件,如文档所述。

<feature name="File">
    <param name="ios-package" value="CDVFile" />
</feature>
<feature name="FileTransfer">
    <param name="ios-package" value="CDVFileTransfer" />
</feature>

1 个答案:

答案 0 :(得分:2)

在phonegap 3.x中,您必须使用命令行添加插件,而不是更改config.xml

添加文件和文件传输使用此:

cordova plugin add org.apache.cordova.file

cordova plugin add org.apache.cordova.file-transfer

它将更改config.xml并添加其他所需文件。

对于phonegap构建,您必须在本地添加它们,然后使用以下命令在线构建它们:

phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git
phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer.git
phonegap remote build ios