appceleratortitanium-alloyappcelerator-alloy

CommonJS require function not found running iOS Adhoc/Enterprise


I have an Appcelerator Alloy 6.3.0 iOS app that runs fine on device when running in development.

I packaged the app using my enterprise certificate then build my .ipa and install (and trust) the app on the device.

The app runs fine but then throws an error when attempting to use the commonJS library (pure JS).

try{
    var netUtil = require('API');
    netUtil.getList($.labelModel.text, myCallBackFunction);
catch(e){
    alert('Error: ' + e);
}

The error shown is...

TypeError: undefined is not a function (evaluating 'a.getList(k.label-Model.text,g)' )

The exact same code runs fine on device without changes when running dev certificate with/without liveview.

What may be causing CommonJS require function not found only when running iOS .ipa Adhoc/Enterprise ?


Solution

  • I believe that API name is reserved in Apple's internal apis or could be used by Titanium itself. So you should rename your API.js file to something non-generic like custom_api.js or my_api.js & then try again.

    I have had this issue once when I named some lib file to animation.js or something like this (not remember exactly) & figured out that it's always better & safer to use underscore formatting while naming lib files or other js files because internal apis mostly don't use underscore name formatting.