Animate Auto Layout Constraints and Alpha on NSView

Swift 5

animator() is the key.

You can simply do like this:

 NSAnimationContext.runAnimationGroup({ context in

    //Indicate the duration of the animation
    context.duration = 0.25
    self.popupConstraintX.animator().constant = x
    self.popupConstraintY.animator().constant = y
    self.graphPopup.animator().alphaValue = 1.0
   
   }, completionHandler:nil)

The modification of alphaValue is happening before you have turned on implicit animation, so the alpha will not be animated. It's unclear to me whether that was intentional or not.

The view is not animating to the position given by the popupConstraints, because you're not actually doing anything inside the animation block that would cause the view's frame to change. In order to trigger an implicit animation, you must not only update constraints; you must also ensure that the view's frame changes within the animation block. If you're using AutoLayout, this is usually done by calling layoutSubtreeIfNeeded.

However, because you updated the constraints and called layoutSubtreeIfNeeded() prior to the animation block, there are no additional frame changes left to make inside the block (unless there's something happening down in updateConstraints() which you haven't shown us.)

You should remove the first call to layoutSubtreeIfNeeded(), or if it's still necessary, put it above the popupConstraint modifications. Then, when you call layoutSubtreeIfNeeded() within the animation block, a new frame will be set based on those changed constraints, and you should see animation happening.