iOS 无法识别的选择器发送到实例错误

iOS unrecognized selector sent to instance error

我在 LoginViewController 中添加了一个按钮。 这是 LoginViewComtroller

中的代码
loginButton?.addTarget(self, action: #selector(LoginViewController.wechatLogin), for: .touchDown)

func wechatLogin()  {
    sendWXAuthRequest()  
}

func sendWXAuthRequest() {
    print("hello")
    let req: SendAuthReq = SendAuthReq()
    req.scope = "snsapi_userinfo,snsapi_base"
    WXApi.send(req)
}

func onResp(_ resp: BaseResp!) {
    print(resp)
}

这是 AppDelegate.swift

中的代码
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        //register
        buildKeyWindow()
        let right =  WXApi.registerApp("My_Appid")
        print(right)
        return true
    }


    func application(_ application: UIApplication, handleOpen url: URL) -> Bool {
        return WXApi.handleOpen(url, delegate: self)
    }


    func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        return WXApi.handleOpen(url, delegate: self)
    }

我第一次运行申请的时候,进微信就报错。 然后我第二个 运行 它,有一些错误说 "unrecognized selector sent to instance"

尝试在建筑设置的 Other Linker Flags 中将 -all_load 更改为 -force_load