2012-05-30 61 views
3

對於客戶端,我需要使用Sencha Touch和Cordova構建本機應用程序。如何使用Cordova/PhoneGap構建sencha應用程序

爲了提高性能,我使用SDK Tools中的命令「sencha app build package」來縮小javascript源代碼。

如果我使用Sencha進行開發,而Corova使用webview,則沒有任何問題。但是我需要使用Cordova功能(如FileSystem,...),我無法使用Sencha。

問題是,當我使用「sencha應用程序構建包」,我有像[ERROR] ReferenceError: Can't find variable: fileSystem錯誤。

我看了很多關於Sencha + Cordova的帖子,但他們都沒有談論用Cordova + Sencha構建/縮小源碼。

有沒有人遇到過這個問題,你是如何解決這個問題的?

問候

UPDATE ON收取罰金

我使用了一個叫做爲每個需要訪問到科爾多瓦變量方法CordovaFunctions.js文件,我app.js等視圖/控制器調用方法CordovaFunctions.js ...

這裏是我的app.json:

{ 
/** 
* The application's namespace, used by Sencha Command to generate classes 
*/ 
"name": "ImageDownloader", 

/** 
* The file path to this application's front HTML document, relative to this app.json file 
*/ 
"indexHtmlPath": "index.html", 

/** 
* The absolute URL to this application in development environment, i.e: the URL to run this application 
* on your web browser during development, e.g: "http://localhost/myapp/index.html". 
* 
* This value is needed when build to resolve your application's dependencies if it requires server-side resources 
* that are not accessible via file system protocol. 
*/ 
"url": null, 

/** 
* List of all JavaScript assets in the right execution order. 
* Each item is an object with the following format: 
*  { 
*   "path": "path/to/script.js" // Relative path to this app.json file 
*   "update": "delta"   // (Optional) 
*          // - If not specified, this file will only be loaded once, and 
*          // cached inside localStorage until this value is changed. 
*          // - "delta" to enable over-the-air delta update for this file 
*          // - "full" means full update will be made when this file changes 
* 
*  } 
*/ 
"js": [ 

    { 
     "path": "cordova-1.7.0.js" 
    },/* 
    { 
     "path": "CordovaFunctions.js" 
    },*/ 
    { 
     "path": "sdk/sencha-touch.js" 
    } 
    , 
    { 
     "path": "app.js", 
     "bundle": true, // Indicates that all class dependencies are concatenated into this file when build 
     "update": "delta" 
    } 
], 

/** 
* List of all CSS assets in the right inclusion order. 
* Each item is an object with the following format: 
*  { 
*   "path": "path/to/item.css" // Relative path to this app.json file 
*   "update": "delta"   // (Optional) 
*          // - If not specified, this file will only be loaded once, and 
*          // cached inside localStorage until this value is changed to either one below 
*          // - "delta" to enable over-the-air delta update for this file 
*          // - "full" means full update will be made when this file changes 
* 
*  } 
*/ 
"css": [ 
    { 
     "path": "resources/css/app.css", 
     "update": "delta" 
    } 
], 

/** 
* Used to automatically generate cache.manifest (HTML 5 application cache manifest) file when you build 
*/ 
"appCache": { 
    /** 
    * List of items in the CACHE MANIFEST section 
    */ 
    "cache": [ 
     "index.html" 
    ], 
    /** 
    * List of items in the NETWORK section 
    */ 
    "network": [ 
     "*" 
    ], 
    /** 
    * List of items in the FALLBACK section 
    */ 
    "fallback": [] 
}, 

/** 
* Extra resources to be copied along when build 
*/ 
"resources": [ 
    "resources/images", 
    "resources/icons", 
    "resources/startup" 
], 

/** 
* File/directory name matchers to ignore when copying to the builds, must be valid regular expressions 
*/ 
"ignore": [ 
    "\.svn$" 
], 

/** 
* Directory path to store all previous production builds. Note that the content generated inside this directory 
* must be kept intact for proper generation of deltas between updates 
*/ 
"archivePath": "archive", 

/** 
* Default paths to build this application to for each environment 
*/ 
"buildPaths": { 
    "testing": "build/testing", 
    "production": "build/production", 
    "package": "build/package", 
    "native": "build/native" 
}, 

/** 
* Build options 
*/ 
"buildOptions": { 
    "product": "touch", 
    "minVersion": 3, 
    "debug": false, 
    "logger": "no" 
}, 

/** 
* Uniquely generated id for this application, used as prefix for localStorage keys. 
* Normally you should never change this value. 
*/ 
"id": "dfbad430-a63b-11e1-a218-a1757e9a8324" 
} 

回答

0

在您的app.json配置文件中,您需要告訴Sencha build命令phoneGap庫是您的應用程序所必需的。將它添加到JS節點:

/** 
* List of all JavaScript assets in the right execution order. 
* Each item is an object with the following format: 
*  { 
*   "path": "path/to/script.js" // Relative path to this app.json file 
*   "update": "delta"   // (Optional) 
*          // - If not specified, this file will only be loaded once, and 
*          // cached inside localStorage until this value is changed. 
*          // - "delta" to enable over-the-air delta update for this file 
*          // - "full" means full update will be made when this file changes 
* 
*  } 
*/ 
"js": [ 
    { 
     "path": "sdk/sencha-touch.js" 
    }, 
    { 
     "path": "cordova-1.5.0.js" 
    }, 
    { 
     "path": "app.js", 
     "bundle": true, /* Indicates that all class dependencies are concatenated into this file when build */ 
     "update": "delta" 
    } 
], 
+0

我很欣賞你的努力,但我已經做到了這一點,因爲我使用的文件名爲科爾多瓦和煎茶之間CaordvaFunctions.js,它一點兒也不工作:'[錯誤]的ReferenceError :找不到變量:fileSystem'。我用我的app.json的內容更新我的帖子 –

相關問題