Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19285] iOS: App throws error when building to device with commonjs modules

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionInvalid
Resolution Date2015-07-31T16:23:22.000+0000
Affected Version/sRelease 5.0.0
Fix Version/sn/a
ComponentsiOS, Tooling
Labelsqe-5.0.0, regression
ReporterEwan Harris
AssigneeChris Barber
Created2015-07-29T23:05:03.000+0000
Updated2015-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

FileDateSize
commonjs.example.test1.zip2015-07-30T05:17:53.000+00001435
Screen Shot 2015-07-31 at 9.45.01 AM.png2015-07-31T16:54:11.000+000030070

Comments

  1. Chee Kiat Ng 2015-07-30

    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
  2. Ewan Harris 2015-07-30

    [~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
  3. Chee Kiat Ng 2015-07-30

    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.
  4. Chee Kiat Ng 2015-07-30

    Additional info: using ti create, ti build to device, it's ok. So most likely this is related to appc_cli too.
  5. Chee Kiat Ng 2015-07-30

    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.
  6. Chris Barber 2015-07-31

    This works as expected. The example MUST go in a platform directory named "commonjs":
       mkdir -p modules/commonjs
       cd modules/commonjs
       unzip commonjs.example.test1.zip
       
  7. Ewan Harris 2015-07-31

    [~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
       Ewans-MacBook-Pro:testApp1234 eharris$ ls -l /Users/eharris/Documents/Appcelerator_Studio_Workspace/testApp1234/build/iphone/build/Debug-iphoneos/testApp1234.app/
       total 38760
       -rw-r--r--  1 eharris  staff   635075 Jul 31 09:42 Default-568h@2x.png
       -rw-r--r--  1 eharris  staff   610220 Jul 31 09:42 Default-667h@2x.png
       -rw-r--r--  1 eharris  staff  2004257 Jul 31 09:42 Default-Landscape-736h@3x.png
       -rw-r--r--  1 eharris  staff   622531 Jul 31 09:42 Default-Landscape.png
       -rw-r--r--  1 eharris  staff  1784621 Jul 31 09:42 Default-Landscape@2x.png
       -rw-r--r--  1 eharris  staff  1240741 Jul 31 09:42 Default-Portrait-736h@3x.png
       -rw-r--r--  1 eharris  staff   669227 Jul 31 09:42 Default-Portrait.png
       -rw-r--r--  1 eharris  staff  1826311 Jul 31 09:42 Default-Portrait@2x.png
       -rw-r--r--  1 eharris  staff   127342 Jul 31 09:42 Default.png
       -rw-r--r--  1 eharris  staff   413614 Jul 31 09:42 Default@2x.png
       drwxr-xr-x  2 eharris  staff       68 Jul 31 09:43 Frameworks
       -rw-r--r--  1 eharris  staff     1829 Jul 31 09:42 Info.plist
       -rw-r--r--  1 eharris  staff      808 Jul 31 09:42 KS_nav_ui.png
       -rw-r--r--  1 eharris  staff      811 Jul 31 09:42 KS_nav_views.png
       -rw-r--r--  1 eharris  staff        8 Jul 31 09:42 PkgInfo
       drwxr-xr-x  3 eharris  staff      102 Jul 31 09:43 _CodeSignature
       -rw-r--r--  1 eharris  staff     6836 Jul 31 09:42 appicon.png
       -rw-r--r--  1 eharris  staff    12393 Jul 31 09:43 embedded.mobileprovision
       drwxr-xr-x  3 eharris  staff      102 Jul 31 09:42 modules
       -rwxr-xr-x  1 eharris  staff  9848608 Jul 31 09:43 testApp1234
       lrwxr-xr-x  1 eharris  staff       95 Jul 31 09:42 ti.cloud.js -> /Users/eharris/Library/Application Support/Titanium/modules/commonjs/ti.cloud/3.2.9/ti.cloud.js
       
  8. Chee Kiat Ng 2015-08-03

    [~cbarber], aside from using the example, if you use
    appc run -p ios -T device
    on a brand new *appc* project, it will copy a commonjs module, specifically ti.cloud, by default. And this is causing the error.
  9. Chris Barber 2015-08-03

    [~cng] Merged a ton of fixes. Try again. :)
  10. Wilson Luu 2015-09-01

    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)

JSON Source