Lottie-ios: App crashes when using IBOutlet

Created on 1 Apr 2019  路  2Comments  路  Source: airbnb/lottie-ios

This issue is a:

  • [X] Crashing Bug
  • [X] Regression (Something that once worked, but doesn't work anymore)

Which Version of Lottie are you using?

Lottie 3.0.3

What Platform are you on?

  • [X] iOS

What Language are you in?

  • [X] Swift

Expected Behavior

I expect that the animation worked as it did in pre 3.x versions.

Actual Behavior

The app crashes.

Code Example

I have code like this:

import UIKit
import Lottie

class BlockForNonProViewController: UIViewController {
    @IBOutlet weak var animationContainer: AnimationView!
    @IBOutlet weak var okButton: UIButton!

    var shouldHideOkButton: Bool = true

    override func viewDidLoad() {
        super.viewDidLoad()
        let animation = Animation.named("blocked-animation")
        animationContainer.animation = animation
        animationContainer.contentMode = .scaleAspectFit
        animationContainer.loopMode = .loop
        animationContainer.play()
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        okButton.isHidden = shouldHideOkButton
    }

    @IBAction func okButtonTapped(_ sender: Any) {
        self.dismiss(animated: true, completion: nil)
    }
}

The app crashes on the line animationContainer.animation = animation with an "unrecognized selector sent to instance". It seems the view controller itself is sent the selector removeFromLayer which makes no sense on a view controller.

The animation view is an IBOutlet which perhaps is what version 3.x can't handle?

Most helpful comment

Seems like a duplicate. Setting the module field to Lottie should fix this problem. Its a strange issue with cocoapods and swift that it doesnt autofill. Im looking into that.

All 2 comments

possible duplicate of Issue 826

Seems like a duplicate. Setting the module field to Lottie should fix this problem. Its a strange issue with cocoapods and swift that it doesnt autofill. Im looking into that.

Was this page helpful?
0 / 5 - 0 ratings