I'm trying to implement an animationView using Lottie & SwiftUI.
this is my code :
import SwiftUI
import Lottie
struct ContentView: View {
var body: some View {
AnimationsView()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
struct AnimationsView : UIViewRepresentable {
func makeUIView(context: UIViewRepresentableContext<AnimationsView>) ->
AnimationView {
let aniView = AnimationView()
let animation = Animation.named("Switch", subdirectory: "TestAnimations")
aniView.animation = animation
aniView.play()
return aniView
}
func updateUIView(_ uiView: AnimationView, context:
UIViewRepresentableContext<AnimationsView>) {
}
}
I've added the last version of Lottie as Swift Package dependencies. The preview in SwiftUI show me the animation and everything is OK at this state. I'm not using Storyboard it should open the View and the lottie animation inside.
When I run the app, The app crash and I have this message code : Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
As I understand it there's something not initialized and the return value is null ... I'm trying to do the same thing as in this tutorial : https://www.youtube.com/watch?v=iuEqGyBYaE4
What's wrong?
thank you in advance