[TIMOB-5212] Files in the project root's Resources/iphone folder cannot be loaded by the iOS simulator
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Cannot Reproduce |
Resolution Date | 2016-08-22T16:54:34.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | iOS |
Labels | builder.py, density, images, resources, simulator |
Reporter | Rob Gabbard |
Assignee | Ingo Muschenetz |
Created | 2011-08-25T09:49:42.000+0000 |
Updated | 2017-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.
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
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.
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
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.
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
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
andResources/iphone
as well asResouces/images
andResources/iphone/images
and it worked as expected. I also tested referencing the image using both relative and absolute paths and it worked as expected.Closing ticket as the issue cannot be reproduced, with reference to the above comments.