BLACK FRIDAY SALE: Save big on all my Swift books and bundles! >>

SOLVED: 'animation' was deprecated in iOS 15.0

Forums > SwiftUI

I am trying to code but this message is in my way because of the display of yellow around the area. How do I fix this? Here is my code:

.animation(Animation.linear(duration: 8).repeatForever(autoreverses: false))


Could you provide more code, as the way you are using the .animation modifier matters, and it is not possible to tell what the issue is from this one line of code?

Whan you paste paste your code in to your reply, if you put three back ticks, on separate lines, before and after your code, it will format the code suitably for displaying here. For example

.animation(Animation.linear(duration: 8).repeatForever(autoreverses: false))



If your animation is triggerred once a value is changed you should have the following


.easeOut(duration: 1).repeatForever(autoreverses: false), value: animationAmount

The animationAmount is a @State private var that once is changed the animation is triggerred.


@Greenamberred Sorry, here is the code.

@State var scrollTtext = false

VStack {

Text ("Sample text.")
.frame (width: 600)
.offset (x: scrollTtext ? -182 : 300)
.animation (Animation.linear (duration: 8). repeatForever (autoreverses:
.onAppear () {
self.scrollTtext. toggle ()


There is a suggestion on how to fix it with the error message presented.

as @Bnerd mentioned add the value parameter.

.animation (Animation.linear (duration: 8).repeatForever (autoreverses: false), value: scrollTtext)

BTW, the value parameter is not needed if Self is Equatable (your original would have worked), except in this case it is not Equatable, so value is needed.


@Greenamberred @Bnerd



Also from iOS 16, and onwards you should be using withAnimation


Hacking with Swift is sponsored by RevenueCat

SPONSORED In-app subscriptions are a pain to implement, hard to test, and full of edge cases. RevenueCat makes it straightforward and reliable so you can get back to building your app. Oh, and it's free if your app makes less than $10k/mo.

Learn more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.