Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10914] iOS: When building for iOS devices, the string "Titanium" will be crippled in my application

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionCannot Reproduce
Resolution Date2016-08-24T19:28:00.000+0000
Affected Version/sRelease 2.0.2
Fix Version/sn/a
ComponentsiOS
Labelscommunity, core, exalture, parity
ReporterSven Herzberg
AssigneeEric Merriman
Created2012-09-12T03:02:41.000+0000
Updated2017-03-24T21:58:45.000+0000

Description

My example application breaks when being built for iOS devices (e.g. via Run on "iOS device"), it does not break in the iOS simulator. This is an inconsistency that can introduce bugs in software when people just run quick tests in the iOS simulator. Here is my example code:
	var MyNamespace,
	    win;
	
	try {
		MyNamespace = {};
		MyNamespace.Titanium = {};
		MyNamespace.Titanium.UI = {};
		MyNamespace.Titanium.UI.createWindow = function (params) {
			var result = Titanium.UI.createWindow(params);
			
			if (!params.hasOwnProperty('orientationModes')) {
				result.orientationModes = [
					Titanium.UI.PORTRAIT
				];
			}
			
			return result;
		};
		
		win = MyNamespace.Titanium.UI.createWindow({
			backgroundColor: '#fff',
			navBarHidden:    true
		});
		win.open();
	} catch (e) {
		alert("Ooops! Someone broke *.Titanium.UI.*: " + e);
	}

This code works as expected in the iOS simulator and on Android device. I have not tested the Android emulator (yet I am confident that it will work). The code does not work on iOS devices yielding this alert message: Oooops! Someone broke \*.Ti.UI.\*: TypeError: 'undefined' is not an object (evaluating 'MyNamespace.Ti.UI = {}') Observations:

MyNamespace.Titanium.UI gets changed into MyNamespace.Ti.UI (which breaks my code)

Even the string fragment "\*.Titanium.UI.\*" will be changed into "\*.Ti.UI.\*"

Comments

  1. Chris Barber 2016-08-24

    I cannot reproduce with Titanium SDK master (6.1.0). I suspect this is because we properly AST parse and minify JS code now. I believe this was fixed in 3.0.0 with the iOS build rewrite.
  2. Lee Morris 2017-03-24

    Closing ticket as the issue cannot be reproduced and with reference to the previous comments.

JSON Source