I'm struggling the whole day to fix "has no segue with identifier" error and got stuck.
Error message:
SegueTest[41862:1585831] *** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'Receiver (<SegueTest.TableViewController: 0x7feed6510260>) has no segue with identifier 'tableToCollectionSegue''
*** First throw call stack:
Related files getting error:
Please check my Main.storyboard
on GitHub.
Capture of segue configuration for ViewController (???? Working)
Capture of segue configuration for TableViewController (❌ Getting error)
Environment:
- macOS Mojave 10.14.2
- Xcode 10.1
- Swift 4.2
What I did in Main.storyboard:
Created
UINavigationController
as an initial view controller and connect toRootViewController
as a root view controllerCreate
UINavigationController
that opened fromRootViewController
as a modal viewConnected the
Open Modal
button with the modalUINavigationController
and named itnavigationSegue
Create
ViewController
,TableViewController
, andCollectionViewController
Connect the modal
UINavigationController
with theViewController
as a root view controllerConnect the
ViewController
with theTableViewController
as a triggered segue (manual) namedviewToTableSegue
Connect the
TableViewController
with theCollectionViewController
as a triggered segue (manual) namedtableToCollectionSegue
Connect the the
Next
Button on theViewController
with@IBAction func didTapNext(_ sender: Any)
declared inViewController.swift
How the error occurs:
When I called performSegue(withIdentifier:sender:)
in ViewController.swift
, it works.
(Segue capture)
// Go to TableViewController
@IBAction func didTapNext(_ sender: Any) {
// ???? Working
self.performSegue(withIdentifier: "viewToTableSegue", sender: nil)
}
When I called performSegue(withIdentifier:sender:)
in TableViewController.swift
, it got the error.
(Segue capture)
override func tableView(_ tableView: UITableView,
didSelectRowAt indexPath: IndexPath) {
self.tableView.deselectRow(at: indexPath, animated: true)
// ❌ The segue `tableToCollectionSegue` is connected
// from `TableViewController` to `UICollectionViewController`,
// but got error.
//
// *** Terminating app due to uncaught exception 'NSInvalidArgumentException',
// reason: 'Receiver (<SegueTest.TableViewController: 0x7feeea04a090>) has no segue with identifier 'tableToCollectionSegue''
self.performSegue(withIdentifier: "tableToCollectionSegue", sender: nil)
// ❌ The segue `tableToCollectionSegue` is not connected
// from `UINavigationController` to `UICollectionViewController`.
// This error is expected.
//
// *** Terminating app due to uncaught exception 'NSInvalidArgumentException',
// reason: 'Receiver (<SegueTest.TableViewController: 0x7feeea04a090>) has no segue with identifier 'tableToCollectionSegue''
// self.navigationController?.performSegue(withIdentifier: "tableToCollectionSegue", sender: self)
}
What I have read:
- performSegueWithIdentifier has no segue with identifier
- Receiver has no segue with identifier error message
- performSegueWithIdentifier produce no segue with identifier error
- Segue Error : ViewController has no segue with identifier
- And more
What I have tried:
- Make sure the segue identifiers are correctly specified and actually connected
- Reset all simulator settings and contents
- Clean Xcode Build Folders and
~/Library/Developer/Xcode/DerivedData/
directory - Rename Storyboard
- Restart and rebuild Xcode project
- Restart Mac