[TIMOB-9297] iOS: External (native) module with commonjs file in it can only be built once
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-05-31T20:17:47.000+0000 |
Affected Version/s | Release 2.1.0 |
Fix Version/s | Release 2.1.0, Sprint 2012-11 Core |
Components | iOS |
Labels | core, qe-port |
Reporter | Bill Dawson |
Assignee | Bill Dawson |
Created | 2012-05-29T12:57:15.000+0000 |
Updated | 2012-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 fileassets/[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.
PR Ready: https://github.com/appcelerator/titanium_mobile/pull/2287
Pull merged
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.