Uploaded image for project: 'Alloy'
  1. Alloy
  2. ALOY-850

Alloy: Automatically remove constants for platforms not targeted on compile


    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Tooling
    • Environment:

      Alloy 1.2.2


      I'm all for using [platform=ios] and so, but I wonder if the Alloy compiler could take away the need to do that for the very simple and very common case where in TSS, but also in JS/XML you would use platform specific constants that don't exist if you don't build for that platform.

      Example code

      1. Create a new project: titanium create -p android,ios -n ns --id ti.ns -d .
      2. Initialize Alloy: cd ns && alloy new
      3. Replace the contents of index.tss with:

          ".container": {
              statusBarStyle: Titanium.UI.iPhone.statusBarStyle.LIGHT_CONTENT

      4. Build for Android: titanium build -p android -T device
      5. The app will crash with:

          10-17 15:39:40.420: E/TiExceptionHandler(12559): (main) [152,152] ----- Titanium Javascript Runtime Error -----
          10-17 15:39:40.425: E/TiExceptionHandler(12559): (main) [0,152] - In alloy/controllers/index.js:15,58
          10-17 15:39:40.425: E/TiExceptionHandler(12559): (main) [1,153] - Message: Uncaught TypeError: Cannot read property 'LIGHT_CONTENT' of undefined
          10-17 15:39:40.425: E/TiExceptionHandler(12559): (main) [0,153] - Source:         statusBarStyle: Titanium.UI.iPhone.statusBarStyle.LIGHT_CONTENT,
          10-17 15:39:40.450: W/ResourceType(12559): Failure getting entry for 0x010802c0 (t=7 e=704) in package 0 (error -75)
          10-17 15:39:40.455: E/V8Exception(12559): Exception occurred at alloy/controllers/index.js:15: Uncaught TypeError: Cannot read property 'LIGHT_CONTENT' of undefined

      Possible solutions

      The TSS/XML/JS parsers could check for references to these platform specific constants and then just replace them with null (or undefined?) when that specific platform is not targeted.




            • Assignee:
              tlukasavage Tony Lukasavage
              mpmiranda Mauro Parra-Miranda
            • Watchers:
              4 Start watching this issue


              • Created:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Integration