search

Home  >  Q&A  >  body text

ios - swift module extension prompt method not found

Follow the steps described on the official website

  1. 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
  1. 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)
    }
}
  1. 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

大家讲道理大家讲道理2725 days ago1570

reply all(1)I'll reply

  • 迷茫

    迷茫2017-07-03 11:45:07

    Have a look at the imported bridging file? It’s in Project-Bridging-Header.h

    reply
    0
  • Cancelreply