Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19757] Cannot access files in Resources directory with 5.2.x

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2015-10-29T21:41:08.000+0000
Affected Version/sRelease 5.1.0, Release 5.2.0
Fix Version/sRelease 5.1.0
ComponentsiOS, Tooling
Labelsfilesystem
ReporterSebastian Klaus
AssigneeFeon Sua Xin Miao
Created2015-10-21T06:57:52.000+0000
Updated2015-11-24T19:06:19.000+0000

Description

Operating System
  Name                        = Mac OS X
  Version                     = 10.11.1
  Architecture                = 64bit
  # CPUs                      = 8
  Memory                      = 17179869184
Node.js
  Node.js Version             = 0.10.38
  npm Version                 = 1.4.28
Titanium CLI
  CLI Version                 = 5.0.5
Titanium SDK
  SDK Version                 = 5.2.0.v20151014151229
  SDK Path                    = /Volumes/Data/Users/sebastian/Library/Application Support/Titanium/mobilesdk/osx/5.0.2.GA
  Target Platform             = iphone
var self = Ti.UI.createWindow({
    title: 'file test',
    backgroundColor: '#fff'
});

var navController = Ti.UI.iOS.createNavigationWindow({
    window: self
});

var testFile = Ti.Filesystem.getFile(Ti.Filesystem.getResourcesDirectory(), 'KS_nav_ui.png');
alert(testFile.getSize());

navController.open();
With SDK 5.0.2.GA the alert gives me 748, with 5.1.x and 5.2.x it alerts 0. There are several problems, not getting files out of the resources directory. Also getting directories with getFile for getDirectoryListing() does not work.

