Uploaded image for project: 'Documentation'
  1. Documentation
  2. TIDOC-514

commonJS require with relative and absolute paths with Android and Iphone

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Low
    • Resolution: Cannot Reproduce
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Guides
    • Labels:
      None
    • Environment:

      Titanium 1.8 sdk

    • Customer Priority:
      Next Patch
    • Customer Labels:

      Description

      Using require with a file that is located in a directory above, then trying to access a file under that directory works different in android then it does in iphone.

      using 1.8 SDK tested in simulator, android 2.2 emulator and devices running 2.2, 2.3

      taken from: http://wiki.commonjs.org/wiki/Modules/1.1, Point 4 under Module identifiers:
      Module identifiers may be "relative" or "top-level". A module identifier is "relative" if the first term is "." or "..".

      example: app.js
      ------------------------------
      var test = require('levelOne/levelOne');
      test.open();
      //works in both

      levelZero.js located in Resources folder, same as app.s
      ------------------------------
      exports.open = function(){
      Ti.UI.createWindow(

      { backgroundColor: '#AAAAAA' }

      ).open();

      levelOne.js located in levelOne Folder right above app.js
      ------------------------------
      //note that i would only have one of these running below at a time

      exports.open = function()

      {require('../levelZero')}

      ;
      //can't find the file in Iphone, can find it on Android

      exports.open = function()

      {require('levelZero')}

      ;
      //can't fine the file in Android, can find it on Iphone

        Attachments

          Activity

            People

            • Assignee:
              aevans Arthur Evans
              Reporter:
              paul h Paul Hamilton
            • Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Git Source Code