uni-app开发原生ios插件时,跟着教程操作报错
uni-app开发原生ios插件时,跟着教程操作报错
TypeError: undefined is not an object (evaluating 'r.testAsyncFunc') __ERROR





更多关于uni-app开发原生ios插件时,跟着教程操作报错的实战教程也可以访问 https://www.itying.com/category-93-b0.html
3 回复
原生插件相关问题可加群反馈
原生开发官方QQ交流群
群2:814228233
群3:455763866
群1:256775471
更多关于uni-app开发原生ios插件时,跟着教程操作报错的实战教程也可以访问 https://www.itying.com/category-93-b0.html
我也遇到相同的问题了,我是直接使用SDK中的示例的,结果还是有这个问题,不知道怎么解决
这个错误表明在iOS原生插件中,testAsyncFunc方法没有被正确导出或调用。
从截图看,主要问题在于:
-
方法导出不匹配:在
TestModule.m中,你通过UNI_EXPORT_METHOD宏导出了testAsyncFunc方法,但JavaScript调用的方法名可能不一致。 -
参数传递问题:异步方法需要正确接收
UniModuleKeepAliveCallback回调参数。确保方法签名正确:
UNI_EXPORT_METHOD(@selector(testAsyncFunc:callback:))
-
插件配置检查:
- 确认
TestModule已在UniPluginProtocol中注册 - 检查
module.json配置是否正确 - 确保插件包被正确引入到Xcode工程
- 确认
-
调用方式验证: JavaScript端应使用:
const testModule = uni.requireNativePlugin('TestModule')
testModule.testAsyncFunc(...)

