Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3132] iOS: Platform Specific JS Not Considered in Build Scripts Exclusion Process

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2016-08-19T18:46:32.000+0000
Affected Version/sRelease 1.6.0, Release 2.0.2
Fix Version/sn/a
ComponentsiOS
Labelsdefect, ios, reported-1.6.0, rplist
ReporterDawson Toth
AssigneeIngo Muschenetz
Created2011-04-15T03:37:43.000+0000
Updated2017-03-22T20:57:10.000+0000

Description

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

Comments

  1. Heath Hopkins 2012-04-26

    The issue has not been resolved as of 2.0.1.GA
  2. Chris Barber 2016-08-19

    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.
  3. Lee Morris 2017-03-22

    Closing ticket as invalid with reference to the above comments.

JSON Source