Signal SIGABRT error when using segue

So, after attempting to use a custom transition, I always get the Signal SIGABRT error. I tried to switch the segue to a "show" segue, and suddenly, it starts working. Here's the code it points to.



class AppDelegate: UIResponder, UIApplicationDelegate {



For some reason, I cannot find an error code either. But anyway, here's the code in the transition.



let transition = CircularTransition()

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

let SecondView = segue.destination as! SecondView

SecondView.transitioningDelegate = self

SecondView.modalPresentationStyle = .custom

}

func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {

transition.transitionMode = .dismiss

transition.startingPoint = menuButton.center

transition.circleColor = menuButton.backgroundColor!

return transition



I think it's a problem with the segue or the references.



If you need more details on the "CircularTransition", here's the code. It might be a problem here, too.



import UIKit



class CircularTransition: NSObject {



var circle = UIView()



var startingPoint = CGPoint.zero {

didSet {

circle.center = startingPoint

}

}

var circleColor = UIColor.white

var duration = 0.3

enum CircularTransitionMode:Int {

case present, dismiss, pop

}

var transitionMode:CircularTransitionMode = .present

}

extension CircularTransition:UIViewControllerAnimatedTransitioning {

func transitionDuration(using transitionContext:UIViewControllerContextTransitioning?) -> TimeInterval {

return duration

}

func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {

let containerView = transitionContext.containerView

if transitionMode == .present {

if let presentedView = transitionContext.view(forKey: UITransitionContextViewKey.to) {

let viewCenter = presentedView.center

let viewSize = presentedView.frame.size

circle = UIView()

circle.frame = frameForCircle(withViewCenter: viewCenter, size: viewSize, startpoint: startingPoint)

circle.layer.cornerRadius = circle.frame.size.height / 2

circle.center = startingPoint

circle.backgroundColor = circleColor

circle.transform = CGAffineTransform(scaleX: 0.001, y: 0.001)

containerView.addSubview(presentedView)

UIView.animate(withDuration: duration, animations: {

self.circle.transform = CGAffineTransform.identity

presentedView.transform = CGAffineTransform.identity

presentedView.alpha = 1

presentedView.center = viewCenter

}, completion: {(success:Bool) in

transitionContext.completeTransition(success)

})



}

}else{

let transitionModeKey = (transitionMode == .pop) ? UITransitionContextViewKey.to : UITransitionContextViewKey.from

if let returningView = transitionContext.view(forKey: transitionModeKey) {

let viewCenter = returningView.center

let viewSize = returningView.frame.size

circle.frame = frameForCircle(withViewCenter: viewCenter, size: viewSize, startpoint: startingPoint)

circle.center = startingPoint

UIView.animate(withDuration: duration, animations: {

self.circle.transform = CGAffineTransform(scaleX: 0.001, y: 0.001)

returningView.transform = CGAffineTransform(scaleX: 0.001, y: 0.001)

returningView.center = self.startingPoint

returningView.alpha = 0

if self.transitionMode == .pop {

containerView.insertSubview(returningView, belowSubview: returningView)

containerView.insertSubview(self.circle, belowSubview: returningView)

}

}, completion: {(success:Bool) in

returningView.center = viewCenter

returningView.removeFromSuperview()

self.circle.removeFromSuperview()

transitionContext.completeTransition(success)

}

)}

}

}

func frameForCircle (withViewCenter viewCenter:CGPoint, size viewSize:CGSize, startpoint:CGPoint) -> CGRect {

let xLength = fmax(startpoint.x, viewSize.width - startpoint.x)

let yLength = fmax(startpoint.y, viewSize.height - startpoint.y)

let offsetVector = sqrt(xLength * xLength + yLength * yLength) * 2

let size = CGSize(width: offsetVector, height: offsetVector)

return CGRect(origin: CGPoint.zero, size: size)

}

}

There's not much there to go on but try removing both uses of '!'. Test for nil instead of telling the compiler that you're sure of there being a value.

(It might not help but at least it would remove the most suspicious thing in the code.)

The fact that it fails with

SIGABRT
indicates that this is not a force unwrap problem (which typically trigger an illegal instruction or breakpoint exception, reflected as
SIGILL
or
SIGTRAP
).
SIGABRT
is most commonly associated with an uncaught language exception.

@ENYGMA, please post a symbolicated Apple crash report for this crash. You can learn more about crash reports in Technote 2151 Understanding and Analyzing iOS Application Crash Reports.

IMPORTANT To generate a crash report you’ll have to run your app outside of Xcode. Xcode catches crashes like this and that prevents the generation of a crash report.

Also, it helps if you format your crash report as code, using the

<>
icon in the editor.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Here's the error code.



2018-05-02 07:30:57.200 Mass[63014:1249519] Simulator user has requested new graphics quality: 100

2018-05-02 07:30:57.288 Mass[63014:1249519] Unknown class MenuView in Interface Builder file.

2018-05-02 07:32:57.992 Mass[63014:1249519] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not perform segue with identifier '(null)'. A segue must either have a performHandler or it must override -perform.'

*** First throw call stack:

(

0 CoreFoundation 0x000000010b6f6b0b __exceptionPreprocess + 171

1 libobjc.A.dylib 0x000000010b15b141 objc_exception_throw + 48

2 UIKit 0x000000010c9dff45 -[UIStoryboardSegue _prepare] + 0

3 UIKit 0x000000010c9cb444 -[UIStoryboardSegueTemplate _performWithDestinationViewController:sender:] + 447

4 UIKit 0x000000010c9cb254 -[UIStoryboardSegueTemplate _perform:] + 82

5 UIKit 0x000000010c9cb517 -[UIStoryboardSegueTemplate perform:] + 157

6 UIKit 0x000000010c204d82 -[UIApplication sendAction:to:from:forEvent:] + 83

7 UIKit 0x000000010c3895ac -[UIControl sendAction:to:forEvent:] + 67

8 UIKit 0x000000010c3898c7 -[UIControl _sendActionsForEvents:withEvent:] + 450

9 UIKit 0x000000010c388802 -[UIControl touchesEnded:withEvent:] + 618

10 UIKit 0x000000010c2727ea -[UIWindow _sendTouchesForEvent:] + 2707

11 UIKit 0x000000010c273f00 -[UIWindow sendEvent:] + 4114

12 UIKit 0x000000010c220a84 -[UIApplication sendEvent:] + 352

13 UIKit 0x000000010ca045d4 __dispatchPreprocessedEventFromEventQueue + 2926

14 UIKit 0x000000010c9fc532 __handleEventQueue + 1122

15 CoreFoundation 0x000000010b69cc01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17

16 CoreFoundation 0x000000010b6820cf __CFRunLoopDoSources0 + 527

17 CoreFoundation 0x000000010b6815ff __CFRunLoopRun + 911

18 CoreFoundation 0x000000010b681016 CFRunLoopRunSpecific + 406

19 GraphicsServices 0x00000001113b0a24 GSEventRunModal + 62

20 UIKit 0x000000010c203134 UIApplicationMain + 159

21 Mass 0x000000010ab69af7 main + 55

22 libdyld.dylib 0x000000010f53e65d start + 1

23 ??? 0x0000000000000001 0x0 + 1

)

libc++abi.dylib: terminating with uncaught exception of type NSException

(lldb)

The except message here seems pretty clear:

Could not perform segue with … A segue must either have a

performHandler
or it must override
-perform
.

Alas my knowledge of UIKit does not extend far enough to walk you through this process. I’ve moved your thread over to App Frameworks > Cocoa Touch topic area and hopefully someone there can help you out.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

did you define an identifier for this custom segue ?

Yes, I did. And for some awkward reason, only the Show segue works, but when I use any other segue, including custom, it gives me SIGABRT.

Alright. Thank you, I appreciate it. (:

You have to subclass UIStoryboardSegue


Read the doc that explains how to do it:

h ttps://developer.apple.com/library/content/featuredarticles/ViewControllerPGforiPhoneOS/UsingSegues.html



Creating a Custom Segue


Interface Builder provides segues for all of the standard ways to transition from one view controller to another—from presenting a view controller to displaying a controller in a popover. However, if one of those segues doesn’t do what you want, you can create a custom segue.


The Life Cycle of a Segue


To understand how custom segues work, you need to understand the life cycle of a segue object. Segue objects are instances of the UIStoryboardSegue class or one of its subclasses. Your app never creates segue objects directly; UIKit creates them when a segue is triggered. Here’s what happens:


The view controller to be presented is created and initialized.

The segue object is created and its initWithIdentifier:source:destination: method is called. The identifier is the unique string you provided for the segue in Interface Builder, and the two other parameters represent the two controller objects in the transition.

The presenting view controller’s prepareForSegue:sender: method is called. See Modifying a Segue’s Behavior at Runtime.

The segue object’s perform method is called. This method performs a transition to bring the new view controller onscreen.

The reference to the segue object is released.

Implementing a Custom Segue


To implement a custom segue, subclass UIStoryboardSegue and implement the following methods:


Override the initWithIdentifier:source:destination: method and use it to initialize your custom segue object. Always call super first.

Implement the perform method and use it to configure your transition animations.

NOTE


If your implementation adds properties to configure the segue, you cannot configure these attributes in Interface Builder. Instead, configure the custom segue’s additional properties in the prepareForSegue:sender: method of the source view controller that triggered the segue.


Listing 9-2 shows a very simple custom segue. This example simply presents the destination view controller without any sort of animation, but you can extend this idea with your own animations as necessary.


Listing 9-2A custom segue

- (void)perform {

// Add your own animation code here.


[[self sourceViewController] presentViewController:[self destinationViewController] animated:NO completion:nil];

}

SIGABRT still pops up. Either I messed up on the instruction or it doesn't work. :/

Signal SIGABRT error when using segue
 
 
Q