View unanswered posts | View active topics

Reply to topic  [ 2 posts ] 
Prebuild scripts for multi-platform development 
Author Message

Joined: Tue Mar 27, 2012 6:48 am
Posts: 50
Reply with quote
Hi everyone,

Last update: 13 march 2014

I am sharing my scripts for multi-platform development. All my projects are developed for three targets: iOS, Android and Web (which for me is Facebook). Normally when you want to compile for a specific target you need to do all sorts of manual edits to application.xml (e.g. native extensions), Run.bat (target) and others. Well, by using these scripts all I have to do is change my compiler constants to choose my target, and it does the rest!

Download them here (zip)

Important: Use completely at your own risk. Make a backup of your entire project before using these if you are uncertain at all about using them.

This is what they do:
- On first run:
    - Automatically back everything up and make alterations to project. No need to do any manual setup
    - Adds compiler constants to project for iOS, Web and Android build targets
    - Alters Run.bat, SetupApplication.bat and Packager.bat to support changing build target
    - Adds distribution specific provisioning options to SetupApplication.bat (so they can be different from dev/test)
- On each build:
    - Makes target-specific application.xml files
    - Update Run.bat to build for correct target
    - Optionally updates version/build number
    - Optionally updates DEBUG_IP to current IP
    - Optionally copies applicationId from application xml so they are same

This is how to install them:
1) Ensure you have PHP installed and it is able to run command line scripts
2) Unzip to a folder in your project structure called /script
3) Add this 'prebuild' command to your project: php script/prebuild.php $(BuildConfig) all
NOTE: Can be used in a new, or an existing project

This is how they work:
1) There are three compiler constants CONFIG::iOS, CONFIG::Android and CONFIG::Web
2) Use these for conditional code throughout your project
3) To change build target, simply set ONE of these to true (others to false) and build!

These comments are inside prebuild.php
    * pre-build script for Flash Develop
    * ----------------------------------
    * @version   0.2
    * @date   2014-03-13
    * @author    Peter Vullings <>
    * ----------------------------------
    * performs the following actions:
    * - On first run, will set up the build environment for a Pixelthis project
    *        - Create backup folder and save a copy of all affected files
    *        - Add 'ext' folder for native extensions and reference it from build script
    *        - Add code to detect if the build is for iOS, Android or Web
    * - Increases the build number (part after the last dot) of the version number inside application.xml
    * - Detects the platform (iOS, Android, Web) and debug / release, and makes a new application.xml and
    *   runs correct build command accordingly
    * - Updated SetupApplication.bat with current Debug IP address, and copies application ID from application XML
    * TO SET UP:
    * 1) Install PHP and set it up to allow running from command line
    *        - Windows
    *            - Follow these instructions:
    *            - Make sure you follow the steps to associate the php extension with the filetype, and the
    *              filetype with the executable
    *        - OSX
    *            - Follow these instructions:
    *            - In most cases php can already run from the command line
    *        - Other platforms
    *            -
    * 2) Unzip all scripts to a 'script' folder at same level as 'lib' and 'bin'
    * 3) Add the following pre-build command:
    *       - Open Project > Properties, [Build]
    *       - press the [Builder...] button below 'pre-build command line'
    *       - Enter the following line:
    *            - php script/prebuild.php $(BuildConfig) [options]
    *       - Options
    *            - $(BuildConfig): Required. This allows the script to detect debug / release setting
    *           - all: Optional. If 'all' is specified, all options are enabled (except silent mode)
    *           - version: Optional. If 'all' is not specified, this will increase the build number
    *           - debugip: Optional. If 'all' is not specified, this will detect current IP and update DEBUG_IP
    *           - appid: Optional. If 'all' is not specified, this will copy the appId from application.xml to SetupApplication.bat
    *           - silent: Optional. This will suppress any output from the scripts (including notifications and error messages)
    * TO USE:
    * - To change the target platform at any time, set ONE of the compiler constants to true:
    *        - Open Project > Properties, [Compiler Options]
    *        - Edit the 'Compiler constants':
    *            - CONFIG::iOS,true-or-false
    *            - CONFIG::Android,true-or-false
    *            - CONFIG::Web,true-or-false
    * - Build as you normally would (e.g. CTRL+enter)
    *      - Note: The very first time the script is run it will set up the environment automatically (see notes)
    * NOTES:
    * - The script assumes you are using a standard Flash Develop AS3 project, with default folder structure
    *        - Looks in "/../bat" for batch files
    *        - Looks in "/../" for ___.as3proj, application.xml and Run.bat
    * - On first run, the script will create a folder called 'backup' inside the script folder and place
    *   an original copy of each file it modifies in there. If you delete this folder, the prebuild script will
    *   perform the original setup process again.
    * ----------------------------------
    * Version Info
    *           v0.1   -   12 March 2014:   Original release
    *           v0.2   -   13 march 2014:   Only saves files if they have changed
    *                              Changed arguments to all | silent | version | debugip | appid   
    *                              Initial setup inserts fields for distribution-specific provisioning (iOS)

Last edited by peter.vullings on Wed Mar 12, 2014 10:09 pm, edited 5 times in total.

Tue Mar 11, 2014 1:13 am

Joined: Thu May 15, 2008 7:36 pm
Posts: 636
Location: Baltimore, MD
Reply with quote


Tue Mar 11, 2014 12:58 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.