[TIMOB-19285] iOS: App throws error when building to device with commonjs modules
GitHub Issue | n/a |
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2015-07-31T16:23:22.000+0000 |
Affected Version/s | Release 5.0.0 |
Fix Version/s | n/a |
Components | iOS, Tooling |
Labels | qe-5.0.0, regression |
Reporter | Ewan Harris |
Assignee | Chris Barber |
Created | 2015-07-29T23:05:03.000+0000 |
Updated | 2015-09-01T21:49:41.000+0000 |
Description
Description
When building to a device and including commonjs modules the app will crash with \[ERROR] Script Error Couldn't find module: ti.cloud for architecture: arm64
. Requiring modules such as ti.map work fine.
*When building to simulator the app works fine*
Steps to reproduce
1. Create a project using appc new
and ensure services are enabled
2.Build to device
Actual result
The app will crash with \[ERROR] Script Error Couldn't find module: ti.cloud for architecture: arm64
Expected result
The app should not crash
Attachments
Additional info: 4.1.0.GA works. Only 4.2.0 fails. Something related to handling commonjs modules or specifically ti.cloud module must have changed somewhere in titanium_mobile
[~cng] I believe it is all commonjs modules, I made a basic module which I have attached and that also throws an error. Also I believe that it is symlinking the commonjs file when it builds. If I open up the .app for the project I built then the commonjs file is shown as an alias which links to the file in my Titanium module location, which is probably the root cause of this
Thanks [~eharris], think I have pinpointed the problem. It's with the generated ApplicationMods.h. It used to contain all the definitions of modules, now 4.2.0 it's empty. Also realized ApplicationDefaults.m is different in both versions as well.
Additional info: using ti create, ti build to device, it's ok. So most likely this is related to appc_cli too.
PR here: https://github.com/appcelerator/titanium_mobile/pull/6997 Tested that appc run works for both simulator and device. And so far it looks like it hasn't changed any original ti build behavior. Basically i made sure that the ApplicationMods.m and ApplicationDefaults.m file contents are the same as what appc used to produce in 4.1.0.GA, and also added a rule not to symlink commonjs modules, and to only copy if file didn't exist. [~cbarber], please review to see if this is ok. Only thing I'm not sure how to tackle is, if the commonjs module is updated to a newer version in the installed SDK, how does builder.js register the change and copy the file accordingly.
This works as expected. The example MUST go in a platform directory named "commonjs":
[~cbarber] the modules are inside the modules/commonjs folder in the Titanium SDK, see attached screenshot, I can still reproduce this using the latest SDK(4.2.0.v20150730093157). Also below is the output showing that the ti.cloud.js inside my app is a symlink to the one inside my modules folder
[~cbarber], aside from using the example, if you use
on a brand new *appc* project, it will copy a commonjs module, specifically ti.cloud, by default. And this is causing the error.
[~cng] Merged a ton of fixes. Try again. :)
Closing ticket as fixed. Verified that if build a mobile app and install to device with commonjs modules, then I do not get any runtime errors. Tested on: Appc CLI NPM: 4.2.0-1 Appc CLI Core: 5.0.0-33 Arrow: 1.2.52 SDK: 5.0.0.v20150901105514 Node: v0.10.38 OS: Yosemite (10.10.5) Xcode: 7 beta 6 Devices: iphone 6 (8.4.1)