Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5815] iOS: Native JS Modules not taken in consideration when running the optimalizer for a release build

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2012-01-23T16:39:27.000+0000
Affected Version/sRelease 1.7.2, Release 1.8.0
Fix Version/sSprint 2012-01, Release 2.0.0, Release 1.8.1
ComponentsiOS
Labelsmodule_module, qe-testadded
ReporterMartijn Bogaard
AssigneeStephen Tramer
Created2011-10-05T07:43:15.000+0000
Updated2012-02-03T14:59:46.000+0000

Description

When a release build (run on iOS device) is done, a set of defines are generated to strip the binairy down to the API parts that are used in the App. When certain API's are only used in a JS module and not in the App, the application will crash since they are missing. Define (pseudo) calls to the API's in the app, and the module works. In the simulator, all API's are included so everything works as expected.

Attachments

FileDateSize
nl.icept.pull2refresh-iphone-1.0.zip2011-10-20T12:55:22.000+000060821
TC-280 Testcase.zip2011-10-20T12:55:22.000+0000133055
ti.5815.js2012-01-04T16:00:10.000+0000138
timob-5815-test.tar.gz2012-01-04T16:00:10.000+00001710398

Comments

  1. Matthew Apperson 2011-10-20

    Martijn, Are you talking about a native JS module? or a commonJS module? Best regards, Matt
  2. Martijn Bogaard 2011-10-20

    Hi Matt, I uploaded a Testcase + a broken module for you. To run it, you need to install version 1.0 of the pull2refresh module. - Run the project in the simulator. It works normally. - Run it on a iOS device. It crash (2 crashes actually, the show of the errorview crash also, but thats probably since the initialization isnt fully done yet) since Ti.UI.iPhone is missing. The only differences between the 2 cases is defines.h. When you build for the device, he checks wich parts of the API must be included. IMO he should also load the JS of the module and include the used parts. Since the JS is embedded as a hex encoded string in the static archive, it shouldn't be hard to extract it. Or add a new file which contains the API parts the module is using. For now i have a workaround to manually define the required parts in the module xcconfig, but this issue is not documentated and you can easy miss a part of the API you need or the define could be changed in a future release. Martijn
  3. Stephen Tramer 2012-01-04

    TESTING

    ----

    Remove any existing SDK install for the version you're testing (1.9.0) - this contains the stale json.py file that was deleted as part of the commit.

    Install the SDK you are testing against

    Import the timob-5815-test project into TiStudio

    Create the ti.5815 module

    #* Create a new module (either via commandline or TiStudio) with the identifier ti.5815 #* Place the ti.5815.js file in <module_root>/assets #* Build the module via build.py #* Copy the module zipfile to the project directory for timob-5815-test and install

    Build for simulator

    #* Ensure that the <project_root>/build/iphone/Classes/defines.h file is the default (all symbols) #* Ensure that the app runs on simulator. Output should be:
       [WARN] awww yeah com.appcelerator.5815test
       [INFO] SUPER!
       

    Build for device

    #* Ensure that the <project_root>/build/iphone/Classes/defines.h file contains only the necessary symbol info (note that there may be more than this in the file, but these are required to validate the bug):
       #define USE_TI_API
       #define USE_TI_FILESYSTEM
       #define USE_TI_FILESYSTEMGETFILE
       #define USE_TI_FILESYSTEMRESOURCESDIRECTORY
       #define USE_TI_APIINFO
       #define USE_TI_APIWARN
       #define USE_TI_APP
       #define USE_TI_APPID
       
    #* Ensure that the application runs on device with the proper output

    Export the project via the transport.py script:

    bq. <mobilesdk_install>/iphone/transport.py <project_root> #* Open the xcode project for the export, <project_root>/build/iphone/timob-5815-test.xcodeproj #* Confirm that the xcode project builds and runs on both simulator and device with the expected output #* Confirm that after a build (either for simulator or device), the <project_root>/build/iphone/Classes/defines.h includes the appropriate symbol info (as above)
  4. Stephen Tramer 2012-01-04

    NOTE: When resolving this ticket, TIMOB-6458 should be resolved as a DUPLICATE and link back to this ticket in the comment posted while resolving.
  5. Stephen Tramer 2012-01-05

    NOTE: When resolving this ticket, TIMOB-7001 should be resolved as FIXED provided that step 4. above passes.
  6. Natalie Huynh 2012-01-13

    Tested with 1.9.0.v20120112153134 on simulator and ipod 4.3.3 device

JSON Source