ios - swift的module扩展提示方法找不到

【字号: 日期:2023-11-12浏览:57作者:雯心

问题描述

按照官网所描述的步骤

新建SelfModule.m/.h文件,并导入project-swift.h,对外定义暴露jumpNextPage(params : String)方法

#import 'SelfModule.h'#import 'Project-Swift.h'#import 'Project-Bridging-Header.h'@implementation SelfModule#pragma clang diagnostic push //关闭unknow selector的warrning#pragma clang diagnostic ignored '-Wundeclared-selector'@synthesize weexInstance; WX_EXPORT_METHOD(@selector(jumpNextPage))#pragma clang diagnostic pop@end

新建SelfModule.swift文件,扩展SelfModule方法

public extension SelfModule{public func jumpNextPage(params : NSString){let controller = UIViewCtroller()weexInstance.viewController.navigationController?.pushViewController(controller, animated:true) }}

在AppDelegate中注册Module,

WXSDKEngine.registerModule('self_module', with: NSClassFromString('SelfModule'))

结果提示

method:jumpNextPage for module:self_module doesn’t exist, maybe it has not been registered [;

在Android上是没有任何问题的,但是在iOS上报错,求解原因

问题解答

回答1:

你看一下导入桥接文件没有,在Project-Bridging-Header.h这个里面

相关文章: