Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18998] iOS9: App thinning: Create XCAssets (imagesets) w/ the cli and access resources within those catalogs at runtime

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2015-10-02T02:19:32.000+0000
Affected Version/sn/a
Fix Version/sRelease 5.1.0
ComponentsCLI, iOS
Labelsappthinning, ios9
ReporterStephen Feather
AssigneePraveen Innamuri
Created2015-06-11T15:13:29.000+0000
Updated2019-06-11T16:17:13.000+0000

Description

The first stage of app thinning support is to correctly sort out graphic assets by their associated targets and scale factor (1x,2x,3x | iphone, ipad). This is already supported at the file level to some extent with the proxies loading files with the appropriate file names flags on a particular device. This is a two part improvement and as more information is gained from apple, split into appropriate tickets. Apple will be documenting the XCAsset Source Artifact Format (basically a folder with JSON markup - Content.json) that will allow the cli to gather in project resources and create the needed imageset. The proxies will need to be able to access the assets located within the asset catalogs at runtime. *Reference*: https://developer.apple.com/library/prerelease/ios/documentation/IDEs/Conceptual/AppDistributionGuide/AppThinning/AppThinning.html *Note*: Filenames with suffix 2x, 3x etc will still work in runtime. However, Apple will not slice the app into variants according to this naming convention. These files *must be inside asset catalogs* in order for app thinning to work.

Attached screenshot of how to get to use App Thinning.

These are the steps to reproduce on Xcode 7 Beta2: 1. Archive your app in Xcode 7 Beta2. This archive will still be full sized. 2. Select archive and choose to export. 3. Choose last option to export ipa file for development use. 4. This screen will appear and you can choose specific device. 5. After export, show package contents of ipa and you can see a Assets.car file that contains the images. As compared to not using App thinning, you won't see the car file but instead your image files.

Some More Reference:

_AssetCatalog Folder looks like this_ {quote} Media.xcassets -- fullscreen.imageset ---- fullscreen.png ---- fullscreen@2x.png ---- fullscreen@2x~ipad.png ---- etc. ---- Contents.json -- titleImage.imageset ---- titleImage.png ---- titleImage@2x.png ---- titleImage@3x.png ---- etc ---- Contents.json -- Contents.json {quote} _Contents.json file looks like this_
{
  "images" : [
    {
      "idiom" : "universal",
      "filename" : "fullscreen.png",
      "scale" : "1x"
    },
    {
      "idiom" : "universal",
      "filename" : "fullscreen@2x.png",
      "scale" : "2x"
    },
    {
      "idiom" : "universal",
      "filename" : "fullscreen@3x.png",
      "scale" : "3x"
    },
    {
      "idiom" : "iphone",
      "filename" : "fullscreen~iphone.png",
      "scale" : "1x"
    },
    {
      "idiom" : "iphone",
      "filename" : "fullscreen@2x~iphone.png",
      "scale" : "2x"
    },
    {
      "idiom" : "iphone",
      "scale" : "3x"
    },
    {
      "idiom" : "ipad",
      "filename" : "fullscreen~ipad.png",
      "scale" : "1x"
    },
    {
      "idiom" : "ipad",
      "filename" : "fullscreen@2x~ipad.png",
      "scale" : "2x"
    }
  ],
  "info" : {
    "version" : 1,
    "author" : "xcode"
  }
}

Attachments

FileDateSize
Screen Shot 2015-07-09 at 1.03.55 pm.png2015-07-09T05:22:15.000+0000120779

Comments

  1. Stephen Feather 2015-06-11

    Will add apple doc link as soon as posted.
  2. Chee Kiat Ng 2015-07-09

    *Titanium Reference:* http://www.appcelerator.com/blog/2015/04/how-to-use-density-specific-images/ We will need to consider the current method titanium developers are used to, and based on that, how best to integrate app thinning.
  3. Travis Crist 2015-07-14

    Will the implementation of this force apps to enable bitcode?
  4. Chee Kiat Ng 2015-07-14

    As far as I can tell, although bitcode is part of app thinning, it has nothing to do with xcassets. Currently bit code is enabled YES in build settings by default in every Xcode project in Xcode 7 Beta 3.
  5. Travis Crist 2015-07-14

    Thanks Chee for the info. Is it possible to request support to disable bitcode in the build settings? I ask because we have many 3rd party frameworks and if they all have to support bitcode then we will not be in good shape to build with iOS 9. I am concerned that Xcode 7 defaults it to Yes and that there needs to be an ability to set it to No for those who are not able to fully use it yet due to special circumstances. Would that be possible? Or do I need to file a new ticket for that request? Thanks, Travis
  6. Chee Kiat Ng 2015-07-14

    We are actually in the midst of considering that, thank you for your input. It will be great if you could file a new ticket for this.
  7. Chee Kiat Ng 2015-07-24

    Latest updated [docs](https://developer.apple.com/library/prerelease/ios/documentation/Xcode/Reference/xcode_ref-Asset_Catalog_Format/FolderStructure.html#//apple_ref/doc/uid/TP40015170-CH18-DontLinkElementID_2) from Apple. Note: This clearly describes that even if you group the images, all assets filenames in the asset catalog MUST be unique.
  8. Chee Kiat Ng 2015-10-02

    All subtasks are complete. Resolving this issue.

    Steps to Test

    1. Using [~fokkezb] app in http://www.appcelerator.com/blog/2015/04/how-to-use-density-specific-images/ 2. After build, verify all images are in the asset catalog in the Xcode project in /build/iphone Also test if packaged app (for specific device) is app thinned.
  9. Eric Wieber 2015-10-30

    Verified implemented, using: MacOS 10.11.2 (15C27e) Studio 4.4.0.201510290507 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 Images are put into asset catalog in the Xcode project. App thinning successfully reduces app size and images available in exported archive

JSON Source