Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9297] iOS: External (native) module with commonjs file in it can only be built once

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-05-31T20:17:47.000+0000
Affected Version/sRelease 2.1.0
Fix Version/sRelease 2.1.0, Sprint 2012-11 Core
ComponentsiOS
Labelscore, qe-port
ReporterBill Dawson
AssigneeBill Dawson
Created2012-05-29T12:57:15.000+0000
Updated2012-08-28T04:43:55.000+0000

Description

If an iOS module project has a file named assets/[moduleid].js then that javascript file is compiled and actually becomes the module itself (in lieu of the native, Objective-C code). If you create a module project and add such a file, you will only be able to compile the module project one time.

Fail Case / Test Case

* Create an iOS module project (not going through those steps here.) For purposes of this example, let's say the module has the id "ti.testmod". * Create a JS file assets/[moduleid].js. In my example, you would create assets/ti.testmod.js. * Put some miscellaneous exports code in that Js file, such as:
exports.hello = function() { return "hello world"; };
* Build the module project. * Build the module project again. This second time, it will fail with a bunch of "redefinition of ..." errors. Example:

/Users/bill/tmp/mods/barker/Classes/TiBarkerModuleAssets.m:29:16: error: redefinition of 'data'
                static UInt8 data[] = {
                             ^
/Users/bill/tmp/mods/barker/Classes/TiBarkerModuleAssets.m:12:16: note: previous definition is here
                static UInt8 data[] = {
                             ^
/Users/bill/tmp/mods/barker/Classes/TiBarkerModuleAssets.m:37:17: error: redefinition of 'ranges'
        static NSRange ranges[] = {
                       ^
/Users/bill/tmp/mods/barker/Classes/TiBarkerModuleAssets.m:20:17: note: previous definition is here
        static NSRange ranges[] = {
* If you're testing my fix branch, you should _not_ get the failures, of course. The reason is that the template-replacement code (where we dump in the results of running titanium prep on the javascript) is slightly wrong and is stacking up the code each time prep is run, rather than replacing the existing code.

Comments

  1. Bill Dawson 2012-05-29

    PR Ready: https://github.com/appcelerator/titanium_mobile/pull/2287
  2. Blain Hamon 2012-05-31

    Pull merged
  3. Anshu Mittal 2012-08-28

    Verified on: SDK:2.2.0.v20120827143312 Studio:2.1.2.201208201549 Modules with commonjs file in it can be built any number of times successfully.

JSON Source