gpt4 book ai didi

ios - trigger.io native iOS 模块在检查器中工作,而不是应用程序

转载 作者:行者123 更新时间:2023-11-29 03:26:37 25 4
gpt4 key购买 nike

我正在为 trigger.io 构建一个 iOS 模块。我让它在 ios-inspector 应用程序中按需工作。

我已经尝试按照此处的文档构建模块: https://trigger.io/docs/current/api/native_modules/the_basics.html#ios_2

我得到一个生成的 inspector/ios-inspector/build/module.a 然后我将那个 module.a 复制到 module/ios/module.a

然后我进入触发器工具包并修改版本号并上传新模块。然后在工具包应用程序部分,我选择模块的新版本并构建应用程序。

在我的应用程序代码中我这样做

  for(var prop in forge.my_module){
console.log("prop==", prop, forge.my_module[prop]);
}

我得到的唯一属性是:

[   INFO] Console.log: prop==,showAlert,function (c, b, a) {forge.internal.call("my_module.showAlert",{text:c},b,a);}

这是来自原始 ios-inspector 项目的 showAlert 方法。但是,我不再有该方法的任何 Objective C 代码。

我觉得我在这里错过了一个明显的步骤。

最佳答案

添加 objective-c API 方法将允许您像这样调用它们:

forge.internal.call('my_module.my_method', {my_param: 2});

不会为您生成任何 JavaScript 方法,它们实际上是在 module/javascript/module.js 中明确定义的。制作模块时生成的默认 module.js 包含如下内容:

// Expose the native API to javascript
forge.my_module = {
showAlert: function (text, success, error) {
forge.internal.call('my_module.showAlert', {text: text}, success, error);
}
};

您应该能够在那里添加您的 API。参见 https://trigger.io/docs/current/api/native_modules/adding_javascript.html了解更多详情。

关于ios - trigger.io native iOS 模块在检查器中工作,而不是应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20390183/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com