Whirlwind
Whirlwind

Reputation: 13675

Application crashing without information about crash when transitioning to another view controller

I have two view controllers, LoginViewController and TermsAndPrivacyViewController.

On first view controller, there is a button that has IBAction, which opens TermsAndPrivacyViewController. On TermsAndPrivacyViewController I have web view, that loads url I am passing from LoginViewController. So, this is the code(Login view controller):

 @IBAction func tosAction(_ sender: Any) {

        if let vc = UIStoryboard(name: "Login", bundle: nil).instantiateViewController(withIdentifier: kTOSViewControllerIdentifier) as? TermsAndPrivacyViewController{

            vc.url =  URL(string: kTOSUrl)
            self.navigationController?.pushViewController(vc, animated: true)

        }
    }

On TermsAndPrivacyViewController, I have this:

override func viewDidLoad() {
        super.viewDidLoad()

        webView.navigationDelegate = self
        if let `url` = url {
            webView.load(URLRequest(url: url))
            webView.allowsBackForwardNavigationGestures = true
        }
    }

So, when I hit a button, app crashes SIGABRT message, and nothing else. Also, I don't get any crash report on Firebase Crashlytics (I have detached an app from a debugger first, and produced a crash).

Now, the strange part :/ ... If I put a breakpoint on a first line of tosAction() method, and go step by step (or just let it continue), everything works normally. No crash???

Am I missing something obvious here? What is the reason of crashing? Also, I tried to put Exception Breakpoint but nothing changes. I only get this:

enter image description here

enter image description here

and a console:

console image

so, kinda no information about crash at all.

EDIT

Ok, now the even more strange part :) I just tried app on different phones.

App crashes on iPhone 6s+, iOS 12.1(16B5059d), but it works normally on iPhone 6, iOS 12.0 (16A366)

Upvotes: 1

Views: 397

Answers (3)

Jan Erik Schlorf
Jan Erik Schlorf

Reputation: 2311

To get further information on this type of crashes, open the Breakpoints menu (or press CMD+8), click the plus icon in the bottom left corner and press Exception Breakpoint.... Right click, then edit. Add an action of the type Debugger Command and enter the following:

enter image description here

Reproduce the crash again, this time the console will output a more useful error message.

Upvotes: 0

Badr Filali
Badr Filali

Reputation: 300

Maybe you can use segue methods inside your LoginViewController.

 @IBAction func tosAction(_ sender: Any) {
        performSegue(withIdentifier: "GoToWeb", sender: nil)
    }
}

And call prepareForSegue

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        if (segue.identifier == "GoToWeb") {
            let vc = segue.destination as! TermsAndPrivacyViewController
            vc.url = "YOUR_URL"
        }

And the code inside TermsAndPrivacyViewController don't change

Edit:

Maybe your not binding well your UIButton, can you verify in the right panel, in the section "Show the connection inspector" if your button is call only once.

Upvotes: 0

Abbas Torabi
Abbas Torabi

Reputation: 255

maybe you use library or framework that not supported by those device. you must see the error

did you try this?

when the app crashing, in the console press cmd+F and search exception. now you can see your error

hope to helpful.

Upvotes: 1

Related Questions