Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14884] iOS: device builds don't use platform-specific files for commonjs modules

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-09-20T23:11:03.000+0000
Affected Version/sRelease 3.0.2, Release 3.1.0, Release 3.1.1, Release 3.1.2
Fix Version/s2013 Sprint 19, 2013 Sprint 19 Core, Release 3.2.0
ComponentsiOS
Labelsn/a
ReporterTony Lukasavage
AssigneeChris Barber
Created2013-08-14T21:25:22.000+0000
Updated2013-12-19T20:09:27.000+0000

Description

problem

When referencing commonjs modules in code, iOS device builds do not reference platform specific modules if they are present, instead they reference the non-platform-specific ones. This does not occur on iOS simulator builds, which behave as expected. This makes it impossible to use platform-specific versions of Javascript files on iOS device builds, being a blocker for the linked tickets.

test case

app.js

var win = Ti.UI.createWindow({
	backgroundColor: '#fff',
	modal: false,
	exitOnClose: true
});

win.open();

require('lib/mylib').sayHello();

lib/mylib.js

exports.sayHello = function() {
	alert('hello from the CFG.js (you should never see this)');
}

iphone/lib/mylib.js

exports.sayHello = function() {
	alert('hello from the iphone CFG.js');
}

reproduce

Create a traditional titanium app, adding the files mentioned above.

Run for iOS simulator

Confirm that you get the message from the platform-specific mylib.js file: "hello from the iphone CFG.js"

Now run for an iOS device

You will get the error described here, where the non-platform-specific module is referenced, giving you the message: "hello from the CFG.js (you should never see this)"

Comments

  1. Tristan Roscoe 2013-09-06

    This works for iPhone, not pretty though: alloy compile --config platform=ios && cp -r Resources/iphone/* Resources && ti build --platform ios -T device OSX 10.8.4 Xcode Version 5.0 (5A11386k) Titanium CLI 3.1.2 Alloy 1.3.0 SDK 3.1.2.GA
  2. Tony Lukasavage 2013-09-06

    Just to explain [~troscoe]'s comment a bit, it is relative to Alloy 1.3.0 which uses platform-specific compiles (ALOY-760). Due to this ticket, these don't work properly for iOS device builds. His steps workaround this issue by:

    Compiling Alloy for ios, putting files in platform-specific folder

    Copy the platform-specific files to top-level Resources folder. This won't conflict with other platforms since their platform-specific folders behave as expected and will override these.

    Run a titanium build, which will compile alloy to the platform-specific folder again. These will be ignored and the files copied in the last step will be used by the Titanium build process.

  3. Chris Barber 2013-09-21

    Pull request: https://github.com/appcelerator/titanium_mobile/pull/4723
  4. Wilson Luu 2013-10-21

    Closing ticket as fixed. Verified the "hello from the iphone CFG.js" alert is appearing on iOS device when adding lib/mylib.js and iphone/lib/mylib.js to the specified directory. Tested on: Titanium Studio, build: 3.2.0.201310181940 OS: Mac OS X Mountain Lion (10.8.5) SDK build: 3.2.0.v20131021142445 Ti CLI: 3.2.0 (72f7426b4ee6c2d2883c666d5b7e03906a16012f) Devices: iphone 4s (6.0.1), iphone 5 (7.0.2)

JSON Source