Follow the steps described on the official website
Create a new SelfModule.m/.h file, import project-swift.h, and define and expose the jumpNextPage(params: String) method to the outside world
#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
Create a new SelfModule.swift file and extend the SelfModule method
public extension SelfModule{
public func jumpNextPage(params : NSString){
let controller = UIViewCtroller()
weexInstance.viewController.navigationController?.pushViewController(controller, animated:true)
}
}
Register Module in AppDelegate,
WXSDKEngine.registerModule("self_module", with: NSClassFromString("SelfModule"))
Result prompt
method:jumpNextPage for module:self_module doesn't exist, maybe it has not been registered [;
There is no problem on Android, but an error is reported on iOS, please find out the reason
迷茫2017-07-03 11:45:07
Have a look at the imported bridging file? It’s in Project-Bridging-Header.h