Search code examples
sencha-touch-2sencha-architect

How to add 'Ext.require' in Sencha Architect 2


Per the instructions here in order to use the Native API I need to add an 'Ext.require()' to the code. How do I do that in Sencha Architect 2? It seems like everything outside a custom function or an event is readonly so I can't just add my own code ad-hoc.


Solution

  • As suggested by Bharat Nagwani, Architect now includes a way to require any classes that you would like to dynamically load.

    Luca Candela and I presented a small application which illustrates use of the Ext.device.Camera API a few weeks ago in London. https://github.com/CaliLuke/NativeContacts

    In order to include the device api in your application, do the following:

    • Go into the Sencha SDK and copy the device folder into your project directory
    • Inside of Architect, click the Application node
    • Search for "requires" in the configuration panel
    • Add "Ext.device.Camera" to the requires configuration
    • Search for "loader" in the configuration panel
    • Click the + to the right of Loader Config
    • Click the newly added "Loader" node (a child of Application)
    • Add paths '{"Ext.device": "device/"}

    So to sum it up, make sure the files are there. Tell the application that you need that Class and then tell the loader where to find those files you've just put into your project folder.