Comments

  1. Sebastian Klaus 2015-10-21

    *Update* Why I did not mentioned the bug before (I'm testing with 5.2.x since about 2 weeks): the bug does not appear running the app with tishadow
  2. Chee Kiat Ng 2015-10-21

    [~benutzername], can you try with another file? I noticed that this is a png file that came coupled with the app bundle. In 5.1.X and 5.2.X onward, we actually copy all bundled images into asset catalog, for app thinning purposes. So these files are no longer in the Resources Folder after build. But there shouldn't be a situation whereby you need to getSize of an image file that came bundled in the app. However, it will work for downloaded files during run-time.
  3. Sebastian Klaus 2015-10-21

    Yes, I can confirm that it works for downloaded files in the data or cache folder. It also happens for jpg files. My first situation: I deliver some background images within my app. I use the directory listing to show the background possibilities and not to take care of a config background image array if I add an image. Second situation: I create a pdf file in my app und have to access some image files in my resources directory. Is there a way to access the assets?
  4. Chee Kiat Ng 2015-10-21

    Ok I didn't expect these use cases. Will investigate.
  5. Sebastian Klaus 2015-10-21

    Can I disable app thinning in the tiapp.xml?
  6. Chee Kiat Ng 2015-10-21

    [~benutzername], there may be ways to workaround your situations using JS. The fastest way workaround i can think now is to change the extension of your files to be non-image type. then change it back during run-time. (Since we allocate the images into assets catalog only during build). The whole purpose of image asset catalog is so that iOS can allocate the right resolution image for the right device in order to save storage space. So it's not as simple if we wish to tackle your situations. As said, we will discuss further internally. There's currently no way to disable assets catalogs in the later versions.
  7. Sebastian Klaus 2015-10-21

    [~cng] Thanks. Will try that. So it's just renaming the .jpg to .image e.g.? And Appcelerator will not find them as images during the build?
  8. Chee Kiat Ng 2015-10-21

    [~benutzername], by the way, do you use any @2x, @3x files?
  9. Chee Kiat Ng 2015-10-21

    [~benutzername], yes that's correct.
  10. Sebastian Klaus 2015-10-21

    [~cng] I always using @2x and @3x files Could this be a problem while renaming to a non image type?
  11. Sebastian Klaus 2015-10-21

    It works so far. Will watch it.
  12. Ingo Muschenetz 2015-10-21

    [~cng] The existing use cases (no matter what they are) HAVE to continue to work for it to be named 5.1.0, which would suggest the flag sets asset catalogs OFF by default. Otherwise we need to publish it as 6.0.
  13. Feon Sua Xin Miao 2015-10-22

    master: https://github.com/appcelerator/titanium_mobile/pull/7330 5_1_X: https://github.com/appcelerator/titanium_mobile/pull/7331 To enable app thinning, include following property in tiapp.xml <property name="use-app-thinning" type="bool">true</property>
  14. Wilson Luu 2015-10-26

    Closing ticket as fixed. Verified that if I use the sample code above, then I am able to get the file from the Resources directory. Tested on: Appcelerator Studio, build: 4.4.0.201510231805 Appc CLI NPM: 4.2.1-6 Appc CLI Core: 5.1.0-38 Arrow: 1.3.13 SDK: 5.1.0.v20151023172822 Node: v4.2.1 OS: El Capitan (10.11.1) Xcode: 7.1 Devices: iphone 6s (9.1), iphone 6 plus (8.3)
  15. Ingo Muschenetz 2015-10-27

    I agree with [~hansknoechel]--this should be under iOS unless you have plans for a similar usage for Android. WRT to TIMOB-19489, that's fine. It's a new feature in 5.1.0. If you want to take advantage of it, you have to enable asset catalogs. We just have to make that EXCEPTIONALLY clear when describing the feature.
  16. Chris Barber 2015-10-27

    [~hansknoechel] Properties are only supported as a child of the tag. Platform specific properties are not supported, but could be if needed.
  17. Hans Knöchel 2015-10-27

    [~cbarber] I would just make it exactly as we do with <use-main-thread> and <use-autolayout>. Ok?
  18. Chris Barber 2015-10-27

    That's fine, but these one-off settings must each be explicitly added to the tiapp.xml parser library. Also, these settings will not be known to the Titanium app at runtime. Properties are embedded in the app, settings like min-ios-ver are not. Perhaps it's time to give the tiapp.xml parser some intelligence.
  19. Sebastian Klaus 2015-10-27

    Just to interfere here shortly. Will there be an own section in the docs for all these parameters like *use-app-thinning*, *run-on-main-thread* etc?
  20. Feon Sua Xin Miao 2015-10-27

    Master: https://github.com/appcelerator/titanium_mobile/pull/7353 5_1_X: https://github.com/appcelerator/titanium_mobile/pull/7354 To enable app thinning, include following property in tiapp.xml under ios tag <use-app-thinning>true</use-app-thinning>
  21. Chee Kiat Ng 2015-10-27

  22. Eric Wieber 2015-10-29

    Verified fixed, using: MacOS 10.11.2 (15C27e) Studio 4.4.0.201510280736 Ti SDK 5.1.0.v20151028190028 Appc NPM 4.2.1 Appc CLI 5.1.0-38 Ti CLI 5.0.5 Alloy 1.7.16 Arrow 1.3.13 Xcode 7.2 (7C46l) Node v0.12.7 Java 1.7.0_80 production Using the sample code provided, I am able to access the file in the resources directory. The use-app-thinning property is now usable under the ios tag
  23. Chris Barber 2015-11-20

    [~cng] Nope. app thinning is not enabled by default at any time and is only enabled manually. Perhaps you're thinking of the launch screen storyboard which will be disabled for existing apps, but enabled for new apps.
  24. Chris Barber 2015-11-21

    [~cng] Can you please update the wiki so that the information is correct? Thank you!
  25. Chris Barber 2015-11-24

    [~bimmel] It's technically "png" and "jpg". We don't support "jpeg". I don't like the second sentence. Here, just use this: {quote} When enabled, all .png and .jpg images in the Resources directory will be copied into an asset catalog image set and grouped by filename. High density images are defined with the @2x and @3x suffix. For example, foo.jpg, foo@2x.jpg, and foo@3x.jpg would all be grouped into the same image set. However foo@4x.jpg would be in its own image set because @4x is not supported and seen as just apart of the filename and not a suffix. For details, see Images and ImageView APIs. Additionally, images that are in the asset catalog are not accessible from the filesystem and thus you cannot reference the images by its path or URL with the Ti.Filesystem API or equivalent. There is currently no way to exclude specific images from being copied into the asset catalog. {quote}

JSON Source