Quick Start Guide
This guide will walk you through creating your first Rive animation in an iOS app, from installation to rendering an interactive animation on screen.Prerequisites
Before starting, ensure you have:- Xcode 14.0 or later installed
- An iOS project targeting iOS 14.0+ (or macOS 13.1+, tvOS 16.0+, visionOS 1.0+)
- The RiveRuntime package installed (see Installation Guide)
Step 1: Add a Rive File to Your Project
Get a Rive File
Download a
.riv file from the Rive Community or create your own in the Rive Editor.For this guide, we’ll use a file named truck.riv.Add to Xcode Project
Drag the
.riv file into your Xcode project navigator. Make sure to:- Check Copy items if needed
- Select your app target in Add to targets
Step 2: Import RiveRuntime
At the top of your Swift file, import the RiveRuntime framework:Step 3: Create Your First Animation
Choose the approach that matches your app architecture:By default,
RiveViewModel automatically plays the first animation in the file. You can customize this behavior with additional parameters.Step 4: Customize Playback Options
Control animation playback, layout, and loop behavior:Customization Options
Layout Options
Control how your animation fits within its container:Layout Configuration
Step 5: Add Interactivity with State Machines
State machines make your animations interactive by responding to user input:State Machine Example
Input Types
State machines support three types of inputs:Step 6: Display Multiple Animations
You can display different artboards and animations from the same Rive file:Multiple Animations
Complete Working Example
Here’s a complete example that puts it all together:Complete Example
Common RiveViewModel Methods
Next Steps
Now that you’ve created your first Rive animation, explore more advanced features:Animation Playback
Learn about advanced playback control and animation management
State Machines
Create complex interactive animations with state machines
Layout
Master layout options, fit modes, and alignment
Events
Listen and respond to events from your animations
Troubleshooting
Animation Not Showing
- Verify the
.rivfile is in your bundle resources - Check the file name matches exactly (case-sensitive)
- Ensure the view has a non-zero frame size
Animation Not Playing
- Check that
autoPlayis set totrueor callviewModel.play()explicitly - Verify the animation name exists in your Rive file
- Make sure the artboard name is correct if specified
State Machine Inputs Not Working
- Verify the state machine name is correct
- Check that input names match exactly (case-sensitive)
- Ensure the input type matches (number, boolean, or trigger)
- Confirm the state machine is properly configured in the Rive editor
Resources
- Rive Community Files - Download free Rive animations
- Rive Editor - Create your own animations
- API Documentation - Detailed API reference
- GitHub Examples - More code examples