为商店建造时删除 Ti.API.info()?
Remove Ti.API.info() when building for stores?
当我为 App Store/Play Store 打包应用程序时,我是否应该删除对 Ti.API.info() 的任何调用,或者它们会被忽略甚至不被编译?
不,他们还在这里,好人 Fokke 创建了一个很好的模块,ti-stealth 可以为您完成这项工作。
在生产环境中不记录消息的快速而肮脏的解决方案:
将 Ti.API.log 包装在 alloy.js 中的函数中:
function log (msg) {
if (Alloy.CFG.debugging) {
Ti.API.log('>>> ' + msg);
}
}
log("My logged message");
在 config.son 中包含 debugging
键:
{
"global": {},
"env:development": {
"debugging":true
},
"env:test": {
"debugging":true
},
"env:production": {
"debugging":false
}
}
快速而肮脏但有效:
在alloy.js
function consLog(e)
{
if (!ENV_PRODUCTION)
console.log(JSON.stringify(e));
}
并使用它:
consLog("Hello World");
当我为 App Store/Play Store 打包应用程序时,我是否应该删除对 Ti.API.info() 的任何调用,或者它们会被忽略甚至不被编译?
不,他们还在这里,好人 Fokke 创建了一个很好的模块,ti-stealth 可以为您完成这项工作。
在生产环境中不记录消息的快速而肮脏的解决方案:
将 Ti.API.log 包装在 alloy.js 中的函数中:
function log (msg) {
if (Alloy.CFG.debugging) {
Ti.API.log('>>> ' + msg);
}
}
log("My logged message");
在 config.son 中包含 debugging
键:
{
"global": {},
"env:development": {
"debugging":true
},
"env:test": {
"debugging":true
},
"env:production": {
"debugging":false
}
}
快速而肮脏但有效: 在alloy.js
function consLog(e)
{
if (!ENV_PRODUCTION)
console.log(JSON.stringify(e));
}
并使用它:
consLog("Hello World");