Description:
Script Error Couldn't find module: ti.cloud for architecture: x86_64
When creating a project from the Appcelerator CLI and building to simulator, the app throws a runtime error as shown.
NOTE: This only occurs when creating a project from the Appc CLI. Creating a project using Studio with or without services runs as expected.
Steps to reproduce:
1) Using Appc CLI, create a new Titanium project
2) Use "appc run" command to launch, choose iOS simulator
Result:
Runtime error on device
Expected Result:
Application runs as expected
Note:
A diff on the projects prior to run (created in studio versus appc CLI) shows only the following additional lines included in the alloy.js in the project created by Appc CLI:
// added during app creation. this will automatically login to
// ACS for your application and then fire an event (see below)
// when connected or errored. if you do not use ACS in your
// application as a client, you should remove this block
(function(){
var ACS = require('ti.cloud'),
env = Ti.App.deployType.toLowerCase() === 'production' ? 'production' : 'development',
username = Ti.App.Properties.getString('acs-username-'+env),
password = Ti.App.Properties.getString('acs-password-'+env);
// if not configured, just return
if (!env || !username || !password) { return; }
/**
* Appcelerator Cloud (ACS) Admin User Login Logic
*
* fires login.success with the user as argument on success
* fires login.failed with the result as argument on error
*/
ACS.Users.login({
login:username,
password:password,
}, function(result){
if (env==='development') {
Ti.API.info('ACS Login Results for environment '+env+'
:');
Ti.API.info(result);
}
if (result && result.success && result.users && result.users.length){
Ti.App.fireEvent('login.success',result.users[0],env);
} else {
Ti.App.fireEvent('login.failed',result,env);
}
});
})();
on a subsequent launch, it worked. seems to be related to a new project.
should this be moved into TIMOB? seems like a blocker for the release to me.
This issue is reproducible by building an iOS app using any globally installed CommonJS module and doing a device or dist build:
ti build -p ios -T device --build-only
The map of JS files uses relative paths for the key. The only time the key is absolute is when you are using a global CommonJS module. The fix is pretty simple. If it's an absolute path, just do a
path.basename()
on the original file path. Note: This is not an Appc CLI specific issue. This is not an Alloy issue.master: https://github.com/appcelerator/titanium_mobile/pull/7108 5_0_X: https://github.com/appcelerator/titanium_mobile/pull/7109
Closing ticket as fixed. Verified that after I create a mobile project and launch te mobile app with latest mobile SDK, then I do not get the
Couldn't find module
error. 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 simulator (9.0)