【问题标题】:CommonJS require function not found running iOS Adhoc/Enterprise未找到运行 iOS Adhoc/Enterprise 的 CommonJS 所需功能
【发布时间】:2017-11-11 17:13:57
【问题描述】:

我有一个 Appcelerator Alloy 6.3.0 iOS 应用程序,在开发中运行时在设备上运行良好。

我使用我的企业证书打包应用程序,然后构建我的 .ipa 并在设备上安装(并信任)该应用程序。

应用程序运行良好,但在尝试使用 commonJS 库(纯 JS)时抛出错误。

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

显示的错误是...

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

在使用/不使用 liveview 运行开发证书时,完全相同的代码在设备上运行良好,无需更改。

只有在运行 iOS .ipa Adhoc/Enterprise 时才找到 CommonJS 要求功能的原因是什么?

【问题讨论】:

  • 您能否尝试将所需文件重命名为非通用名称,因为 API 名称可能会保留给某些内部 Apple API?将其重命名为 custom_titanium_file.js,然后重试。
  • OMG - 这实际上解决了问题!
  • 是的,有时解决方案很简单,就像看起来相反。将其发布为答案,您可以将其标记为已接受,让其他人知道它已解决。

标签: appcelerator titanium-alloy appcelerator-alloy


【解决方案1】:

我相信 API 名称保留在 Apple 的内部 API 中,或者可供 Titanium 本身使用。因此,您应该将 API.js 文件重命名为非通用名称,例如 custom_api.jsmy_api.js,然后重试。

当我将一些 lib 文件命名为 animation.js 或类似的东西(不记得确切)时,我曾经遇到过这个问题,并发现在命名时使用下划线格式总是更好更安全lib 文件或其他 js 文件,因为内部 api 大多不使用下划线名称格式。

【讨论】:

    猜你喜欢
    • 2020-04-24
    • 1970-01-01
    • 2018-10-31
    • 1970-01-01
    • 1970-01-01
    • 2014-05-21
    • 2021-08-19
    • 2012-09-02
    • 1970-01-01
    相关资源
    最近更新 更多