Hi I have tried the workaround suggested by the appcelerator team (for dealing with the deprecation of ti.include in version 6.0.0)
function include(file) {
return eval(Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, file).read().text);
}
And I get an error, probably the system can't read the file. the error is:
[ERROR] : TiBlob: java.io.FileNotFoundException:
Resources/underscore-min.js
I have managed to list the directory files through .getDirectoryListing() and couldn't find the file, actually I couldn't find any .js file there.
Any suggestions?
Short answer: Don't try to use the workaround but migrate your apps to the correct require
functionality. The Ti.include()
method has been deprecated since 3.3.0 (!) and has been removed in 6.0.0 (3 major versions later). All current and future apps use this behavior for scalable high-performance apps and so should you.
For your use-case, this is how you would use your library nowadays:
var _ = require('underscore-min')
It expects your file to be placed in <project-root>/Resources/underscore-min.js
(Classic projects) or <project-root>/app/lib/underscore-min.js
(Alloy projects).
Read more about require
and how to use it here and here.
Code strong!