Problem
Platform specific JavaScript files are not considered when the build scripts decide what modules to exclude. That means if you only use Ti.UI.createWindow in a platform specific JavaScript file, you will NOT be able to deploy to device.
NOTE: This will ONLY show up when you deploy to device! The simulator build scripts don't exclude modules, so this bug will not show up there.
Error
When deploying to device, the following error will pop up:
Application Error
invalid method (createWindow) passed to UIModule at createWindow.js (line 2)
Sample Code
Place the following in your Resources/app.js. Note that you can uncomment the last line to force the build scripts to include Ti.UI.Window.
// include a file that attempts to create a new window
// if this file is in the platform build folder, its content won't be used to decide what modules to include
Ti.include('createWindow.js');
// so if we explicitly specify "we're going to use Ti.UI.Window", this program will work
// but if you comment out the following line, and deploy to device, this app will NOT work
//Ti.UI.createWindow;
Now place the following in Resources/iphone/createWindow.js. Note that if you move it to Resources/createWindow.js (out of the iphone folder), everything will work.
var win = Ti.UI.createWindow({
backgroundColor: '#0f0'
});
win.open();
If everything works (if the bug is NOT present), you will see a window with a green background.
Tested On
Titanium SDK version: 1.6.0 (02/10/11 14:34 9db0685...)
WORKS on iPhone Simulator 4.2
BROKEN on iPod Touch 3rd Generation
WORKS on Android Device 2.1 (when placed in Resources/android folder)
Workaround
Either move the code out of the iphone folder, or explicitly force Titanium to include the components that are being excluded by placing the following in your app.js:
Ti.UI.createWindow; // note that we don't actually call this function; just a reference is enough
Associated Helpdesk Ticket
http://developer.appcelerator.com/helpdesk/view/73211
The issue has not been resolved as of 2.0.1.GA
Resolving this ticket as invalid. In Titanium SDK 3.0.0, we correctly overlay platform specific JS on top of non-platform specific code, then parse and walk the AST to find the native modules being used. This shouldn't be an issue anymore.
Closing ticket as invalid with reference to the above comments.