Configuring the Module

You could embed all the necessary configuration for your module in the code.

However, if you plan to publish your module, or if you just want to make it easier to tweak its parameters as you are using a module internally, you can specify configuration that module users must supply.

Specifying the required configuration

By including a module/config_schema.json file, you can define the configuration options your module depends on.

This file is structed in an extended form of JSON Schema, something like this:

{
    "type": "object",
    "additionalProperties": false,
    "properties": {
        "ipad": {
            "required": false,
            "type": "string",
            "dependencies": ["ipad-landscape"],
            "_filepicker": true
        },
        "ipad-landscape": {
            "required": false,
            "type": "string",
            "dependencies": ["ipad"],
            "_filepicker": true
        },
        "hide-manually": {
            "description": "If this is enabled then it is your responsiblity to hide the launch image once your app is ready. See the API docs for more details.",
            "required": false,
            "type": "boolean"
        },
        "background-color": {
            "type": "string",
            "required": false,
            "description": "The color to be shown behind the image if it doesn't fit the screen exactly - e.g. \"#303045\"",
            "pattern": "^#[\\da-fA-F]{6}$"
        }
    }
}

This is an abridged version of the launchimage module's configuration schema.

Note the use of _filepicker to create a file path input field, and the different types that affect the HTML input type for this field.

Reading in the configuration in your module

In your module, you would read in the supplied configuration values with ForgeApp.configForModule on Android, and [ForgeApp configForModule] on iOS.

For example:

NSString* appid = [[[ForgeApp sharedApp] configForPlugin:@"facebook"] objectForKey:@"appid"];

or:

ForgeApp.configForPlugin("facebook").get("appid").getAsString()

In your build steps files, you can use Mustache templating, e.g.:

"do": {
    "copy_file_from_src": {
        "filename": "{{modules.icons.config.ios.120}}",
        "dest": "120.png"
    }
}