Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12115] iOS: utils.js commonjs module will not work on iOS

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionCannot Reproduce
Resolution Date2013-04-08T11:30:58.000+0000
Affected Version/sRelease 3.0.0
Fix Version/sRelease 3.0.2
ComponentsiOS
Labelsparity
ReporterTony Lukasavage
Assigneejithinpv
Created2012-12-18T16:14:45.000+0000
Updated2017-03-21T21:54:44.000+0000

Description

problem

If I define a commonjs module named *utils.js* or *Utils.js* in my iOS project, I get a runtime error when trying to access it. The error looks like the attached screenshot when used with the test case below. This issue does *not* occur on Android or Mobileweb. This error also does not occur if I move utils.js into a folder. I assume that iOS is overwriting utils.js within an internally used module of it own, or something to that effect.

expected behavior

I should be able to define and use a commonjs module named utils.js or Utils.js in my iOS project.

test case

utils.js

exports.sayHi = function() {
    alert('hi');
}

app.js

require('utils').sayHi(); 

Attachments

FileDateSize
Screen Shot 2012-12-18 at 11.14.30 AM.png2012-12-18T16:14:45.000+000043041

Comments

  1. JH 2012-12-20

    The titanium submodule utils is imported. The same goes for all .js files named as titanium submodules. More info here: http://developer.appcelerator.com/question/145896/ti-30-requireui-returns-the-tiui-module-instead-of-uijs
  2. Tony Lukasavage 2013-01-22

    Yet another case: http://developer.appcelerator.com/question/147253/commonjs-module-not-working-in-ios-simulator
  3. jithinpv 2013-04-08

    Issue does not reproduces Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 Titanium SDK version: 3.0.2 iOS iPhone Simulator: iOS SDK version: 6.0
  4. Tony Lukasavage 2013-04-08

    Is there any info on where this was actually resolved? A commit in 3.0.2 or something? I just confirmed that it is now working properly in 3.1.0 for me as well.
  5. jithinpv 2013-06-20

    Issue does not reproduces Tested with iOS SDK: 5.1 iOS iPhone Simulator: 5.1 Mac OS X Version 10.7.5 Titanium SDK version 3.1.1.v20130606121419 Titanium Studio, build: 3.0.1.201212181159
  6. Lee Morris 2017-03-21

    Closing ticket as the issue cannot be reproduced and due to the above comments.

JSON Source