Alloy uses the
config.json file, located in the project's
app directory, to specify global values, conditional environment and platform values, and widget dependencies. The configuration file contains the following objects:
Contains key-value pairs present for all environments and platforms.
Contains key-value pairs present for targets built for development, running in either the simulator or emulator.
Contains key-value pairs present for targets built for testing on a device.
Contains key-value pairs present for targets built for production, running after a package installation.
Contains key-value pairs present for targets built for Android.
|os:ios||Contains key-value pairs present for targets built for iOS.|
|os:windows||Contains key-value pairs present for targets built for Windows Phone. Note: Support for Windows 8.1 and Windows Phone SDKs has been deprecated as of SDK 6.3.0.GA and has be removed in SDK 7.0.0.GA.|
Contains key-value pairs for widget dependencies, where the key is the widget name and the value is the version number of the widget.
|autoStyle||Enables the autostyle feature for the entire Alloy project. See Dynamic Styles: Autostyle for more information.|
|backbone||Select the Backbone.js library to use for Alloy Model and Collection objects. Set to either |
When mixed together, 'os' values override 'env' values, which override 'global' values. If you want to specify both a platform and environment-specific configuation, combine the 'os' and 'env' values together into one string with the values space separated. These values are accessible during runtime by prefixing the key with
Example of a configuration file:
In the above example, if the application is ran on the iPhone simulator and prints out 'foo' using
Ti.API.info(Alloy.CFG.foo), it will return '6.'