CMYR - "his could also happen if you've wired up a button to an IBAction that doesn't exist anymore (or has been renamed)"
If you're running into this problem make sure that you go to Main.storyboard, RIGHT click on the yellow box icon (view controller) at the top of the phone outline and DELETE the outlet(s) with yellow flags.
What happens in instances like this is you probably named an action, then renamed it. You need to delete the old name and if that was the only issue will start right up in sim!
Did you set the OS_ACTIVITY_MODE variable by any chance? To check if you have this variable set (and turn it off), in Xcode 9, do the following:
Select from Xcode menu Product -> Scheme -> Edit Scheme..
Select the Run scheme and look under Arguments.
If you see the OS_ACTIVITY_MODE variable checked, deselect it
In Xcode 9 and Swift 4:
Print exception stack to know the reason of the exception:
Add (+) Add Exception Breakpoint.
Select the new breakpoint, Control-Click, Edit Breakpoint.
In my case, I was calling a delegate method but the method wasn't declared.
This error is generic and can appear by a number of reasons. Make sure you have not disabled your Logs to actually see what happened. Enable OS_ACTIVITY_MODE in the schemes if you have disabled it. You might have disabled it to prevent a lot of irrelevant logs but they are handy.
You can also trace the cause in more details by adding an exception breakpoint po $arg1
. As already mentioned by Ahmed-Lotfi
Here is a common checklist that you can go through.
2) Check if you have renamed an IBOutlet and calling it
3) Check if you have renamed a method name or the method doesn't exist
4) Check if you are trying to add or remove any view from hierarchy
5) Check for any missing framework or library
6) Check if you’ve forgot to register your custom cell identifier
7) Check for any missing flag in the Proejct Setting (-obj) or any other linker flag etc.
Other solutions didn't work form me, here's mine. It applies only to Xcode 8 when running in Swift 2.3 legacy mode:
Looks like Interface Builder is trying to rename the method that should be hooked up to the button.
Here's a radar with more details.
The solution (workaround) is to manually replace the method parameter name to _
:
@IBAction func editPictureTapped(sender: UIButton) { // not working
print("Tapped")
}
Change to this:
@IBAction func editPictureTapped(_: UIButton) { // working OK
print("Tapped")
}
It could also be wrong Segue Identifier Name. Eg -
performSegueWithIdentifier("wrongSegueName", sender: self)
My situation was a little different, I was trying to segue into a UINavigationController
, and what fixed it for me was getting the main queue portion.
For Objective-C:
dispatch_async(dispatch_get_main_queue(), ^{
[self performSegueWithIdentifier:@"SegueName" sender:self];
});
For Swift 3:
DispatchQueue.main.async { [weak self] in
self?.performSegue(withIdentifier: "SegueName", sender: self)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With