Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2585] Include paths for iphone and android are not based on the same starting point

GitHub Issuen/a
Resolution Date2011-04-17T01:59:31.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.7.0, Sprint 2011-10
Labelsandroid, defect, enterprise, klist, release-1.7.0, reported-1.5.0, rplist
AssigneeDon Thorp


This issue is making me nuts! :-)

I have broken my app into small, manageable pieces and link things together using Titanium.include and the 'url' property when creating a new window.

Both of these require a 'path' to a .js file. The trouble is, one platform seems to want it relative to the root and the other relative to where the file is being included from. The url property used to be the same (iphone vs android) until 1.5, but after I upgraded today I found that it had changed on android requiring me to fiddle the paths to get the app working again.

Can we please have it one way or the other on all platforms? I am trying to build a core of code that will work across all platforms and having to deal with varying path models is just making my code that much more complex.





  1. Dawson Toth 2011-04-15

    Associated Helpdesk Ticket


    We have an enterprise client and a premium client pushing for consistency as well.

  2. John Welch 2011-04-15

    Thank you for the escalation.

  3. Don Thorp 2011-04-15

    To be discussed next week to identify the underlying issue.

  4. John Welch 2011-04-15

    Attached is an example project showing the issue. I don't know if the example is overkill but this is how I am seeing the problem with another project.

    The file contained in /include/folder2/other_file.js has the following:

       // This works for iPhone: 
       // Titanium.include("../../include/folder/file.js");
       // This works for Android & errors for iPhone:
       alert("A variable != " + theMessage);

    I've built and tested this using mobilesdk-1.6.0-20110106161536-osx.zip.

    I'm guessing the issue it somewhere in loadAppResource method, but who knows... Going to try to figure something out tomorrow.

  5. Andreas sandberg 2011-04-15

    This ticket is also probably related to LH #1986. Same failure/results for images specified with absolute urls.

  6. John Welch 2011-04-15

    I have two projects at a stand still due to this bug. Is there a current ETA for this issue to be resolved?

  7. Indy 2011-04-15

    So, the work-around would be be use case statement around each include()?

    ie: if( Utils.isIOS() ) { Ti.include('include/utils/dashboard.js') } else { Ti.include('utils/dashboard.js') }

    from ticket #62271

  8. hal 2011-04-15

    Just to summarize paths for images, this has just been tested on iOS 4.2 / Ti 1.6.0 (3 Feb 2011) with the following results for both the image and backgroundImage properties of imageView (using the simple project attached):

       image: 'card/'+i+'.png', // no leading slash (relative) works
       image: './card/'+i+'.png', // leading dot and slash works
       image: '/card/'+i+'.png', // leading slash does *not* work
       image: 'app://card/'+i+'.png', // leading "app://" does *not* work

    The same code and tests on Android APIs 2.2 / Ti 1.6.0 (2 Feb 2011) work for all of the above 4 paths.

    Note, I have not tested a relative parent path (double-dot and slash), ie ../

  9. Dawson Toth 2011-04-15

    I've updated the ticket so that it is properly tagged, given that their is HD interest and enterprise interest in its resolution.

    Unofficial Workaround

    Unofficially (aka unsupported, at least through here), you might want to take a look at the work I did on the redux library's "include" function. It lets you do absolute includes on both Android and iOS from any folder, to any folder. It may be a suitable workaround until the core code is fixed.

    Here is a link straight to the relevant function. It isn't reliant on any other functions in redux, so it should be easy to rip out. It operates off of what the platform osname is and the depth of the currentWindow's url.

    https://github.com/dawsontoth/Appcelerator-Titanium-Redux/blob/master/redux.js#L164"> https://github.com/dawsontoth/Appcelerator-Titanium-Redux/blob/mast...

  10. Jon Alter 2011-04-15

    Another customer interested in this

    Associated Helpdesk Ticket


  11. John Welch 2011-04-15

    Can more information related to this bug be released to the community/paid devs? ETA maybe?

  12. Don Thorp 2011-04-15

    Bill, We'll probably need to generate or find the iOS ticket that goes with this. Drillbit tests of correct behavior will speed the iOS fixes.

  13. Bill Dawson 2011-04-15

    (from [b1ea8d3e0c31c5078f52380552b078d9eb3b0d25]) New "includes" drillbit test suite to test Ti.include() [#2585] https://github.com/appcelerator/titanium_mobile/commit/b1ea8d3e0c31c5078f52380552b078d9eb3b0d25"> https://github.com/appcelerator/titanium_mobile/commit/b1ea8d3e0c31...

  14. Bill Dawson 2011-04-15

    Related commit: https://github.com/appcelerator/titanium_mobile/commit/dbac80a64d0dec1ce02d327f21226ad9aac6483d"> https://github.com/appcelerator/titanium_mobile/commit/dbac80a64d0d...

  15. Bill Dawson 2011-04-15

    QE: This is the Android ticket re pathing in Ti.include(). A set of drillbit tests to be sure that Ti.include() can handle relative and absolute pathing has been added to drillbit (see the "includes" test suite in drillbit.) Android passes those tests but at that moment iOS doesn't. iOS will be handled in ticket #3349, so for purposes of setting this to resolved you need only test the Android part in drillbit.

  16. Bill Dawson 2011-04-15

    Interested parties follow #3349 for the iOS part.

  17. Natalie Huynh 2011-04-15

    Tested with Titanium SDK version: 1.7.0 (03/15/11 11:42 1f6dbfe)
    Ran Drillbit on Emulator 2.1, ran includes test suite all pass
    relativeDown true 9 Success
    slashToRoot true 16 Success
    dotdotSlash true 23 Success
    dotSlash true 23 Success
    lotsOfDots true 37 Success

  18. Bill Dawson 2011-04-15

    (from [dbac80a64d0dec1ce02d327f21226ad9aac6483d]) Re-work absoluteUrl() to better handle relative pathing for includes and such. [#2585] https://github.com/appcelerator/titanium_mobile/commit/dbac80a64d0dec1ce02d327f21226ad9aac6483d"> https://github.com/appcelerator/titanium_mobile/commit/dbac80a64d0d...

  19. Don Thorp 2011-04-15

    Since a new iOS ticket has been created, converting this to Android only.

JSON Source