problem
Executing a
titanium build
without the --target option throws an error that the 99% of developers will have no idea how to work with, seen here:
/usr/local/lib/node_modules/titanium/node_modules/longjohn/dist/longjohn.js:181
throw e;
^
TypeError: Cannot read property '0' of undefined
at BlackberryNDK.self.build (/Users/tlukasavage/Library/Application Support/Titanium/mobilesdk/osx/3.1.1.GA/blackberry/cli/common/blackberryndk.js:233:62)
at build.<anonymous> (/Users/tlukasavage/Library/Application Support/Titanium/mobilesdk/osx/3.1.1.GA/blackberry/cli/commands/_build.js:140:15)
at /usr/local/lib/node_modules/titanium/lib/cli.js:116:18
at /usr/local/lib/node_modules/titanium/node_modules/async/lib/async.js:190:13
at /usr/local/lib/node_modules/titanium/node_modules/async/lib/async.js:116:25
at /usr/local/lib/node_modules/titanium/node_modules/async/lib/async.js:187:17
at /usr/local/lib/node_modules/titanium/node_modules/async/lib/async.js:491:34
at /usr/local/lib/node_modules/titanium/lib/cli.js:112:8
at ChildProcess.<anonymous> (/Users/tlukasavage/Development/alloy/test/projects/Harness/plugins/ti.alloy/hooks/alloy.js:149:6)
---------------------------------------------
at /Users/tlukasavage/Development/alloy/test/projects/Harness/plugins/ti.alloy/hooks/alloy.js:142:11
at /usr/local/lib/node_modules/titanium/node_modules/node-appc/lib/async.js:14:6
at /usr/local/lib/node_modules/titanium/node_modules/async/lib/async.js:190:13
at /usr/local/lib/node_modules/titanium/node_modules/async/lib/async.js:94:25
at /usr/local/lib/node_modules/titanium/node_modules/async/lib/async.js:187:17
at /usr/local/lib/node_modules/titanium/node_modules/async/lib/async.js:459:34
at /Users/tlukasavage/Development/alloy/test/projects/Harness/plugins/ti.alloy/hooks/alloy.js:90:9
at exithandler (child_process.js:635:7)
It appears it happens because the --target option is not explicitly set.
test case
In any Titanium app, execute the following:
titanium build -p blackberry
and you will get the above error. Just as an additional note, you get the same error if you explicitly define the BB NDK path (-n) and the ip address of the simulator (-A), which should obviously indicate that the target would be "simulator".
expected
There's a few possible solutions, listed in my preferential order:
Make the default target "simulator" like with all other platforms
Do better bounds checking around the line mentioned in the exception. Specifically, the length of the builder.type2variantCpu\[this.builder.target\]
array needs to be validated before attempting to access index zero. If the array is empty, an informative error should be thrown, not the current stack trace.
Workaround
Explicitly specify the --target in your command:
titanium build -p blackberry -T simulator -A XXX.XXX.XXX.XXX
https://github.com/appcelerator/titanium_mobile_blackberry/pull/151
PR no longer valid
PR: https://github.com/appcelerator/titanium_mobile_blackberry/pull/205
Closing ticket as fixed.