Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5212] Files in the project root's Resources/iphone folder cannot be loaded by the iOS simulator

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionCannot Reproduce
Resolution Date2016-08-22T16:54:34.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsbuilder.py, density, images, resources, simulator
ReporterRob Gabbard
AssigneeIngo Muschenetz
Created2011-08-25T09:49:42.000+0000
Updated2017-03-30T22:06:32.000+0000

Description

Platform-specific images are placed in the following project directories:
Resources/android/images/high/ic_tab_home.png
Resources/android/images/medium/ic_tab_home.png
Resources/android/images/low/ic_tab_home.png
Resources/iphone/images/ic_tab_home.png
Resources/iphone/images/ic_tab_home@2x.png
These are used to set icons to tabs, in the following working code:
var tabGroup = Ti.UI.createTabGroup();

var win1 = Ti.UI.createWindow({
  title:'Tab 1',
  backgroundColor:'#fff'
});
var tab1 = Ti.UI.createTab({
  icon:"/images/ic_tab_home.png",
  title:'Tab 1',
  top:0,
  left:0,
  right:0,
  bottom:0,
  width:'100%',
  height:'100%',
  window:win1
});

tabGroup.addTab(tab1);

tabGroup.open();
When the iPhone version of builder.py launches the iOS simulator, it does so in a manner causing the app resources to be loaded from the project root folder instead of the app's resource folder in the iphone build folder. This is causing significant issues when loading device specific resources residing in the Resources/iphone folder. For instance, attempting to load the file Resources/iphone/images/KS_nav_ui.png using the path images/KS_nav_ui.png or /images/KS_nav_ui.png no longer works. If you put them in a top level /images folder, they end up overriding their Android density-specific counterparts when the Android version of builder.py runs. It appears builder.py is correctly copying files from the Resources/iphone folder to the app's resource folder residing at build/iphone/build/Debug-iphonesimulator/_appname_.app. For instance, the file Resources/iphone/images/KS_nav_ui.png is correctly copied to build/iphone/build/Debug-iphonesimulator/_appname_.app/images/KS_nav_ui.png. But since the iOS simulator is loading the resources directly from the project root, the files in the app resource folder are ignored. At present... there doesn't appear to be a graceful workaround to this issue without creating a device specific path at runtime and ingesting it into each path reference for device-specific resources, a significant change to any existing codebase of medium or larger size.

Comments

  1. Paul Dowsett 2011-08-31

    Rob Are you aware of the [Changes to filesystem on iOS](http://developer.appcelerator.com/blog/2011/05/changes-to-filesystem-on-ios.html)? If this does not solve it, we will need some code that demonstrates the issue. Would you update the ticket and let me know? Thanks
  2. Rob Gabbard 2011-09-01

    Here's an example... I have an image file ic_tab_home.png for which I have device specific versions of for android and iphone. Based on your SDK docs, the way to accomplish this is to lay it out in the project directory like so.... Resources/android/images/high/ic_tab_home.png Resources/android/images/medium/ic_tab_home.png Resources/android/images/low/ic_tab_home.png Resources/iphone/images/ic_tab_home.png Resources/iphone/images/ic_tab_home@2x.png Following this convention, any reference to "/images/ic_tab_home.png" should load the file specific to the device you are running on, such as in the following code... var homeTab = Titanium.UI.createTab({ icon:"/images/ic_tab_home.png", title:'Home', top:0, left:0, right:0, bottom:0, width:'100%', height:'100%', window:homeWin }); However, as I described in the bug, when the builder launches the emulator, it does so in a manner that causes it to ignore the "Resources/iphone" folder when resolving paths. This is really an issue of how builder.py copies over device-specific resources and the way it launches the emulator. In this instance, I'm not making any Titanium.File calls, I'm just following the SDK guidelines for loading device specific resources. I've also spent a considerable amount of time going through builder.py to isolate the issue as I described in the original bug description.
  3. Paul Dowsett 2011-09-02

    Rob I appreciate your effort, but the absolutely crucial thing we need is a piece of code that reproduces the problem. Please would you follow [Creating Good Use-cases](http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-CreatingGoodUsecases) and [Summary: Jira Ticket Checklist](http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-Summary%3AJiraTicketChecklist). Once all the information is provided, I can accept the ticket. Thank you in advance
  4. Rob Gabbard 2011-09-02

    I did.... var homeTab = Titanium.UI.createTab({ icon:"/images/ic_tab_home.png", title:'Home', top:0, left:0, right:0, bottom:0, width:'100%', height:'100%', window:homeWin }); Given the project layout as I described in great detail above, the image referenced in this code will not load in the iOS simulator as it should as described in the Titanium Mobile documentation. The alternate path "images/ic_tab_home.png" will not work either.
  5. Paul Dowsett 2011-09-06

    Rob I am happy to move this to the correct project, but in future please be aware that adhering to the [Submitting Bug Reports](http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-SubmittingBugReports) guide is a prerequisite to raising tickets. Thank you
  6. Chris Barber 2016-08-22

    Unable to reproduce with Titanium SDK master (currently 6.1.0). I'm not sure exactly when it was fixed. I tested with images in Resources and Resources/iphone as well as Resouces/images and Resources/iphone/images and it worked as expected. I also tested referencing the image using both relative and absolute paths and it worked as expected.
  7. Lee Morris 2017-03-30

    Closing ticket as the issue cannot be reproduced, with reference to the above comments.

JSON Source